Need clarity

RIKKAL
Tera Contributor

When you open an incident record, it should populate all the Active Incidents Number and Short description as Info message for Same caller.

i want to create it business rules is it possible ?if yes can anyone say me

 

4 ACCEPTED SOLUTIONS

Dr Atul - LNG
Tera Patron

Hi @RIKKAL 

 

It is ootb but user need to click:

AGLearnNGrow_0-1732891442932.png

 

View solution in original post

Anand Kumar P
Tera Patron

Hi @RIKKAL ,

 

Create display business rule and use below script 

    if (current.caller_id) {

        var grinc= new GlideRecord('incident');

        grinc.addQuery('caller_id', current.caller_id)

        grincaddQuery('state', '!=', 6)

        grinc.addQuery('sys_id', '!=', current.sys_id);

        grinc.query();

        var message = '';

        while (grinc.next()) {

            message += grinc.number + ': ' + grinc.short_description + '\n';

        }

        gScratchpad.activeIncidentsMessage = message;

}

Create new on load client script on incident table and use below script 

function onLoad() {

    if (g_scratchpad.activeIncidentsMessage) {

        g_form.addInfoMessage("Active incidents for this caller:\n" + g_scratchpad.activeIncidentsMessage);

    }

}

 

Mark it as helpful and solution proposed if it serves your purpose.
Thanks,
Anand

View solution in original post

PrashantLearnIT
Tera Sage

Hi @RIKKAL 

 

It is already available OOB, like how @Dr Atul - LNG  have mentioned, no scripting is required and is not recommended.

View solution in original post

Runjay Patel
Giga Sage

Hi @RIKKAL ,

 

As @Anand Kumar P  mentioned write display business rule and use script to display the message. Also you don’t need to write client side script.

i have refined the script to display all active incident open by caller.

use below script:

// Get the current record's caller
var caller = current.caller_id;

// Query the Incident table for active incidents of the same caller
var incidentGR = new GlideRecord('incident');
incidentGR.addQuery('caller_id', caller); // Filter by the same caller
incidentGR.addQuery('active', true); // Filter by active incidents
incidentGR.query();

// Create the message
var message = 'Active Incidents for ' + caller.name + ': \n';
while (incidentGR.next()) {
message += 'Incident Number: ' + incidentGR.number + ' - ' + incidentGR.short_description + '\n';
}

// If no active incidents, inform the user
if (incidentGR.getRowCount() === 0) {
message = 'No active incidents found for this caller.';
}

// Display the message as an Info message
gs.addInfoMessage(message);

Accept the solution if it helped.

View solution in original post

5 REPLIES 5

Dr Atul - LNG
Tera Patron

Hi @RIKKAL 

 

It is ootb but user need to click:

AGLearnNGrow_0-1732891442932.png

 

Anand Kumar P
Tera Patron

Hi @RIKKAL ,

 

Create display business rule and use below script 

    if (current.caller_id) {

        var grinc= new GlideRecord('incident');

        grinc.addQuery('caller_id', current.caller_id)

        grincaddQuery('state', '!=', 6)

        grinc.addQuery('sys_id', '!=', current.sys_id);

        grinc.query();

        var message = '';

        while (grinc.next()) {

            message += grinc.number + ': ' + grinc.short_description + '\n';

        }

        gScratchpad.activeIncidentsMessage = message;

}

Create new on load client script on incident table and use below script 

function onLoad() {

    if (g_scratchpad.activeIncidentsMessage) {

        g_form.addInfoMessage("Active incidents for this caller:\n" + g_scratchpad.activeIncidentsMessage);

    }

}

 

Mark it as helpful and solution proposed if it serves your purpose.
Thanks,
Anand

PrashantLearnIT
Tera Sage

Hi @RIKKAL 

 

It is already available OOB, like how @Dr Atul - LNG  have mentioned, no scripting is required and is not recommended.

Runjay Patel
Giga Sage

Hi @RIKKAL ,

 

As @Anand Kumar P  mentioned write display business rule and use script to display the message. Also you don’t need to write client side script.

i have refined the script to display all active incident open by caller.

use below script:

// Get the current record's caller
var caller = current.caller_id;

// Query the Incident table for active incidents of the same caller
var incidentGR = new GlideRecord('incident');
incidentGR.addQuery('caller_id', caller); // Filter by the same caller
incidentGR.addQuery('active', true); // Filter by active incidents
incidentGR.query();

// Create the message
var message = 'Active Incidents for ' + caller.name + ': \n';
while (incidentGR.next()) {
message += 'Incident Number: ' + incidentGR.number + ' - ' + incidentGR.short_description + '\n';
}

// If no active incidents, inform the user
if (incidentGR.getRowCount() === 0) {
message = 'No active incidents found for this caller.';
}

// Display the message as an Info message
gs.addInfoMessage(message);

Accept the solution if it helped.