Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

servicenow

venkatamahesh
Tera Contributor

If the current incident is a child incident, add a info message with a clickable parent incident number.

 

3 REPLIES 3

venkatamahesh
Tera Contributor
function onLoad() {
    //Type appropriate comment here, and begin script below
    var parent = g_form.getReference('parent_incident', parentFunc);

    function parentFunc(parent) {
        var p = g_form.getValue('parent_incident');
        if (p != "") {
            g_form.addInfoMessage('This is a child incident of ' + '<ahref = \'https://dev64478.service-now.com/nav_to.do?uri = incident.do ? sys_id = ' + parent.sys_id + '\'target = \'_blank\'>' + parent.number + '</a>');

        }
    }
}

Harish Bainsla
Kilo Patron
Kilo Patron

Hi use onload client script

function onLoad() {

    if (g_form.getValue('parent_incident') != '') {
        var parentIncidentNumber = g_form.getValue('parent_incident');
        var link = '<a href="' + parentIncidentNumber + '">' + parentIncidentNumber + '</a>';
        var message = 'This incident is related to parent incident: ' + link;
        g_form.addInfoMessage(message);
    }
check below screenshot its working i try on my pdi
HarishBainsla_0-1709106011553.png

 

_Gaurav
Kilo Sage

Hi @venkatamahesh 

Just write a display business rule where the condition should be parent incident is not empty and in the script section add the below-mentioned script.
Conditon

_Gaurav_0-1709106154160.png

 

Script

var link = '<a href="incident.do?sys_id='+current.parent_incident+'"> '+current.parent_incident.number+' </a>';
var message = gs.getMessage('Parent incident') + ' ' + link + ' ';
gs.addInfoMessage(message);
 
Please mark this as helpful and accept it as a solution if this resolves your query.
Thanks!