SCCM updates on alm_asset and cmdb_ci tables

jiral
Giga Sage

Hello,

Prior to update to Helsinki, update on the alm_asset and cmbd_ci table records are working correctly. Now as an asset/ci is retired or any values change, it reverts or re-populate fields with their previous values. It was said to be bi-directional, as what I'm told, and I was wondering where I should start in identifying the problem.

Thank you.

1 ACCEPTED SOLUTION

It appears your setAssignedTo() function checks to see if the source has a user name to assign. Using similar logic, we can add an additional if condition and not continue when the Status [install_status] is Retired:




function setAssignedTo() {


      var userName = source.u_v_gs_compute_stem_username0;


      if (JSUtil.nil(userName)) {


              return;


      }


      if (target.install_status == 7) { //retired


              return;


      }


      var x = userName.indexOf("\\");


      if (x > -1) {


              userName = userName.substring(x + 1);


      }


      target.assigned_to = GlideUser.getSysId("user_name", userName);


}



Hopefully that is the field you are using as well as the value. You may need to adjust if it is different.


View solution in original post

7 REPLIES 7

ccajohnson
Kilo Sage

My guess is that your Assets and CI mappings should be reviewed. ServiceNow has utilities that you can use:


Asset and CI management


Apologies. Forgot to state that the updates on alm_asset and cmbd_ci table tables are coming from the SCCM integration. SCCM re-populates the "Assigned to" of its previous value on a retired asset/ci. How do we stop SCCM from doing this?


Since this is an integration, you should be able to change the transform map for that field to not populate if the target record has a given state. For more information on changing the transform, see the following wiki article:


http://wiki.servicenow.com/index.php?title=Creating_New_Transform_Maps#Using_a_Script_to_Calculate_a...


Here is the transform map script that we have :



runIt();



function runIt() {


      determineClass();


      setAssignedTo();


      setCorrelationID();


}



function determineClass() {


      // Determine the class of the target CI


      if (source.u_v_gs_system_systemrole0 == "Workstation")


              target.sys_class_name = "cmdb_ci_computer";


      else


              target.sys_class_name = "cmdb_ci_win_server";


}



function setAssignedTo() {


      var userName = source.u_v_gs_compute_stem_username0;


      if (JSUtil.nil(userName))


              return;



      var x = userName.indexOf("\\");


      if (x > -1)


              userName = userName.substring(x + 1);



      target.assigned_to = GlideUser.getSysId("user_name", userName);


}



// This function fixes the fact that when transforming a integer to a string field, it includes the commas


function setCorrelationID() {


      target.correlation_id = source.u_v_gs_compute_tem_resourceid + '';


}



Where do I need to make the changes?