How to retrieve the sys id
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-09-2024 12:42 AM
I have created two records producer. First one should create the case and second one should not create. I need to retrieve the sys id of the case and check the variable "yes or no" from the second record producer and based on these answer it should update the existing case created by the first record producer.
How to write the script for it. Pls help here

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-09-2024 01:16 AM - edited ‎07-09-2024 01:17 AM
Hi @PRAGHATIESH S ,
I tried your problem in my PDI and it works for me please add the script in script section of Record producer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-09-2024 01:24 AM
Hi @Community Alums
Thanks for the reply. I need to retrieve sys id of existing case created by first record producer and check few conditions on second record producer variable. Then finally need to update the existing case state using second record producer script.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-09-2024 01:37 AM
You can add one flag in your target table like fromFirstRecordProducer, and when you hit 1st RP you can make that flag true from script, and in 2nd RP you can add below script
var gr = new GlideRecord('incident');
gr.addQuery('active', true);
gr.addQuery('u_fromFirstRecordProduer', true); // Flag that you created and set true in 1st Record Producer
gr.orderByDesc(); // gives the 1st record from FirstRecord Producer
gr.setLimit(1); .. gived only 1 record
if(gr.next()){
var id = gr.sys_id;
}
Please mark my answer correct and helpful if this works for you
Thanks and Regards
Sarthak