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 G- LNG
Tera Patron
Tera Patron

Hi @RIKKAL 

 

It is ootb but user need to click:

AGLearnNGrow_0-1732891442932.png

 

*************************************************************************************************************
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]

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

View solution in original post

Anand Kumar P
Giga Patron
Giga 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
Giga Sage

Hi @RIKKAL 

 

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

********************************************************************************************************
Please appreciate the efforts of community contributors by marking the appropriate response as the correct answer and helpful. This may help other community users to follow the correct solution in the future.

********************************************************************************************************
Cheers,
Prashant Kumar
ServiceNow Technical Architect


Community Profile LinkedIn YouTube Medium TopMate
********************************************************************************************************

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 G- LNG
Tera Patron
Tera Patron

Hi @RIKKAL 

 

It is ootb but user need to click:

AGLearnNGrow_0-1732891442932.png

 

*************************************************************************************************************
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]

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

Anand Kumar P
Giga Patron
Giga 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
Giga Sage

Hi @RIKKAL 

 

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

********************************************************************************************************
Please appreciate the efforts of community contributors by marking the appropriate response as the correct answer and helpful. This may help other community users to follow the correct solution in the future.

********************************************************************************************************
Cheers,
Prashant Kumar
ServiceNow Technical Architect


Community Profile LinkedIn YouTube Medium TopMate
********************************************************************************************************

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.