Change the color of nodes in the dependency view

kanakoA
Tera Contributor

Is it possible to dynamically change the color of a node in the dependency view?
For example, if the status is critical, make the node background color red.

3 REPLIES 3

Shivalika
Mega Sage

Hello @kanakoA 

 

Yes, you would need to modify the dependency map renderer UI Script.

 

May be created a script include with your styling conditions and call that script include in UI Script. 

 

Something like below 👇 

 

Below can be your script include - 

 

var CustomDependencyView = Class.create();
CustomDependencyView.prototype = {
initialize: function() {},

getCustomNodeStyles: function(ciSysId) {
var ci = new GlideRecord('cmdb_ci');
if (ci.get(ciSysId)) {
var status = ci.getValue('status'); // Adjust based on actual status field

if (status == 'critical') {
return { "background-color": "red", "border-color": "darkred" };
} else if (status == 'warning') {
return { "background-color": "yellow", "border-color": "orange" };
} else {
return { "background-color": "green", "border-color": "darkgreen" };
}
}
return {}; // Default styling
},

type: 'CustomDependencyView'
};

 

Kindly mark my answer as helpful and accept solution if it helped you in anyway. This will help me be recognized for the efforts and also move this questions from unsolved to solved bucket. 

 

Regards,

 

Shivalika 

 

My LinkedIn - https://www.linkedin.com/in/shivalika-gupta-540346194

 

My youtube - https://youtube.com/playlist?list=PLsHuNzTdkE5Cn4PyS7HdV0Vg8JsfdgQlA&si=0WynLcOwNeEISQCY

Community Alums
Not applicable

Hi @kanakoA ,

I don't think that's possible as you have just one property to make changes to the color which is "A value of true indicates that filtered out items will be removed from the graph along with any disconnected children while a value of false indicates that the items will be dimmed in color."

 

SandeepDutta_0-1743131920835.png

This property won't help with what is your ask!!

 

would recommend using the Unified Map with Washington, Xanadu and Yokohama.  The less customizations of the dependency map is recommended. 

 

 

 

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @kanakoA 

No, there is no way to uninstall it, and I wouldn’t recommend resorting to coding. This is more about education, and using code would only increase technical debt.

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************