Scripted way to set relation between Application service - BA

SGanguly
Tera Contributor

Hi

I am currently working on a greenfield deployment of CSDM. What I observed is I can not define an Application/Technical service without mapping technical and business service offerings. Our stakeholders are yet to come back with their respective offerings and customer is expecting to see Business Applications are mapped with the applications as proof of value initiation. There are around 450 applications which need to be covered using CSDM. 

Is there any scripted way to skip mapping the offerings and set up the relationships between technical/application services with Business Application? I tried to write the following lines in the main script for the same, but it did not help. Any help will be much appreciated.

//Creates an application service with the same name of the application
			var appSvc = new GlideRecord('cmdb_ci_service_auto');
				appSvc.initialize();
				appSvc.name = appName; //Say appName is fed by an array of application names here.
				appSvc.service_classification = "Application Service";
				var appSvcSysID = appSvc.insert(); //Collects the sys_id of the newly created Application Service.

// Creates the relationships between different entries.				
			var relation = new GlideRecord('cmdb_rel_ci');
//Creates new relationship between new Business Application and new Application Service
				relation.initialize();
				relation.parent = newBAsysID;
				relation.child = appSvcSysID;
				relation.type.setDisplayValue("Consumes::Consumed by");
				relation.insert();				
//Creates new relationship between new Application Service and new Application.
				relation.initialize();
				relation.parent = appSvcSysID;
				relation.child = applicationSysID;
				relation.type.setDisplayValue("Depends on::Used by");
				relation.insert();
5 REPLIES 5

suvro
Mega Sage
Mega Sage

Try defining a new variable for the new relation

var relation2 = new GlideRecord('cmdb_rel_ci');

relation2.initialize();

relation2.parent = appSvcSysID;

relation2.child = applicationSysID;

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

relation2.insert();

SGanguly
Tera Contributor

Thanks Suvro

I will try the same and update here.

Did you get a chance to try this?

Alex Wohl
Tera Contributor

My first thought is the literal  ‘ Depends on::Used by ‘  may need to be a sysID rather than literal  I have seen in past that scripts will fail with literals. I dont know enough to point to what should be Just a guess