Field validation in transform map

SK41
Giga Guru

Hi, 

The other vendor is sending data of fields in excel sheet and i have to validate if the data for the mandatory fields are sent or not.  I have to validate fields before it  is mapped to our  cmdb_ci_server  table   and mapping is done through transform map.

Please let me know how can i achieve that.

Thanks in advance.

Regards.       

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

you need to use onBefore transform script for this if you want specific mandatory fields on target table to be non-empty in the import set

sample script below

(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {

	// Add your code here

	if(source.u_field1 == '' || source.u_field2 == ''){
		ignore = true;
	}

})(source, map, log, target);

if you want all then enable this checkbox of "Enforce Mandatory fields" to Only Mapped fields or All Fields

find_real_file.png

Regards
Ankur

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

View solution in original post

8 REPLIES 8

Hi,

you can include message like this

(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {

    // Add your code here

    if(source.u_field1 == '' || source.u_field2 == ''){
        error_message = 'Mandatory fields missing'; // will be shown in API response if consumed by 3rd party
        log.error("Mandatory fields missing"); // will be shown in import logs
        ignore = true;
    }

})(source, map, log, target);

Regards
Ankur

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

Thank you so much!

Welcome

Regards
Ankur

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

  • All validations & rules applied on “Request Light” table should be applied in Transformation Map and person who is uploading data should be able to see errors. Can you please help me with this use case?