Can we use GlideRecord in UI action Script ?

Tapish Sharma
Tera Contributor

Hi Everyone,

Can we use Glide record in UI action script ?I could see some recommendations that Client side script should not use Glide record . Is UI action client script if we have not checked the client check box ??

1 ACCEPTED SOLUTION

Harsh Vardhan
Giga Patron

yes you can use glide record in server side of ui action script. 

Please have a look on below blog. it has mentioned an example.

 

Client & Server Code in One UI Action

View solution in original post

4 REPLIES 4

Harsh Vardhan
Giga Patron

yes you can use glide record in server side of ui action script. 

Please have a look on below blog. it has mentioned an example.

 

Client & Server Code in One UI Action

Harsh Vardhan
Giga Patron

If you have a scenario and only want to perform the glide record part in client side script, you can also consider the GlideAjax, here you will do all the glide record script part in client callable script include and then call it on your UI Action client side script by using Glide Ajax. 

Please check the details about Glide Ajax on link below. 

 

https://docs.servicenow.com/bundle/geneva-servicenow-platform/page/script/server_scripting/reference...

 

 

Hi harshvardhan,

Thanks for your response, Here is my script 

 

var newIncident = new GlideRecord('sn_hr_core_case');
newIncident.initialize();
newIncident.subject_person = current.subject_person;
newIncident.opened_for = current.opened_for;
newIncident.hr_service = current.hr_service;
newIncident.short_description = current.short_description;
newIncident.assignment_group = current.assignment_group;
newIncident.priority = current.priority;
newIncident.parent = current.parent;
newIncident.description = current.description;
newIncident.u_case_type = current.u_case_type;
newIncident.insert();

gs.addInfoMessage('New Case ' + newIncident.number + ' created.');
action.setRedirectURL(newIncident);
action.setReturnURL(current);

You can use this script on your UI Action. UI Action execute bother client and server side script. So you will not check "client" check box as true and just paste the script in your UI action, it will work. 

Please check my first response, that blog will give you much more clear understanding about UI Action.