Set catalog variable mandatory based on sc task state
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-22-2024 10:11 PM
2 REPLIES 2
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-22-2024 10:27 PM
Hi @Avee90
your script is almost correct, you just need some moifications in it....
// Assuming ‘state’ is a variable on the catalog item. If it’s a field on the task, you’d need to approach it differently.
var state = g_form.getValue('state');
// Assuming ‘short_description’ is a variable. If it’s a field, this approach is fine.
// Otherwise, for a variable, you use g_form.getValue(‘variable_name’);
var sd = g_form.getValue('short_description');
if (sd === 'Please attach the template') {
if (state === '3') { // Assuming state ‘3’ is the value representing the desired choice, and it’s captured as a string
g_form.setMandatory('upload_the_template', true);
} else {
// Optionally, make it not mandatory if the condition is not met
g_form.setMandatory('upload_the_template', false);
}
Please Mark this Helpful and Accepted Solution. If this Helps you to understand. This will help both the community and me..
- Keep Learning
Thanks & Regards
Deepak Sharma
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-22-2024 10:54 PM
HI @Avee90
check the below code.
var state = g_form.getValue('state');
var sd = g_form.getValue('short_description');
if (sd === 'Please attach the template') {
if (state = 3) { // state 3 is the value representing integer value
g_form.setMandatory('upload_the_template', true);
} else {
g_form.setMandatory('upload_the_template', false);
}
If my answer finds you well, helpful, and related to the question asked. Please mark it as correct and helpful.
Thanks
dgarad
Thanks
dgarad