- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā03-04-2022 08:49 AM
Hi guys. I need help in with my requirements.
Currently, user can cancel the SCTASK without adding a note on why it is being canceled.
We need to make sure that the ADDITIONAL COMMENTS field will become MANDATORY ONLY IF the SCTASK is being canceled. It should require users to add notes on why this is being canceled.
If the user did not put any comments, they can't cancel the SCTASK and if they insist, there should be a warning that the Additional Comments field is MANDATORY and will require notes.
This is our SCRIPT of the UI Action CANCEL. Can someone help me with the requirements?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā03-04-2022 09:16 AM
Hi
Also would like to share here the UI action can itself execute as both Client and Server side methods.
Please refer the below link which explains this very clearly:
https://servicenowguru.com/system-ui/ui-actions-system-ui/client-server-code-ui-action/
So now for your requirement, you can update your UI Action as below:
1) Give a action name say "cancelTask"
2) Click on the check box "Client" on UI Action form
3) Give a valid on click function such as "cancelCatalogTask()"
4) Now update your current UI Action script as below:
function cancelCatalogTask() {
g_form.setMandatory('comments',true);
//Call the UI Action and skip the 'onclick' function
gsftSubmit(null, g_form.getFormElement(), 'cancelTask'); //MUST call the 'Action name' set in this UI Action
}
//Ensure call to server-side function with no browser errors
if (typeof window == 'undefined')
runBusRuleCode();
//Server-side function
function runBusRuleCode() {
// Add your current code here which is supposed to run on Server side
}
Sharing the screenshot as well for reference on the changes you need to do:
Have shared both the methods with you and both should work. Please try and let me know if you have a query.
Hope this helps. Please mark the answer as correct/helpful based on impact.
Regards,
Shloke
Regards,
Shloke
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā03-04-2022 09:37 AM
Hi,
It's fine..I have just given an overview... use my above script and modify according to your requirement... It was perfectly working fine.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā03-04-2022 10:14 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā03-04-2022 09:10 AM
Hi
You can achieve this using a On Change Client Script on Catalog Task table and use the script below:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
if(newValue == 'Put the value of cancel here'){
g_form.setMandatory('comments',true);
}
//Type appropriate comment here, and begin script below
}
Hope this helps. Please mark the answer as correct/helpful based on impact.
Regards,
Shloke
Regards,
Shloke
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā03-04-2022 09:37 AM
Hi Mr.
If the user did not put any comments, they can't cancel the SCTASK and if they insist, there should be a warning that the Additional Comments field is MANDATORY and will require notes.
This is our existing UI ACTION
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā03-04-2022 09:16 AM
Hi
Also would like to share here the UI action can itself execute as both Client and Server side methods.
Please refer the below link which explains this very clearly:
https://servicenowguru.com/system-ui/ui-actions-system-ui/client-server-code-ui-action/
So now for your requirement, you can update your UI Action as below:
1) Give a action name say "cancelTask"
2) Click on the check box "Client" on UI Action form
3) Give a valid on click function such as "cancelCatalogTask()"
4) Now update your current UI Action script as below:
function cancelCatalogTask() {
g_form.setMandatory('comments',true);
//Call the UI Action and skip the 'onclick' function
gsftSubmit(null, g_form.getFormElement(), 'cancelTask'); //MUST call the 'Action name' set in this UI Action
}
//Ensure call to server-side function with no browser errors
if (typeof window == 'undefined')
runBusRuleCode();
//Server-side function
function runBusRuleCode() {
// Add your current code here which is supposed to run on Server side
}
Sharing the screenshot as well for reference on the changes you need to do:
Have shared both the methods with you and both should work. Please try and let me know if you have a query.
Hope this helps. Please mark the answer as correct/helpful based on impact.
Regards,
Shloke
Regards,
Shloke