Challenge on Outage Details field

Luiz Lucena
Mega Sage

Hello everyone, 

Have a little bit of a challenge here. 
We are using the awesome System Status v2 by @Andrew Albury-D and, based on internal requirements, I had to create a template with a text to populate the Details field in the Outage form. 
That text is to facilitate for people generating the outages with specific font size and format. 

They came with another requirement, which is to populate the CI name in that text, like the example below, but I'm not sure how to achieve that as the text comes from the template onLoad.

Screenshot 2024-07-02 164722.png

 

Any idea will be much appreciated.

1 ACCEPTED SOLUTION

Bogdan18
Tera Guru
Here you go Luiz!
Client script on Change of the Configuration item:
 
 
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
    if (isLoading || newValue === '') {
        return;
    }

    var getDetails = g_form.getValue("details");

    var ci = g_form.getReference("cmdb_ci", function(ci) {


        var ciDisplay = ci.name.toString();

        if (getDetails.indexOf("the system above") >= 0) {
            getDetails = getDetails.replace("the system above", ciDisplay);
        } else {
            var oldCi = getDetails.substring(getDetails.indexOf("affecting "), getDetails.indexOf(".")).replace("affecting ", " ");

            ciDisplay = " " + ciDisplay;
            getDetails = getDetails.replace(oldCi, ciDisplay);

        }

        g_form.setValue("details", getDetails);

    });
}

View solution in original post

2 REPLIES 2

Bogdan18
Tera Guru
Here you go Luiz!
Client script on Change of the Configuration item:
 
 
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
    if (isLoading || newValue === '') {
        return;
    }

    var getDetails = g_form.getValue("details");

    var ci = g_form.getReference("cmdb_ci", function(ci) {


        var ciDisplay = ci.name.toString();

        if (getDetails.indexOf("the system above") >= 0) {
            getDetails = getDetails.replace("the system above", ciDisplay);
        } else {
            var oldCi = getDetails.substring(getDetails.indexOf("affecting "), getDetails.indexOf(".")).replace("affecting ", " ");

            ciDisplay = " " + ciDisplay;
            getDetails = getDetails.replace(oldCi, ciDisplay);

        }

        g_form.setValue("details", getDetails);

    });
}

Worked perfectly!

 

Thanks, @Bogdan18 !