- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-01-2020 06:52 AM
Hello all,
Currently there is a Integration through which we are only updating and inserting the new CI's and not updating the existing CI's which are created by discovery or manually added.
Now we have a requirement , if for the some CI's some fields are empty(which are present in the database integration) then that integration should update those fields in the Particular CI.
Below is the Onbefore Script:
(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {
// Add your code here
if(action == "update" && source.u_bios_serialnumber == target.serial_number && target.discovery_source != "ABC Integration")// for only updating the ones created by this integration
{
ignore=true;
}
else if(action == "insert" && source.u_operation_system == 'Red Hat Enterprise Linux Server' ||source.u_operation_system =='Oracle Linux Server'||source.u_operation_system == 'SUSE Linux Enterprise Server' ||source.u_operation_system == 'Linux')//Only to insert Linux Servers
{
ignore = false;
}
else
{
ignore = true;
}
})(source, map, log, target);
What changes can be made in the above script to fulfill the requirement.
Also can we use Reconciliation Rules to achieve this ?
Thanks in advance!!
Regards,
Mahak
Solved! Go to Solution.
- Labels:
-
Integrations
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-02-2020 06:26 AM
So why not move to the new IH-ETL feature so you can use the Reconciliation rules.
If you are on Orlando, you could use the new IH-ETL feature to import data via IRE, and then Reconciliation rules to add the logic of what data source that can update what CI class and attributes. You can even put in a condition to say if blank is empty then allow this source to update.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-02-2020 05:07 AM
Hello Yash,
Thank you ,but this is not working.
Because in the source table no field is empty.
Also as per my requirement ,I want if there is any field in target table which is empty then only the value of Source table field should be transformed for the existing recorded not created through this transfrom Map.
But what is happening through the above code is for the existing records even if the the field is not empty the data of that particular filed overwritten with the data in the source table,
I don't want to override the data .
I hope you understood my requirement now.
Thanks for the help.
Regards,
Mahak
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-02-2020 05:15 AM
Hi Mahak,
As per your requirement you want target table field to be updated only when the target field is not empty
Meaning if the transform map determines a record to be updated so you want only those fields to be updated which are empty so that it doesn't override the existing value
Try this for simple 1 field first
(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {
// Add your code here
if(action == "update" && source.u_bios_serialnumber == target.serial_number && target.discovery_source != "ABC Integration")// for only updating the ones created by this integration
{
ignore=true;
}
else if(action == "insert" && source.u_operation_system == 'Red Hat Enterprise Linux Server' ||source.u_operation_system =='Oracle Linux Server'||source.u_operation_system == 'SUSE Linux Enterprise Server' ||source.u_operation_system == 'Linux')//Only to insert Linux Servers
{
ignore = false;
}
else
{
ignore = true;
}
if(target.field1 == ''){
target.field1 = source.u_field1;
}
})(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
‎10-02-2020 06:22 AM
Hello Ankur,
This is also not working since above we have specified that the CI's created by other data sources other than this should be updated,that's why it is ignoring this even if a particular field is empty in the existing records,it is ignoring them.
Do we have any other option?
Thanks.
Regards,
Mahak
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-02-2020 06:26 AM
So why not move to the new IH-ETL feature so you can use the Reconciliation rules.
If you are on Orlando, you could use the new IH-ETL feature to import data via IRE, and then Reconciliation rules to add the logic of what data source that can update what CI class and attributes. You can even put in a condition to say if blank is empty then allow this source to update.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-02-2020 06:36 AM
Hello Patrick,
Is this a plugin or an app which we needs to be installed?
Or is it paid or free?
And the reason why i don't want to use it for this particular integration is because this integration is already developed ,only one last requirement which i have stated above needs to be fulfilled.
And this is an urgent integration ,so if i will use the new IH-ETL feature ,it will take time since this is a complete new thing for me.
So can you please help me in fulfilling the above requirement using Transform map and scripting only.
It would be a great help as i am now clueless how to do this.
From the next integration i will try to use the new feature for sure,thanks for providing this useful info.
Thanks you.
Regards,
Mahak