- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-19-2022 04:42 AM
Hello,
I have an async business rule which splits an array from a field and creates multiple records according to array length using for loop.
This is working fine. However, records are inserted at once without any delay. I wanted these inserts to be delayed atleast by 20 seconds as there are transform maps in the background which should assess whether to push these inserted records into a target table or update it. Since, there is no delay, all are being pushed as new insert on target table causing issues in data.
How can we add delay after for loop for these record inserts to take some time?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-19-2022 07:08 AM
Since, we are adding delay in the script, there is definitely a performance issue and if this record count is in multiple of thousands then it might take hours to process.
Regarding your main concern that system is inserting record instead of updating, I don't think this issue should exist in the first place. Because, as you must be having coalesce field configured on transform map, even if we have multiple record with same coalesce field(unique id) then once first record is inserted then 2nd, 3rd record executes update operation automatically even if they are part of same import set record. So, not sure how you are facing this issue or I am completely understanding your main concern.
Let me know if you have any further queries.
Please mark this as Correct or Helpful if it helps.
Thanks and Regards,
Abhijit
Community Rising Star 2022
Regards,
Abhijit
ServiceNow MVP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-19-2022 04:53 AM
Hello,
You can use gs.sleep(20000) after gr.insert() statement so that it will wait for 20 seconds after creating each record.
Let me know if you have any further queries.
Please mark this as Correct or Helpful if it helps.
Thanks and Regards,
Abhijit
Community Rising Star 2022
Regards,
Abhijit
ServiceNow MVP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-19-2022 05:29 AM
Doesnt this cause performance issues as these array records are created in quick succession causing same business rule to run at a time in few cases.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-19-2022 07:08 AM
Since, we are adding delay in the script, there is definitely a performance issue and if this record count is in multiple of thousands then it might take hours to process.
Regarding your main concern that system is inserting record instead of updating, I don't think this issue should exist in the first place. Because, as you must be having coalesce field configured on transform map, even if we have multiple record with same coalesce field(unique id) then once first record is inserted then 2nd, 3rd record executes update operation automatically even if they are part of same import set record. So, not sure how you are facing this issue or I am completely understanding your main concern.
Let me know if you have any further queries.
Please mark this as Correct or Helpful if it helps.
Thanks and Regards,
Abhijit
Community Rising Star 2022
Regards,
Abhijit
ServiceNow MVP