How to open a Glide Record in custom view with pre-filled data through UI action?

Rajat10
ServiceNow Employee
ServiceNow Employee
var newRecord = new GlideRecord(My table);
newRecord.setValue(name, current.getValue(name));
action.openGlideRecord(newRecord);
 
Above is the script code written in one of UI action button on one table..
This code is opening 'my table' in default view with pre-filled name field.
 
 I want that My table opens in custom view say 'view 1' with pre-filled name filed, when I click on UI action button.
 
Any help would be appreciated.
 
 
1 ACCEPTED SOLUTION

Sonam Tiwari
Tera Guru

@Hi @Rajat10 ,

var newRecord = new GlideRecord(My table');

//newRecord.setValue('name', current.getValue('name'));
var url = '/<your_table_name>.do?sys_id=-1' + '&sysparm_view=<your_desierd_view>' + '&sysparm_query=name=' + encodeURIComponent(current.getValue('name'));
action.setRedirectURL(url);


Can you try doing it this way. In the URL you can set the view and in sysparm_query, you should be able to set the values as before which will open with pre-filled name.

View solution in original post

2 REPLIES 2

Sonam Tiwari
Tera Guru

@Hi @Rajat10 ,

var newRecord = new GlideRecord(My table');

//newRecord.setValue('name', current.getValue('name'));
var url = '/<your_table_name>.do?sys_id=-1' + '&sysparm_view=<your_desierd_view>' + '&sysparm_query=name=' + encodeURIComponent(current.getValue('name'));
action.setRedirectURL(url);


Can you try doing it this way. In the URL you can set the view and in sysparm_query, you should be able to set the values as before which will open with pre-filled name.

Rajat10
ServiceNow Employee
ServiceNow Employee

Thanks a lot. That worked 🙂