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

asifnoor
Kilo Patron

Hi

In the transform map, set this option "Enforce Mandatory fields" to "All fields". If any fields are not filled then transform will not happen for that record.

Mark the comment as a correct answer and also helpful if this solves the problem.

Hello SK

Did you check this thread? If you go to import log you can find the list of skipped records.

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

Thanks ankur that helps. 

One question here is  if i need to print some kind of message here that the "field is mandatory please provide value" can i do that instead of just ignore?

Is it technically feasible to send the sender a message or some information that mandatory fields are blank instead of just ignoring it in the script?

 

Thanks!