- 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 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:38 PM
This script is working but whole loading the form this script is not not working because current shift identifier field is populating during the onload .
Should i create same script in the on load form also
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-01-2023 09:41 PM
Yes u can create on load as well so that it executes after the form load.
Mark Harsh answer as accepted if it helped u resolve your query.
Thanks,
Danish
- 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.