108
Views
5
Comments
Solved
Select radio button by default
Application Type
Traditional Web

I would like for my radiogroup to select one radiobutton by default.

Here is the value of radiogroup

Here is the default value which is diabled

Here is the radiogroup

Here is a radiobutton


2026-03-10 13-44-16
Carolina Oliveira
Solution

Hello @Jennifer Ayache,

Do you really need to have a local variable that is from data type Species or could you just have it as Species identifier data type? 

By setting the data type to Species identifier you should be able to set a default value.


Best regards,

Carolina Oliveira

2023-12-16 19-57-03
Sanjay Kushwah
Solution

Hii @Jennifer Ayache,

Firstly there is no need to take record type local varibale just  change your local variable data type to soc_species identifier and on initialize of your Screen/Block Just assing desired Value(that you want to keep selected by default) to your local variable.

I am also attaching OML file for your help.


kind regards,

Sanjay Kushwah

RadioGroup.oml
2021-09-06 15-09-53
Dorine Boudry
 
MVP

there is no need for an OnInitialize, you can just give the local variable a default value.

2023-12-16 19-57-03
Sanjay Kushwah


You're absolutely correct, @Dorine Boudry. Setting a default value for the local variable is indeed the preferred method for this specific scenario. It's simpler and saves an unnecessary event trigger. However, using OnInitialize might be a valid option in situations where you need to dynamically determine the default value based on other conditions or user interactions within the Screen or Block.

 Thank you for pointing that out, @Dorine Boudry . I'm always open to learning more efficient ways to code. Your suggestion is definitely a more elegant solution for this case. If you have any other tips or best practices that you could share, I would greatly appreciate it. 


Thanks,

Sanjay Kushwah

2021-09-06 15-09-53
Dorine Boudry
 
MVP

totally agree to do it in OnInitialize when some logic is involved 

2026-03-10 13-44-16
Carolina Oliveira
Solution

Hello @Jennifer Ayache,

Do you really need to have a local variable that is from data type Species or could you just have it as Species identifier data type? 

By setting the data type to Species identifier you should be able to set a default value.


Best regards,

Carolina Oliveira

2023-12-16 19-57-03
Sanjay Kushwah
Solution

Hii @Jennifer Ayache,

Firstly there is no need to take record type local varibale just  change your local variable data type to soc_species identifier and on initialize of your Screen/Block Just assing desired Value(that you want to keep selected by default) to your local variable.

I am also attaching OML file for your help.


kind regards,

Sanjay Kushwah

RadioGroup.oml
2021-09-06 15-09-53
Dorine Boudry
 
MVP

there is no need for an OnInitialize, you can just give the local variable a default value.

2023-12-16 19-57-03
Sanjay Kushwah


You're absolutely correct, @Dorine Boudry. Setting a default value for the local variable is indeed the preferred method for this specific scenario. It's simpler and saves an unnecessary event trigger. However, using OnInitialize might be a valid option in situations where you need to dynamically determine the default value based on other conditions or user interactions within the Screen or Block.

 Thank you for pointing that out, @Dorine Boudry . I'm always open to learning more efficient ways to code. Your suggestion is definitely a more elegant solution for this case. If you have any other tips or best practices that you could share, I would greatly appreciate it. 


Thanks,

Sanjay Kushwah

2021-09-06 15-09-53
Dorine Boudry
 
MVP

totally agree to do it in OnInitialize when some logic is involved 

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.