prevent update of a field in transform map
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-06-2020 10:10 PM
I have a field "Name" in a CMDB table. This table data is updated through a data source via transform map.
I have a requirement to prevent update of Name through data source when it is manually updated by CMDB admin.
I have written the below logic in OnBefore transform map:
(function runTransformScript(source, map, log, target) {
var grAcc=new GlideRecord('cmdb_ci_computer');
grAcc.addQuery('name','DOES NOT CONTAIN',source.u_name);
grAcc.query();
if(grAcc.next())
ignore=true;
})(source, map, log, target);
With this, not only 'Name' but entire record update is getting skipped, pls let me know how to prevent the update only for "Name" field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-06-2020 11:58 PM
So in the example, incoming source is IBM-001 and target record's name is updated with IBM-001_HW_Asset, so when I query in the script with one unique identifier and name does not contain source, we get this CI, Here the transform script is ignoring the entire record update, it should just ignore the update of 'Name' attribute. How can i achieve this?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-07-2020 12:08 AM
Do you have name as unique identifier in your CI class?
Why it will update IBM-001_HW_Asset when source is IBM-001?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-07-2020 12:28 AM
Hi,
So you are saying if the incoming name is present even as sub-string in the target name field it should not override this value but continue updating other field values
if yes then you can have onBefore transform script for handling this and remove the field map for the name field
var incomingValue = source.u_name;
var targetName = target.name;
if(targetName.indexOf(incomingValue) >=0){
// found sub-string don't do anything
}
else{
// not found then allow update for name as well by setting the value as below
// if you don't want to do this then don't add else part itself
target.name = incomingValue;
}
Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader