Creating CI's and relationships via workflows.

ajuriol
Kilo Contributor

Hi Everyone.

 

We would like to be able to create CI's for example a server and relationships like applications during the processing of a requested item. So typically information would be collected by various teams using various catalog tasks within the workflow. At some point in the workflow we would then commit everything to the CMDB.


If anyone has done something like this and would be kind enough to share their ideas / experiences / script examples that would be greatly appreciated.

 

Many Thanks

Alberto

5 REPLIES 5

NBeheydt
Tera Expert

We are looking to do the same thing.   Were you able to come up with a solution?



Thanks


I am also trying to do this Nancy - did you manage to get it working?


No, this is something that is still on our 'to do' list.


akash_mehta
ServiceNow Employee
ServiceNow Employee

Alberto:   I have done something like this in a workflow for a new Business Application with a relationship to a Business Service



1)   Create a Maintain Item record with an associated Workflow


2)   Created some variables (Publisher, Application Name, Version, Business Service, Business Owner)


3)   I have a workflow that has a Business approval, Technical Approval, and a Technical SME Review (task)


4)   After all of that is done I run the following script to create the Business Application and relationship to Business Service:



//create the business application


  var grBA = new GlideRecord("u_cmdb_ci_business_appl");


  grBA.initialize();


  grBA.name = current.variables.name;


  grBA.version = current.variables.version;


  grBA.manufacturer = current.variables.publisher;


  grBA.operational_status = 2;


  grBA.owned_by = current.variables.owner;


  grBA.assigned_to = current.variables.assigned_to;


  grBA.insert();




//make relationship to business service


if(!current.variables.service.nil()){


  var grREL = new GlideRecord('cmdb_rel_ci');


  grREL.initialize();


  grREL.parent = current.variables.service;


  grREL.child = grBA.sys_id;


  grREL.type.setDisplayValue("Depends on::Used by");


  grREL.insert();


}




You could do something similar using the above...



Hope that helps.



-Akash