UI Action Via Scripts

NirajM
Tera Expert

UI Action  : Create Button and write as script below code . there are four below scenario explain each scenario with scripting. 

  1. Create one Button the incident form to create a new problem record and copy the short description and description and other field from incident to the problem table.
  2. Work-In Progress button won’t be visible when the ticket is about to be created. After creation of a record, the button should be visible
  3. There should be a button on incident form. When user click the button, system should update priority of incident to P1 and do not save the record.
  4. There should be a button on problem record to create 2 problem tasks automatically associated with the same problem.

Please Advise. 

1 ACCEPTED SOLUTION

@NirajM 

1. Write below code in UI action

var problemGr = new GlideRecord("problem");
problemGr.initialize();
problemGr.short_description = current.short_description.toString();
problemGr.description = current.description.toString();
//Set all other required fields as short description and description set above
problemGr.insert();

 

2. Un check the "Show insert" check box to not show the "Work in Progress" button when the ticket is about to create

jaheerhattiwale_0-1670472683885.png

 

 

Please mark as correct answer if this solves your issue.

Please mark the answer as correct or helpful based on impact
ServiceNow Community Rising Star, Class of 2023

View solution in original post

3 REPLIES 3

Mike_R
Kilo Patron
Kilo Patron

These are pretty straight forward but please post what you attempted/tried and we will try to help you out.

I attempted all the questions use cases, I resolved 3rd and 4th , Not able solve output for question number 1 and 2. 

@NirajM 

1. Write below code in UI action

var problemGr = new GlideRecord("problem");
problemGr.initialize();
problemGr.short_description = current.short_description.toString();
problemGr.description = current.description.toString();
//Set all other required fields as short description and description set above
problemGr.insert();

 

2. Un check the "Show insert" check box to not show the "Work in Progress" button when the ticket is about to create

jaheerhattiwale_0-1670472683885.png

 

 

Please mark as correct answer if this solves your issue.

Please mark the answer as correct or helpful based on impact
ServiceNow Community Rising Star, Class of 2023