Transform map script only to update(no insert) based on conditions.

suryan
Kilo Expert

Hi All, I have a transform Map in which I had made a field as Coalesce, so that only matching records gets updated when user export the excel file and updates it and then uses the transform map to update the records in the table using the exported file which he/she has updated.

My challenges are:

1)I want the transform map not to update new records that are not part of export file that he did before updating (any new additions that are not there in the table)

2)I want the transform map not to update or stop updating, when a specific field has 'no records' / blank, show the error message about it

3)I want the transform map to update the records into the table only when the record workflow status is either 'A' or 'B'. I am sure that this can be achieved by using transform script which has to run On before query, not sure, how to achieve this.

Any help and suggestion, highly appreciated.

Regards,

Surya

1 ACCEPTED SOLUTION

i checked the above code it is not throwing an error if i insert with empty field , it is not inserting but showing as updated 1 record successfully. How the user knows that it is not inserted if it does not throw a message


View solution in original post

6 REPLIES 6

Hi Suryan,



Can you add log statement to check what value the 'u_supp_validation_result' is having?



gs.log('SY Supp Validation result is:'+source.u_supp_validation_result);


if(source.u_supp_validation_result == ''){


error= true;


error_message = 'The field is blank';


}



if(action == 'insert'){


ignore = true;


}



Regards


Ankur


Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

1. uncheck run business rules - it will reduce confusion on the values while validation


2. verify the data with coalesce that you have added


3. then verify/load data the script @ankur has requested.