How to Retrieve Incident Field Values in Service Catalog Item Form?

Ramya834
Tera Contributor

Hello, ServiceNow community,

 

I have a requirement to match the record_no field in a catalog item with the incident table's record_no field. When a match is found, I need to update the record_charge field in the incident record to 100 INR.

I'd like to achieve this through a script. However, please note that there is no field of type reference here.

Could you please help me with a script or provide guidance on how to accomplish this in an efficient and maintainable way in ServiceNow?

1 REPLY 1

AshishKM
Kilo Patron
Kilo Patron

Hi @Ramya834 ,

If this is one time ( or on-demand ) activity then write the fix-script otherwise write the BR on SCTASK [ sc_task] table on insert for specific catalog item [ Requested Item.Item = "<Item Name">] 

 

As I understood, if the record_charge field [ on incident form ] is not empty means record_no already matched and we don't need to consider those incident record for "record_no" matching. So glide on incident table for matched record with two addQuery conditions as below.

 

var grINC = new GlideRecord("incident");
      grINC.addQuery("record_chargeISEMPTY");
      // set the record number from task using the current [object ] and dot walking
      grINC.addQuery("record_no", "From SCTASK Variables"); 
      grINC.query();

      // if expecting more than 1 matching records use the while loop else If condition
      while( grINC.next()) {
          grINC.record_charge =100; // use the "100" if field type string/char
          grINC.update();
      } 

 

 

 


Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution