- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-13-2024 05:23 AM
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:
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-13-2024 05:52 AM
Hello @GBS ,
You can write the script like below.
current.u_opened=gs.nowDateTime();
Please refer the below links as well.
https://www.servicenow.com/community/developer-forum/how-to-set-current-date-and-time/m-p/2223464
Please mark my answer as correct and helpful if it helps you.
Regards,
Namrata
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-13-2024 06:33 AM - edited 06-13-2024 06:34 AM
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