- 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 03:32 AM
Hello all,
Can anyone help in this ?
Many thanks in advance!!
Regards,
Mahak

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-02-2020 03:46 AM
Hello Mahak.
As per my knowledge ignore=false,not any value and did not work,as per my knowledge
Try the below one.
(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {
if(action == "update" && source.u_bios_serialnumber == target.serial_number && target.discovery_source != "ABC Integration");//you forget ; here
{
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');//you forget ; here also
{
ignore = false;// if this condition statisfied then the record will not be ignored.
}
else
{
ignore = true;
}
})(source, map, log, target);
I checked you forget Semicolon(;)in your script
Please check,it may the reason of not worling.
Regards
Yash Agarwal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-02-2020 04:30 AM
Hello Yash,
The above script is working there was no issue in that but now as i have mentioned i need to update the the empty fields of exiting records also which are not created through this integration ,so i want to add that logic in this.
(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")
{
if(target.os_service_pack =='')// if field of target record is empty
{
target.os_service_pack = source.u_service_pack;
}
if(target.ip_address =='')
{
target.ip_address = source.u_ip_addr1;
}
if(target.os_domain =='')
{
target.os_domain = source.u_computer_domain_name;
}
else
{
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')
{
ignore = false;
}
else
{
ignore = true;
}
})(source, map, log, target);
But what is happening through the extra code is it is updating all the fields of the target record which are not created through this integration .
I want for ex if any record or ci has field let say service pack empty and in our source table that CI is there so only the value of service pack from source table to copied to target service pack field and not all the fields.
In this i need help'.
Regards,
Mahak

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-02-2020 04:50 AM
Hello Mahak
What i understand is if the source field is empty then that empty value should not move to the target table field.
If the source field has value then only it should move to the target field.
If so then here is the code.
(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {
// Add your code here
if(action == "update" && source.u_bios_serialnumber!='' &&source.u_bios_serialnumber == target.serial_number && target.discovery_source != "ABC Integration")
{
if(source.os_service_pack !='' && target.os_service_pack =='')// if field of target record is empty
{
target.os_service_pack = source.u_service_pack;
}
else if(source.ip_address !=''&& target.ip_address =='')
{
target.ip_address = source.u_ip_addr1;
}
else if(source.os_domain !=''&&target.os_domain =='')
{
target.os_domain = source.u_computer_domain_name;
}
}//added
else
{
ignore=true;
}
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')
{
ignore = false;
}
else
{
ignore = true;
}
})(source, map, log, target);
Please try the above one, Before moving the data,I Checked that value is available in the source field or not
Please keep posted
Regards
Yash Agrawal