- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2024 06:41 PM
My purpose is to copy an existing record and display a new record form using the UI action "Record Copy" created with a client-side script.
「g_navigation.open(table_name + '?sys_id=-1&sysparm_view=viewname');」
I want to get the display value of an existing record using "g_form.getEditableFields();" and set it in a new record.
I thought it would be possible to set the field value with "sysparm_query=" in the setting value of "g_navigation.open", but it doesn't work.
Can I copy the value of an existing field to a new record using a URL?
I think record copying can be done easily using a server-side script, but I would like to use client-side ``g_navigation.open'' to implement record copying with required fields left blank.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2024 06:56 PM
Hi @bonsai
you were on the right path: "sysparm_query" parameter has to be leveraged for prefilling fields with values. If you want to see this in action you can go to the list view of any table (in my example "incident") and lookup any values. In the below example I filter for a certain caller:
Then click on the "New" button and examine the resulting URL. In the form view of a new record you will see that the caller field is prepopulated the previous filter:
Maik

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2024 07:03 PM - edited 01-09-2024 07:07 PM
Hi @bonsai here is the example through UI Action client callable. It creates a new record on change request table
function redirectToChg(){
var desc = g_form.getValue('description'); //RITM desc
var sd = g_form.getValue('short_description'); //RITM short desc
//Base URL for creating a new CHG record and to map fields via 'sysparm_query' parameter
var url = '/change_request.do?sys_id=-1&sysparm_query=';
//Query parameter to map fields on CHG form.
var urlParams = 'description=' + encodeURIComponent(desc) + '^short_description=' + encodeURIComponent(sd);
//Open CHG in new window
g_navigation.open(url + urlParams, '_blank');
}
Make sure your onclick value matches the function name
Harish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2024 06:56 PM
Hi @bonsai
you were on the right path: "sysparm_query" parameter has to be leveraged for prefilling fields with values. If you want to see this in action you can go to the list view of any table (in my example "incident") and lookup any values. In the below example I filter for a certain caller:
Then click on the "New" button and examine the resulting URL. In the form view of a new record you will see that the caller field is prepopulated the previous filter:
Maik

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2024 07:03 PM - edited 01-09-2024 07:07 PM
Hi @bonsai here is the example through UI Action client callable. It creates a new record on change request table
function redirectToChg(){
var desc = g_form.getValue('description'); //RITM desc
var sd = g_form.getValue('short_description'); //RITM short desc
//Base URL for creating a new CHG record and to map fields via 'sysparm_query' parameter
var url = '/change_request.do?sys_id=-1&sysparm_query=';
//Query parameter to map fields on CHG form.
var urlParams = 'description=' + encodeURIComponent(desc) + '^short_description=' + encodeURIComponent(sd);
//Open CHG in new window
g_navigation.open(url + urlParams, '_blank');
}
Make sure your onclick value matches the function name
Harish