Depending on the field, another field is Mandatory and Visible.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-16-2022 05:07 AM
Hi Team,
I need to get some code as per the requirement,
1) I had a choice field in custom table which had 3 choices in the choice field X,Y,Z. so when ever I select X or Y from the "Choice Field" then the "Text Field" should be appeared and when ever I select Z from the "Choice Field" then the "Text Field" should be disappeared.
2) I had a reference field with auto updated user and when we impersonate with that user, the "Text Field" should be mandatory also there will be a check box field and if the "Check Box" field is checked then the "Text Field" should be disappeared until the ticket is closed.
Please help me on this .
Thanks,
Karishma.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-16-2022 05:35 AM
Hi Yousaf,
This is actual code,
var pm = g_form.getValue('u_payment_method_choice');
if (isLoading) {
if ((pm == 'u_ach' || pm == 'u_wired') && ( g_form.getValue('u_cost_accountant') == g_user.userID || g_scratchpad.why)) {
g_form.setDisplay('u_if_not_why', true);
g_form.setMandatory('u_if_not_why', true);
} else {
g_form.setMandatory('u_if_not_why', false);
g_form.setDisplay('u_if_not_why', false);
}
} else {
if ((newValue == 'u_wired' || newValue == 'u_ach') && ( g_form.getValue('u_cost_accountant') == g_user.userID || g_scratchpad.why)) {
g_form.setMandatory('u_if_not_why', true);
g_form.setDisplay('u_if_not_why', true);
} else {
g_form.setMandatory('u_if_not_why', false);
g_form.setDisplay('u_if_not_why', false);
}
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-16-2022 05:42 AM
if (isLoading)
return;
var pm = g_form.getValue('u_payment_method_choice');
if ((pm == 'u_ach' || pm == 'u_wired') && ( g_form.getValue('u_cost_accountant') == g_user.userID || g_scratchpad.why)) {
g_form.setDisplay('u_if_not_why', true);
g_form.setMandatory('u_if_not_why', true);
} else {
g_form.setMandatory('u_if_not_why', false);
g_form.setDisplay('u_if_not_why', false);
}
} else {
if ((newValue == 'u_wired' || newValue == 'u_ach') && ( g_form.getValue('u_cost_accountant') == g_user.userID || g_scratchpad.why)) {
g_form.setMandatory('u_if_not_why', true);
g_form.setDisplay('u_if_not_why', true);
} else {
g_form.setMandatory('u_if_not_why', false);
g_form.setDisplay('u_if_not_why', false);
}
}
}
***Mark Correct or Helpful if it helps.***

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-16-2022 05:42 AM
try this please
***Mark Correct or Helpful if it helps.***
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-16-2022 06:12 AM
Hi Yousaf,
Its not working as per the expectation. please send the code as per the requirement.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-16-2022 11:11 PM
Why are you persisting on using code for this? Using a UI policy will work easy for your requirement. You only provide your code (that isn't working) and give no explanation on why you wouldn't use the best way to do this on the platform.
Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark