- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā08-31-2020 03:34 AM
Hi all,
we created web-service through import set API ,but while giving the wrong data values like Impact:ABC and urgency:XYZ in json as show below ,Still the data is inserting .
Please help me to validate data before inserting record
{
"u_description":"test",
"u_short_description":"test",
"u_urgency":"XYZ", //instead 1-High
"u_impact":"ABC", ////instead 1-High
}
Solved! Go to Solution.
- Labels:
-
Integrations
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā08-31-2020 04:05 AM
Hi Kiran,
So you can handle this using onBefore transform script for that import set web service
sample script below
(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {
// Add your code here
var urgencyArray = ['1-High','2 - Medium','3 - Low'];
var impactArray = ['1-High','2 - Medium','3 - Low'];
var arrayUtil = new global.ArrayUtil();
var incomingUrgencyValue = source.u_urgency;
var incomingImpactValue = source.u_impact;
if(!arrayUtil.contains(urgencyArray,incomingUrgencyValue)){
ignore = true;
status_message= 'Urgency value is not valid';
}
if(!arrayUtil.contains(impactArray,incomingImpactValue)){
ignore = true;
status_message= 'Impact value is not valid';
}
})(source, map, log, target);
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
ā08-31-2020 03:39 AM
Hi Kiran,
Are you saying you want to validate if the values are valid during the import set load?
if yes then you will have to write onBefore transform script
please explain in details what and how the setup is currently?
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
ā08-31-2020 03:47 AM
In my current setup, created web-service through import set API and created source table and map the fields with Mapping Assist(source fields are mapped to target fields),So when we receive the Json ,Import set API will automatically map and create incident ticket .
So now we want to validate the Json data and values are valid or not ,before moving to import set
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā08-31-2020 04:05 AM
Hi Kiran,
So you can handle this using onBefore transform script for that import set web service
sample script below
(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {
// Add your code here
var urgencyArray = ['1-High','2 - Medium','3 - Low'];
var impactArray = ['1-High','2 - Medium','3 - Low'];
var arrayUtil = new global.ArrayUtil();
var incomingUrgencyValue = source.u_urgency;
var incomingImpactValue = source.u_impact;
if(!arrayUtil.contains(urgencyArray,incomingUrgencyValue)){
ignore = true;
status_message= 'Urgency value is not valid';
}
if(!arrayUtil.contains(impactArray,incomingImpactValue)){
ignore = true;
status_message= 'Impact value is not valid';
}
})(source, map, log, target);
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
ā08-31-2020 04:29 AM
thanks you soo much this is what we are looking for ,but we have 100 of values to validate like group value contains 100 values we cant hard code values her ,So any dynamic way to validate ?