Assignment Related to Business Rule

Shubham Rai
Tera Contributor
  • Create a table called ‘incident_temp’ with below two fields
    Incident Number
    Short Description
  • Create a business rule, this should execute only whenever any new incident created on ‘Incident’ table
  • Create a new record in ‘incident_temp’ table from above newly created Incident record and set Incident Number and short description values and save the record in ‘incident_temp’ table

Please, help me with 2nd point

1 ACCEPTED SOLUTION

Hi,

script looks ok

I hope BR is after insert on incident table

are you sure the table name is incident_temp or it is u_incident_temp

(function executeRule(current, previous /*null when async*/) {

var rec = new GlideRecord('u_incident_temp');
rec.initialize();
rec.u_number = current.number; // field name is correct?
rec.u_string_1= current.short_description; // field name is correct?
rec.insert();

})(current, previous);

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

8 REPLIES 8

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

Seems to be some exercise for your study

So what script did you start and where are you stuck?

Unless you start how would you learn?

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hii Ankur,

I have created table and fields.

but,i'm not getting what exactly i have to do in 2nd point.

Regards,

astik

Hi,

create after insert BR on incident table and then use GlideRecord to insert data into incident_temp table

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hii Ankur,

I have write this script but it is not working

(function executeRule(current, previous /*null when async*/) {

var rec = new GlideRecord('incident_temp');
rec.initialize();
rec.u_number = current.number;
rec.u_string_1= current.short_description;
rec.insert();

})(current, previous);

 

Please,help me with this