Scripting to Map a Field in Transform Map
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-02-2023 08:07 AM
I have 2 fields on table build a transform map to load the data into table.
I want to map the "Service" Field using script.
Can you please help me on this:
If the Service is not empty, map each value of the Excel with the right Service to Target.
I wrote the below script which is not working
answer = (function transformEntry(source) {
if (target.u_delivery_time.nil()) {
target.u_delivery_time = source.u_delivery_time;
}
})(source);Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-05-2023 02:32 AM
@Vamsi43 Yes I think so, try it and tell me, and sorry I saw a mistake in my script, it should look like this, whitout (
(function transformRow(source, target, map, log, isUpdate) {)
you need to put only this:
if (target.u_delivery_time.nil()) {
var delivery;
var catalogItemGR = new GlidRecord("sc_cat_item");
catalogItemGR.addNullQuery('delivery_time');
catalogItemGR.query();
while (catalogItemGR.next()) {
delivery = source.delivery_time;
}
target.u_delivery_time = delivery; // return the value to be put into the target field
} else {
target.u_delivery_time = source.u_delivery_time;
}
If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.
best regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-05-2023 02:45 AM
Hello @MahaAgineo
Like Below i defined the script and Map fields.
When I Loaded the below data
It not written the Adobe Acrobat Pro catalog item "Delivery time = 2days ".
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-05-2023 02:46 AM
@Vamsi43 Upadate the script without first and last line
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-05-2023 02:55 AM
But still not working
Delivery Time on Catalog item is "Duration" type but Variable on Table is "String" field. Do you think we suppose update the script ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-05-2023 03:02 AM
@Vamsi43 Yes you need to convert String to Duration field