Transform Script - Updating values on second run
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-07-2023 07:01 AM
hi
have a transform script that updates a value on a True/False field on customer project table.
so import set has a column has is delayed (Y/N) and based on that the Has Issue value on customer project table is updated.
so it goes like :
var flag;
if (source.isDelayed =='Y')
flag = true; (or flag='true';)
else
flag = false ;
return flag;
have played with quotes, placing the script inside loop etc. everytime i rerun the import, for change of the is delayed column, the table value is not updated 1st time but same File i Load , import and transform second time, the values are updated correct..
any one faced such an issue before??
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2023 11:02 AM
It's difficult to debug the root cause without seeing it, my suggestion, if you are using same excel data sheet, change it and prepare new one then try again.
Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2023 11:09 AM
ya did that too..
Just in case someone wants to try in pdi..
Table: customer project
field: Has Issue
Excel sheet : a Column with Y/N values
field mapping: Excel column to Has issue
script:
so it goes like :
var flag;
if (source.isDelayed =='Y')
flag = true; (or flag='true';)
else
flag = false ;
return flag;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2023 11:20 AM
Hi, unfortunately the details in your post do not make your issue or configuration clear.
If your script is a Field Map script running on 'isDelayed' field? then you would need to return the same data type as the source Field, IE the field the script is running against\the field value you are replacing;
Which (based on your example) is a string - IE standard field data type for temp import tables.
If your script is a beforeTransform script, then you need to map the result of your script to a field on the target table, with the result matching the target field data type; eg for a true\false target field.
var flag = false;
if (source.isDelayed == 'Y') {
flag = true; }
target.targetFieldName = flag;
Perhaps you could update this thread with clear and specific details of your issue\configuration, so that the community is in a better position to understand and assist?
- attaching your script via xml file extract is the best way to share this type of detail.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2023 12:12 PM
So we cannot have in our import excel a field type like true/False ..but we need to map that anyways..similar for choice field.. like eg: Risk is of type string in customer project table but actually a choice fieldin Servicenow.. but the excel would have string. so you mean to say we cannot map them cos of the Difference in target ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2023 12:31 PM
Hi, there is no reason why you cannot map a Y/N string (or any string) to a bool true/false field via transform; but without clear details of your configuration and how you are trying to script your update the community cannot evaluate your issue properly.
As indicated in my previous post, can you update this thread with clear and specific details of your issue\configuration, so that the community is in a better position to understand and assist? Attaching your script via xml file extract is the best way to share this type of detail.