- 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 05:07 AM
So what did you start with and where are you stuck?
you should use client side + server side UI action
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 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 05:18 AM
Hi @Ankur Bawiskar,
I'm curious.
Why wouldn't you just do this client side? For performance reasons?
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 05:24 AM
I have seen few cases in the past where ServiceNow flags this in instance scan and suggests not to use GlideRecord in client side script.
Also seen some cases where ServiceNow recommends not using GlideRecord in client side script in scoped app.
There is no documentation for this which I could locate but it's based on my past experience with ServiceNow guys.
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 05:27 AM - edited 11-02-2023 05:28 AM
Thanks @Ankur Bawiskar
I've never had issues with it (although rarely used). Hence my question. 🙂 As long as you think about how you use it (and with moderation), it seems fine for me to do sometimes.
I agree, using the combo of client & server side in UI Action seems better, but also harder to understand for newcomers.
Help others to find a correct solution by marking the appropriate response as accepted solution and helpful.