Need to get the Sys ID of the inserted record from onBefore transform Script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2025 06:14 AM
Before inserting, the source fields are populating in target record but since the need of the running business rules the fields on the form (Status and lifecycle) are auto setting. Hence trying to get the SysID of the inserted record in Onbefore transform script and need to use that in OnAfter script to overwrite the Status and lifecycle with the Source file fields. But no luck.
Here is the script
Inserting the record if number(coalesce ) field is empty
OnBefore
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2025 08:39 AM
Hello @SAS21
It's recommended to put direct values to avoid any confusion.
Kindly mark my answer as helpful and accept solution if it helped you in anyway. This will help me be recognized for the efforts and also move this questions from unsolved to solved bucket.
Regards,
Shivalika
My LinkedIn - https://www.linkedin.com/in/shivalika-gupta-540346194
My youtube - https://youtube.com/playlist?list=PLsHuNzTdkE5Cn4PyS7HdV0Vg8JsfdgQlA&si=0WynLcOwNeEISQCY
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2025 08:24 AM
Hello @SAS21
If you do the direct assignment as I told in the message above, make sure to use gr.update();
Kindly mark my answer as helpful and accept solution if it helped you in anyway. This will help me be recognized for the efforts and also move this questions from unsolved to solved bucket.
Regards,
Shivalika
My LinkedIn - https://www.linkedin.com/in/shivalika-gupta-540346194
My youtube - https://youtube.com/playlist?list=PLsHuNzTdkE5Cn4PyS7HdV0Vg8JsfdgQlA&si=0WynLcOwNeEISQCY
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2025 08:26 AM
@Shivalika and i noticed two records are inserting may be due to var newSysId = gr.insert();?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2025 08:32 AM
Hello @SAS21
Okeh so now insert is happening. Yes, that's because of gr.insert.
But how will you get the sys_id in On Before. in that case, in OnAfter write another line if(action=='insert) ignore =true; because you have already inserted the record. Write this in another OnAfter script not the same one. But make the order of it to execute before this one. For example make this order as 50. And your CURRENT ON AFTER (the one discussed) as 100.
Kindly mark my answer as helpful and accept solution if it helped you in anyway. This will help me be recognized for the efforts and also move this questions from unsolved to solved bucket.
Regards,
Shivalika
My LinkedIn - https://www.linkedin.com/in/shivalika-gupta-540346194
My youtube - https://youtube.com/playlist?list=PLsHuNzTdkE5Cn4PyS7HdV0Vg8JsfdgQlA&si=0WynLcOwNeEISQCY
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2025 08:47 AM
@Shivalika after this total i see 3 records like below. two with the same number and one wih a new one. when i printed newSysID - its empty
CGCSEM0066995
CGCSEM0066995
CGCSEM0066996