- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-01-2023 09:00 AM
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-01-2023 09:35 AM
Hello @chandan31
Please try this
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var identifer = g_form.getValue('current_shift_identifier');
var wsOptions2 = 'BR';
var wsOptions1 = 'VR';
var wsOptions3 = 'SR';
var wsOptions4 = 'VUF';
var wsOptions5 = 'VP';
if ((identifer.startsWith(wsOptions2)) || (identifer.startsWith(wsOptions3)) || (identifer.startsWith(wsOptions1))) {
g_form.removeOption('indicate_your_start_week', '6');
g_form.setVisible('indicate_your_start_week', true);
} else if ((identifer.startsWith(wsOptions4)) || (identifer.startsWith(wsOptions5))) {
g_form.addOption('indicate_your_start_week', '6','6');
g_form.setVisible('indicate_your_start_week', true);
}
else {
g_form.setVisible('indicate_your_start_week', false);
}
}
Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-01-2023 09:47 PM
Hello @chandan31 ,
Use this -
function onChange(control, oldValue, newValue, isLoading) {
if (newValue == '') {
getVal();
return;
}
getVal();
function getVal(){
var identifer = g_form.getValue('current_shift_identifier');
var wsOptions2 = 'BR';
var wsOptions1 = 'VR';
var wsOptions3 = 'SR';
var wsOptions4 = 'VUF';
var wsOptions5 = 'VP';
if ((identifer.startsWith(wsOptions2)) || (identifer.startsWith(wsOptions3)) || (identifer.startsWith(wsOptions1))) {
g_form.removeOption('indicate_your_start_week', '6');
g_form.setVisible('indicate_your_start_week', true);
} else if ((identifer.startsWith(wsOptions4)) || (identifer.startsWith(wsOptions5))) {
g_form.addOption('indicate_your_start_week', '6','6');
g_form.setVisible('indicate_your_start_week', true);
}
else {
g_form.setVisible('indicate_your_start_week', false);
}
}
}
This will execute onChange and onLoad as well.
Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-01-2023 09:50 PM
HI @chandan31 ,
I trust you are doing great.
Please refer the below updated code.
function onChange(control, oldValue, newValue, isLoading) {
// Check if the form is loading or if the new value is empty, then exit the function
if (isLoading || newValue == '') {
return;
}
// Get the value of the 'current_shift_identifier' field
var identifier = g_form.getValue('current_shift_identifier');
// Define the identifiers that you want to check against
var wsOptions = ['BR', 'VR', 'SR', 'VUF', 'VP'];
// Check if the identifier starts with any of the defined options
if (wsOptions.some(option => identifier.startsWith(option))) {
// If identifier starts with 'BR', 'VR', or 'SR'
if (['BR', 'VR', 'SR'].includes(identifier.substring(0,2))) {
g_form.removeOption('indicate_your_start_week', '6');
}
// If identifier starts with 'VUF' or 'VP'
else if (['VUF', 'VP'].includes(identifier.substring(0,3))) {
g_form.addOption('indicate_your_start_week', '6', '6');
}
// Make the 'indicate_your_start_week' field visible
g_form.setVisible('indicate_your_start_week', true);
}
// If identifier doesn’t match any option, hide the 'indicate_your_start_week' field
else {
g_form.setVisible('indicate_your_start_week', false);
}
}
Was this answer helpful?
Please consider marking it correct or helpful.
Your feedback helps us improve!
Thank you!
Regards,
Amit Gujrathi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-01-2023 10:07 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-01-2023 09:50 PM
HI @chandan31 ,
I trust you are doing great.
Please refer the below updated code.
function onChange(control, oldValue, newValue, isLoading) {
// Check if the form is loading or if the new value is empty, then exit the function
if (isLoading || newValue == '') {
return;
}
// Get the value of the 'current_shift_identifier' field
var identifier = g_form.getValue('current_shift_identifier');
// Define the identifiers that you want to check against
var wsOptions = ['BR', 'VR', 'SR', 'VUF', 'VP'];
// Check if the identifier starts with any of the defined options
if (wsOptions.some(option => identifier.startsWith(option))) {
// If identifier starts with 'BR', 'VR', or 'SR'
if (['BR', 'VR', 'SR'].includes(identifier.substring(0,2))) {
g_form.removeOption('indicate_your_start_week', '6');
}
// If identifier starts with 'VUF' or 'VP'
else if (['VUF', 'VP'].includes(identifier.substring(0,3))) {
g_form.addOption('indicate_your_start_week', '6', '6');
}
// Make the 'indicate_your_start_week' field visible
g_form.setVisible('indicate_your_start_week', true);
}
// If identifier doesn’t match any option, hide the 'indicate_your_start_week' field
else {
g_form.setVisible('indicate_your_start_week', false);
}
}
Was this answer helpful?
Please consider marking it correct or helpful.
Your feedback helps us improve!
Thank you!
Regards,
Amit Gujrathi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-01-2023 09:52 PM
Hello @Amit Gujarathi
I already gave the same answer, then why this again ?
Please don't try to confuse readers.
And we are from one community only so we don't have to change for accept solutions and helpfuls.
We have to chase for helping the persons.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-01-2023 09:56 PM
it is working on onchange but onload it is not working because identifer is populating the loading the form
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-01-2023 09:58 PM
I have created on load client script also but not working