Displaying the u_sla Field Based on sys_tags

nabil
Tera Contributor

Hello

I have a request to display the u_sla field in the Incident table only when one of the associated SLAs has the tag INC_SLA in the task_sla table.

To achieve this, I created a Client Script and a Script Include (see below). However, the script is unable to retrieve the tag (sys_tags) to apply the desired behavior.

I suspect that tags (sys_tags) have a special behavior and are part of the label table.

Would you have any suggestions to resolve this issue?

nabil_0-1733999287224.pngthe tag on sla definition 

nabil_1-1733999526347.png

 

In addition to the issue described earlier, I’ve noticed that the tags I’ve defined in the SLA definition are not appearing in the task_sla table when I create an incident.



client script --->

var incidentSysId = g_form.getUniqueValue();

    // verify if the id is valide 
    if (!incidentSysId) {
        alert('Client Script - Aucun sys_id d\'incident trouvé');
        return;
    }

    var ga = new GlideAjax('ik_IncidentHelperAJAX');
    ga.addParam('sysparm_name', 'hasTag');
    ga.addParam('sysparm_incident_sys_id', incidentSysId);

   
    ga.getXMLAnswer(function(response) {
        //alert(" response " + response);
        if (response === 'false') {
       
            g_form.setVisible('u_sla', false); // Masquer
            //return;
        } else  g_form.setVisible('u_sla', true);

---> Script include 

hasTag: function() {
        var incidentSysId = this.getParameter('sysparm_incident_sys_id');
        gs.log('NBA - Script Include - Vérification des tags SLA pour l\'incident : ' + incidentSysId, 'CheckSLATag');

        // Vérifie que le sys_id est fourni
        if (!incidentSysId) {
            gs.log('NBA - Script Include - Aucun sys_id d\'incident fourni', 'CheckSLATag');
            return 'false';
        }

        var taskSLA = new GlideRecord('task_sla');
        taskSLA.addQuery('task', incidentSysId);
        taskSLA.addQuery('sys_tags', 'INC_SLA'); // Vérifie le tag SLA
        taskSLA.query();

        if (taskSLA.next()) {
            gs.log('NBA - Script Include - SLA tag INC_SLA found   l\'incident : ' + incidentSysId, 'CheckSLATag');
            return 'true';
        } else {
            gs.log('NBA - Script Include - nothing SLA with  tag INC_SLA trouvé pour l\'incident : ' + incidentSysId, 'CheckSLATag');
            return 'false';
        }
    },

Best regards,

1 REPLY 1

Mark Manders
Mega Patron

Why are you tagging SLA records? Aren't they defined on the table? Having client scripts/ui policies work on tags on related records will be a challenge, so maybe there is a need for a different solution.

What is the business case for tagging SLA's (why/when is this done) and what is the content of the u_sla field? What is the use of this field? Is it displaying something? 


Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark