- 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 05:40 AM
I believe you will have to do it for every incoming value separately.
Please check this question also. I believe this is answered. Please mark appropriate response as correct and helpful.
how to insert attachment(inbound) for incident using attachment API
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
ā09-01-2020 07:01 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā09-01-2020 08:05 AM
Hi Kiran,
you can use system property to hold the values you want to validate against
Example:
property will hold comma separated 80 values of group names
then you can validate as below
(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {
// Add your code here
var groupValues = gs.getProperty('group_names').toString();
var incomingGroupName = source.u_group_name;
var arr = groupValues.split(',');
var arrayUtil = new global.ArrayUtil();
if(!arrayUtil.contains(arr,incomingGroupName)){
ignore = true;
status_message= 'Group name is not valid';
}
})(source, map, log, target);
Regards
Ankur
Ankur
⨠Certified Technical Architect || ⨠9x ServiceNow MVP || ⨠ServiceNow Community Leader