Delay of Transform Map
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-05-2024 03:46 PM
Hello Everyone,
I am trying to execute a data source which has two transform maps to two different target tables. I am having trouble querying data against the first target table within my second transform map. Below is my scenario where I try to insert data to two tables but failing to query
Table 1 has two fields Contract and PO Number
Table 2 has three fields PO Line Item Number, PO Number and Contract(reference to Table 1)
There is already a before insert/update business rule which runs on Table 2 that queries for PO Number on Table 1 and if it matches with PO Number of Table 2, sets that specific Contract as a parent.
My issue with transform maps is, when data is inserted on the Table 1, the second transform map runs instantly without finding the PO Number match on the newly inserted data from Table 1 and setting the Contract reference as empty. I tried RunScript activity on second transform map(similar to the existing business rule) but cannot update the Contract as two transform maps run at once. How do I work on setting this field correctly so it links to Table 1?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-05-2024 03:51 PM
I had a similar situation where I was doing a transform field mapping that was scripted to get the target sys_id - it was inconsistently getting that value when running. I moved it into an onAfter script on the transform map and that worked to resolve the issue.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-05-2024 04:47 PM
Hi @RK29 ,
To handle the delay in the transform map and ensure that the second transform map correctly queries data from the first target table, please use onAfter script in the second transform map.
Write a onAfter script that waits for the data in Table 1 to be committed before performing the lookup for the PO Number.
Try using
gs.sleep(1000); // Delay for 1 second
Over all script should look like-
(function onAfter(source, target, map, log, isUpdate) {
gs.sleep(1000); // Delay for 1 second, adjust based on your execution
// Your update script
})(source, target, map, log, isUpdate);
If my response has resolved your query, please consider giving it a thumbs up and marking it as the correct answer!
Thanks & Regards,
Sanjay Kumar