- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-02-2023 02:07 AM - edited 11-02-2023 02:10 AM
Hi All,
I have a requirement to create button on a custom table. Whenever the user clicks on the button, it should open a pop up saying ‘Do you want to proceed?’ with Ok and Cancel button.
When the user clicks on Ok button, it should insert a new record and redirect to the new record form copying the fields values of previous record. Fields like number and additional comments should be copied in the new record from previous record.
When the user clicks on Cancel button, it should abort the action and close the pop up.
Could some one help me to achieve this requirement?
Any help is appreciated.
Thanks in advance.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-02-2023 05:15 AM
I won't recommend using GlideRecord into client side
so try something like this
function myAction()
{
if(confirm("Do you want to proceed?")==true){
gsftSubmit(null, g_form.getFormElement(), "Action name")
}
}
if(typeof window == 'undefined')
createReq();
function createReq() {
var gr = new GlideRecord('custom_table_name');
gr.initialize();
gr.newRecord();
gr.number = current.number;
gr.comments=current.comments;
var newID = gr.insert();
action.setRedirectURL(gr);
action.setReturnURL(current);
}
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
11-02-2023 02:19 AM
You want to use a "Glide modal"
https://developer.servicenow.com/dev.do#!/reference/api/vancouver/client/c_GlideModalV3API#r_GMODV3-...
Example given here
http://www.cloudminus89.com/2021/02/glidemodal-reference-popup-message-in.html
On the confirm you want to use a GlideAjax to copy the current record to the new record. g_form.getUniqueValue()
https://developer.servicenow.com/dev.do#!/reference/api/vancouver/client/c_GlideAjaxAPI
After your done you can redirect the user to the new record:
https://www.servicenow.com/community/developer-forum/ui-action-client-side-redirect/m-p/1382333

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-02-2023 02:20 AM
Hi @Rose17,
You could use this UI Action as an example: https://instance.service-now.com/nav_to.do?uri=sys_ui_action.do?sys_id=f7d268d50a0a0a6f00cebef55b5d3...
Only thing missing here is the popup which can be implemented as (instead of the first line):
if (confirm("Are you sure") == true) {
generateKB();
}
Help others to find a correct solution by marking the appropriate response as accepted solution and helpful.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-02-2023 03:43 AM - edited 11-02-2023 03:52 AM
According to the UI action you provided, I made some modifications as per the requirement as below-

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-02-2023 04:48 AM
Hi @Rose17,
Sorry I think I set you on the wrong foot by providing a Server Side UI Action.
You could use this, and extend where needed.
function myAction() {
if (confirm("Do you want to proceed?") == true) {
createReq();
}
}
function createReq() {
var gr = new GlideRecord('custom_table_name');
gr.initialize();
gr.number = g_form.getValue('number');
gr.comments = g_form.getValue('comments');
var newID = gr.insert();
var url = '/custom_table_name.do?sys_id=' + newID;
top.window.open(url);
}
Help others to find a correct solution by marking the appropriate response as accepted solution and helpful.