What is the purpose of "Post insert script" in Record Producer ? Can I use it to generate events that can be called from Notification?

josephjoechella
Tera Contributor

What is the purpose of "Post insert script" in Record Producer ? Can I use it to generate events that can be called from Notification? 

1 ACCEPTED SOLUTION

Yes, You can trigger an event based on the field value in the newly created record as well as the variables from the record producer. And all the record producer variables will be saved in the targeted table so you can directly use them from the newly created record itself. 

Please find the examples below.

let's assume you have a variable called comments in the record producer if you want to access that Producer variable you will have to simply write as below to access its value

producer.comments

now as you mentioned lets assume in the newly created record if the priority is high and description contains "urgent" you need to trigger an event. for this, you can simply use the current object which is the GlideRecord object of the newly created record. please refer to the below script 

if(current.priority == "2" && String(current.description).indexOf('urgent') >-1 ){
  gs.eventQueue('your.event.name',current,gs.getUserID().current.number)
// in above line last 2 parameters send as per your need
}

 


Please mark it as Correct/Helpful If my answer is helpful in any way,

Best regards,

Thameem

 

View solution in original post

4 REPLIES 4

Thameem Ansari
Giga Guru
Giga Guru

Hi josephjoechellasundar,

Q1: As its name suggests "Post insert script" is a Script that operates on the submitted record, after the record is inserted in the associated table. Post insert script overrides the target record values and record producer template values.

 

Q2: Yes, You can use it to generate events to trigger notifications.

Please find the below Screenshot for your reference:

find_real_file.png

Here I Did 3 things:

 

Line 1: I generated a info message to show the sys_id of the newly created record.

Line 2: I generated a event to trigger a notification of my choice. 

line 3: I have updated the description field.

 

NOTE.: Here I used current.update to update the value. because its not a business rule. here the current object is just the GlideRecord Object of the inserted record.

 

Please mark it as helpful/correct If my answer is helpful in any way,

Best regards,

Thameem

Thanks a lot Thameem for your response. Would I be able to trigger the event based on the attribute value in the created record and also the variable in the record producer ? For an example if the incident priority is high and description field in the case contains "Urgent" 

Yes, You can trigger an event based on the field value in the newly created record as well as the variables from the record producer. And all the record producer variables will be saved in the targeted table so you can directly use them from the newly created record itself. 

Please find the examples below.

let's assume you have a variable called comments in the record producer if you want to access that Producer variable you will have to simply write as below to access its value

producer.comments

now as you mentioned lets assume in the newly created record if the priority is high and description contains "urgent" you need to trigger an event. for this, you can simply use the current object which is the GlideRecord object of the newly created record. please refer to the below script 

if(current.priority == "2" && String(current.description).indexOf('urgent') >-1 ){
  gs.eventQueue('your.event.name',current,gs.getUserID().current.number)
// in above line last 2 parameters send as per your need
}

 


Please mark it as Correct/Helpful If my answer is helpful in any way,

Best regards,

Thameem

 

Thank you Thameem ! Exactly what I was looking for !