Record producer Opened field

GBS
Tera Contributor

I have created a Record producer and used the below script to populate the field values except for the Opened field, the opened field has to be updated with the created on date. 

 

Script:

(function() {
   
    // Set the values to the incident fields
    current.u_opened_by = producer.requested_by;
    current.u_requested_for = producer.requested_for;
    current.u_assignment_group = '5a5c5e849312021029427e8efaba1041'; //group sys_id
    current.u_contact_type = "Self Service";
    current.u_item = '3a25637b47701100ba13a5554ee490a0';

    var createdOn = new GlideDateTime(current.sys_created_on.getDisplayValue());
    current.u_opened = createdOn.getDisplayValue();
    //current.u_opened = current.sys_created_on;
   
    current.u_state = 1;
    current.u_priority = 4;
 

})();

 

GBSaiKiran_0-1718281320673.png

 

1 ACCEPTED SOLUTION
5 REPLIES 5

Robbie
Kilo Patron
Kilo Patron

Hi @GBS,

 

An important thing to note with Record Producers (RP) is to note that the RP Script is executed BEFORE the record is generated.

 

Whilst you can tweak the script and leverage the gs.nowGlideDateTime() method within your script as per @Dnyaneshwaree has mentioned, 9 times out of 10 this could and should match the sys_created_on date, however there could be a slight delay between submission of the RP and the creation of the record so you may want to consider handling this as an onAfter insert business rule and copy the sys_created_date to the u_opened field AFTER the record has been created to guarantee the DateTime fields match.

 

To help others (or for me to help you more directly), please mark this response correct by clicking on Accept as Solution and/or Kudos.


Thanks, Robbie