- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-09-2024 10:03 AM
Hi All,
Hope you are doing well!!
I have the below requirement.
I have a variable "Access type", variable type is Select box(Include none is true) and choices are 1) Single, 2) Group.
Point 1: If you select the choice as "Single" a new variable "Single access" is visible, mandatory and add the choices as mentioned in the below code.
Point 2: If you select the choice as "Group" a new variable "Group access" is visible, mandatory and add the choices as mentioned in the below code.
Point 3: If you select the choice as "None" after selecting point 1or point 2, it should clear the point 1 or point 2 value and hide the variables "Single access" or "Group access".
I have created below onChange client script for this requirement. The point 1 and point 2 is working fine but point 3(none condition) is not working. Please correct my below code if its wrong.
OnChange client script Code:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
//Type appropriate comment here, and begin script below
if (newValue == 'Single') {
g_form.setVisible('single_access ', true);
g_form.setMandatory('group_access', true);
g_form.clearValue('group_access');
g_form.setMandatory('group_access', false);
g_form.setVisible('group_access', false);
g_form.addOption('single_access', 'Teams', 'Teams', 1);
g_form.addOption('single_access', 'Email', 'Email', 2);
g_form.addOption('single_access', 'Outlook', 'Outlook', 3);
g_form.addOption('single_access', 'Data', 'Data', 4);
} else if (newValue == 'group_access') {
g_form.setVisible('group_access', true);
g_form.setMandatory('group_access', true);
g_form.clearValue('single_access');
g_form.setMandatory('single_access', false);
g_form.setVisible('single_access', false);
g_form.addOption('group_access', 'Grp1', 'Grp1', 1);
g_form.addOption('group_access', 'Grp2', 'Grp2', 2);
g_form.addOption('group_access', 'Grp3', 'Grp3', 3);
g_form.addOption('group_access', 'Grp4', 'Grp4', 4);
} else if(newValue == ''{ //new value is 'none' This part is not working
g_form.clearValue('single_access');
g_form.clearValue('group_access');
g_form.setMandatory('group_access', false);
g_form.setMandatory('single_access', false);
g_form.setVisible('group_access', false);
g_form.setVisible('single_access', false);
}
}
Thanks! in advance
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-09-2024 11:24 AM
@Khaja Shaik Please modify as below,
You already have newValue == ‘’ and you can declare those within this loop.
if (isLoading || newValue == '') {
g_form.clearValue('single_access');
g_form.clearValue('group_access');
g_form.setMandatory('group_access', false);
g_form.setMandatory('single_access', false);
g_form.setDisplay('group_access', false);
g_form.setVisible('single_access', false);
}
if (newValue == 'Single') {
g_form.setVisible('single_access ', true);
g_form.setMandatory('group_access', true);
g_form.clearValue('group_access');
g_form.setMandatory('group_access', false);
g_form.setVisible('group_access', false);
g_form.addOption('single_access', 'Teams', 'Teams', 1);
g_form.addOption('single_access', 'Email', 'Email', 2);
g_form.addOption('single_access', 'Outlook', 'Outlook', 3);
g_form.addOption('single_access', 'Data', 'Data', 4);
} else if (newValue == 'group_access') {
g_form.setVisible('group_access', true);
g_form.setMandatory('group_access', true);
g_form.clearValue('single_access');
g_form.setMandatory('single_access', false);
g_form.setVisible('single_access', false);
g_form.addOption('group_access', 'Grp1', 'Grp1', 1);
g_form.addOption('group_access', 'Grp2', 'Grp2', 2);
g_form.addOption('group_access', 'Grp3', 'Grp3', 3);
g_form.addOption('group_access', 'Grp4', 'Grp4', 4);
}
If you want it to in your ‘If and Else’ statement, then you have it as below,
if (isLoading) {
return;
}
The reason for last condition not working is because it’s getting returned as the syntax is same and used twice.
Note : setVisible() will create spaces instead using setDisplay().
Please mark this as helpful and accept it as a solution if this resolves your query.
Thanks,
Sujatha V.M.
Sujatha V.M.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-09-2024 11:24 AM
@Khaja Shaik Please modify as below,
You already have newValue == ‘’ and you can declare those within this loop.
if (isLoading || newValue == '') {
g_form.clearValue('single_access');
g_form.clearValue('group_access');
g_form.setMandatory('group_access', false);
g_form.setMandatory('single_access', false);
g_form.setDisplay('group_access', false);
g_form.setVisible('single_access', false);
}
if (newValue == 'Single') {
g_form.setVisible('single_access ', true);
g_form.setMandatory('group_access', true);
g_form.clearValue('group_access');
g_form.setMandatory('group_access', false);
g_form.setVisible('group_access', false);
g_form.addOption('single_access', 'Teams', 'Teams', 1);
g_form.addOption('single_access', 'Email', 'Email', 2);
g_form.addOption('single_access', 'Outlook', 'Outlook', 3);
g_form.addOption('single_access', 'Data', 'Data', 4);
} else if (newValue == 'group_access') {
g_form.setVisible('group_access', true);
g_form.setMandatory('group_access', true);
g_form.clearValue('single_access');
g_form.setMandatory('single_access', false);
g_form.setVisible('single_access', false);
g_form.addOption('group_access', 'Grp1', 'Grp1', 1);
g_form.addOption('group_access', 'Grp2', 'Grp2', 2);
g_form.addOption('group_access', 'Grp3', 'Grp3', 3);
g_form.addOption('group_access', 'Grp4', 'Grp4', 4);
}
If you want it to in your ‘If and Else’ statement, then you have it as below,
if (isLoading) {
return;
}
The reason for last condition not working is because it’s getting returned as the syntax is same and used twice.
Note : setVisible() will create spaces instead using setDisplay().
Please mark this as helpful and accept it as a solution if this resolves your query.
Thanks,
Sujatha V.M.
Sujatha V.M.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-10-2024 07:06 AM
Hi @Sujatha V M,
Thank you very much for your quick response. Now it is working fine.
Thank you once again!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-12-2024 06:36 AM
Hi @Sujatha V M,
Please help me with the below code. Here we have to show the below variables(Mentioned in the code) 6 times and I have created 6 OnChange client scripts as mentioned below, all the client scripts are working fine but 5th client script not working. Please see the below script and correct if I made any mistake.
Thanks!! in advance.
This OnChange client script is created on the variable "do_you_need_access_to_other_environments_and_or_technology_4" This is the check box.
if (newValue == 'false') {
g_form.setMandatory('environment_5', false);
g_form.setMandatory('technology_5', false);
g_form.clearValue('environment_5');
g_form.clearValue('technology_5');
g_form.setDisplay('do_you_need_access_to_other_environments_and_or_technology_6', false); //This is the check box
g_form.setDisplay('environment_5', false);
g_form.setDisplay('technology_5', false);
g_form.setDisplay('do_you_need_access_to_other_environments_and_or_technology_6', false); //This is the check box
return;
}
//Type appropriate comment here, and begin script below
if (newValue == 'true') {
g_form.setMandatory('environment_5', true);
g_form.setMandatory('technology_5', true);
g_form.setDisplay('environment_5', true);
g_form.setDisplay('technology_5', true);
g_form.setDisplay('do_you_need_access_to_other_environments_and_or_technology_6', true); //This is the check box
g_form.addOption('environment_5', 'Production', 'Production', 1);
g_form.addOption('environment_5', 'Test', 'Test', 2);
g_form.addOption('environment_5', 'test2', 'test2', 3);
g_form.addOption('environment_5', 'UAT', 'UAT', 4);
g_form.addOption('technology_5', 'tech1', 'tech1', 1);
g_form.addOption('technology_5', 'tech2', 'tech2', 2);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-12-2024 06:51 AM
@Khaja Shaik It seems the "Return" value is stopping the execution from not setting it. Can you try the below,
if (isLoading ) {
return;
}
if(newValue == 'true'{
g_form.setMandatory('environment_5', true);
g_form.setMandatory('technology_5', true);
g_form.setDisplay('environment_5', true);
g_form.setDisplay('technology_5', true);
g_form.setDisplay('do_you_need_access_to_other_environments_and_or_technology_6', true); //This is the check box
g_form.addOption('environment_5', 'Production', 'Production', 1);
g_form.addOption('environment_5', 'Test', 'Test', 2);
g_form.addOption('environment_5', 'test2', 'test2', 3);
g_form.addOption('environment_5', 'UAT', 'UAT', 4);
g_form.addOption('technology_5', 'tech1', 'tech1', 1);
g_form.addOption('technology_5', 'tech2', 'tech2', 2);
}
else {
g_form.setMandatory('environment_5', false);
g_form.setMandatory('technology_5', false);
g_form.clearValue('environment_5');
g_form.clearValue('technology_5');
g_form.setDisplay('do_you_need_access_to_other_environments_and_or_technology_6', false); //This is the check box
g_form.setDisplay('environment_5', false);
g_form.setDisplay('technology_5', false);
g_form.setDisplay('do_you_need_access_to_other_environments_and_or_technology_6', false); //This is the check box
}
Do try and let me know.
Please mark this as helpful and accept it as a solution if this resolves your query.
Thanks,
Sujatha V.M.
Sujatha V.M.