- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-01-2024 12:07 PM
I'm importing some department data and there is a custom field called Active. It is a checkbox. The data coming from the source shows either Active or Inactive. If the status is Active, I need the custom field to be checked. If it is Inactive, I need it to be unchecked. I've created an onAfter transform script but it isn't setting the value after the import. Here's the script I'm using:
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-01-2024 02:28 PM
Hey @KeithM1
Is there any particular reason you are doing this in an onAfter instead of just in a field map? It might be more straight forward to do it that way. Setup a field mapping for the field u_active, check the box for "Use source script", then plug in your script with slight modification:
if (source.u_status == "Active"){
gs.info("Source status: " + source.u_status);
return true;
} else if (source.u_status == "Inactive"){
gs.info("Source status: " + source.u_status);
return false
}
Hope this helps!
~Nick
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-01-2024 02:43 PM
I hadn't thought about doing it that way. It worked perfect. Thank you!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-01-2024 02:06 PM
Hi @KeithM1
Replace target.u_active = "true"; with target.u_active = true; (and similarly for "false" to false). This ensures that you are assigning a boolean value instead of a string.
Thank you
Rajesh