Help on validation on variable for "Close Task" button on catalog task record
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
6 hours ago
Hello,
I have a requirement where one catalog variable is there which is visible on catalog task. User should not be able to close the task without filling this variable.
I have create ui policy which works fine if the user change the state from drop down it does make mandatory the variable but if user uses "Close Task" button the catalog task gets closed complete and later the the variable become mandatory.
How can we put restriction on "Close Task" button.
Below is the script
function closeTaskCheck() {
var catalogItem = g_form.getValue('cat_item');
// Check if this task belongs to a specific catalog item
if (catalogItem == "xyz") {
g_form.setMandatory('variables.link', true);
if (!g_form.getValue('variables.link')) {
alert("Please provide the link before closing this task.");
return; // stop here, don't submit
}
}
// Submit to trigger the server-side script
gsftSubmit(null, g_form.getFormElement(), 'close_catalog_task');
}
if (typeof window == 'undefined') {
// Authorization check
if (current.assigned_to.nil() && gs.getUser().isMemberOf(current.assignment_group)) {
current.assigned_to = gs.getUserID();
current.state = 3;
current.update();
} else if ((gs.getUserID() == current.assigned_to && gs.getUser().isMemberOf(current.assignment_group)) || gs.hasRole("admin")) {
current.state = 3;
current.update();
} else {
gs.addErrorMessage("You are not authorized to close this task.");
current.setAbortAction(true);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
5 hours ago
Hello @Tanya10, you can convert your UI policy to Data Policy and verify. Keep the logic same since as you mentioned that it works fine when user changes the state manually.
Under the Data Policy Rule keep your field as mandatory.
Regards,
Nishant
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
an hour ago
I want to prevent this behavior -when user clicks on that UI Action button. It should not close complete the task if the mandatory field is not filled in.
Manually change of state from drop down is taken care by UI policy