- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-08-2025 11:51 PM
Dear experts,
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-09-2025 01:28 AM
Hi Shivalika, thanks for the reply but I managed to solve the issue using my approach as below:
So I have created two new button one is Save as Draft and one is Submit to Assigned and also a new flag field in the risk event form called u_submitted.
Save as Draft code and condition:
Condition:
current.state == 1 && !current.u_submitted
Script:
current.assigned_to = '';
current.update(); // Use update so record isn't considered "submitted"
action.setRedirectURL(current); // Stay on the same record after save
Submit to Assigned:
Condition:
(current.assigned_to != null || !gs.nil(current.assigned_to)) && current.state == 1 && !current.u_submitted
Script:
current.u_submitted = true;
if (current.isNewRecord()) {
current.insert();
} else {
current.update();
}
action.setRedirectURL(current);
And for the global Ui action I did not delete or remove but added in one condition which is to exclude the sn_risk_advanced_event table only which is this condition:
current.getTableName() != 'sn_risk_advanced_event'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-08-2025 11:57 PM
simply override those 2 buttons by changing the table to your table and click Insert and Stay on Right Click -> Form Header
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-08-2025 11:59 PM
Hello @ChuanYanF
I don't think you should modify this global submit update and save buttons - they are used at way tooo large scale and modifying them can have cascading effect.
Instead create custom button and add appropriate conditions.
Can you break down precisely - when do you want submit button - from when till when ?
And when do you want update button - from when till when ?
Kindly mark my answer as helpful and accept solution if it helped you in anyway. This will help me be recognized for the efforts and also move this questions from unsolved to solved bucket.
Regards,
Shivalika
My LinkedIn - https://www.linkedin.com/in/shivalika-gupta-540346194
My youtube - https://youtube.com/playlist?list=PLsHuNzTdkE5Cn4PyS7HdV0Vg8JsfdgQlA&si=0WynLcOwNeEISQCY
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-09-2025 12:05 AM
Thks for the clarification Shivalika, so to break it down more granularly as you can see the screenshot here is how the risk event form initially looks like when users are creating a new risk event record.
So instead of just the Submit button, I wish to add in another button called Save as Draft button next to the Submit button. Currently the risk event form will autopopulate the assigned_to field based on the opened_by user's manager. So the function of the Save as Draft button should be erasing the assigned_to field values and saves the risk event record to not assigned the risk event to anyone, whereas the Submit button will work normally to submit the risk event form as well as making sure the assigned_to field has values inside it and submit the risk event form and assigned to destinate owners. So this two button will appear until the event is successfully assigned to a user, both Save as Draft and Submit button.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-09-2025 12:16 AM
Okehh @ChuanYanF
Got it !! So just one more save as draft button is required and it will be visible when record is new. And Submit button will just make sure that assigned to is not empty.
So here, create a new Save as Draft button and for Submit button just do "Insert and stay" and apart from that add another condition that assigned to is not empty.
in the save as draft , just create in the table uo action as usual - check the form button, client checked and function on client side below 👇
function onClick() {
g_form.setValue('assigned_to', '');
g_form.save();
}
Now for the submit button just add another condition, if(g_form.getValue('assigned_to')=='')
{//g_form.addErrormessage();
return; //IMPortant so that nothing saves. }
Please make these modifications and share screenshot of stuck.
Kindly mark my answer as helpful and accept solution if it helped you in anyway. This will help me be recognized for the efforts and also move this questions from unsolved to solved bucket.
Regards,
Shivalika
My LinkedIn - https://www.linkedin.com/in/shivalika-gupta-540346194
My youtube - https://youtube.com/playlist?list=PLsHuNzTdkE5Cn4PyS7HdV0Vg8JsfdgQlA&si=0WynLcOwNeEISQCY