- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-07-2020 11:25 PM
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.
Solved! Go to Solution.
- Labels:
-
Integrations
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-07-2020 11:54 PM
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
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-07-2020 11:51 PM
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.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-08-2020 05:17 AM
Hello SK
Did you check this thread? If you go to import log you can find the list of skipped records.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-07-2020 11:54 PM
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
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-08-2020 04:45 AM
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!