Transform Script - Change Table Being Inserted To When Certain Conditions Are Met
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-22-2023 11:49 AM
Hello, everyone. I am importing some user data, but there is a specific requirement being given for how the transform map should behave. Specifically, when certain conditions are met, it should insert a record into a completely different table rather than the User table. The basic algorithm is like this:
if (imported record is in sys_user) {
update existing record
}
else if (certain conditions are not met) {
insert record into sys_user
}
else if (certain conditions are met) {
insert record into completely different table
}
I have seen some similar questions along these lines, but they seem to be assuming that the new table is a child of the original table. This is not the case for me - it is a completely different table.
How would I go about solving this problem?
Thank you in advance.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-22-2023 11:57 AM
Hi @Marc D ,
I recommend that you set up multiple Transform Maps, one for each table. And then setup before script to ignore when conditions are not met. That way only the Transform Map that is required will be used to update the target.
Regards,
Niklas
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-22-2023 01:33 PM
Hello, Niklas.
Thank you for the recommendation. I do have a follow-up question, however. Let's say that I have taken your advice and I have made two transform maps. The one that runs first has logic to ignore when the conditions are not met.
In this case, if the conditions WERE met, wouldn't it have both Transform Maps run? Or does the first one running prevent the second from running?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-22-2023 09:55 PM
Hello again,
You need to have conditions on each Transform Map so that only one runs.
Let's say you have a value that can be either A or B. Depending on the value you want to update Table 1 or Table 2. Then you have two transform maps.
Transform Map 1 ignores if value is A. Transform Map 2 ignores if value is B.
Regards,
Niklas