- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-28-2024 03:38 AM
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
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-29-2024 06:44 AM
Hi @RIKKAL
It is ootb but user need to click:
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]
****************************************************************************************************************
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-29-2024 10:26 AM - edited 11-29-2024 10:28 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2024 04:12 AM
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
********************************************************************************************************
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2024 05:53 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-29-2024 06:44 AM
Hi @RIKKAL
It is ootb but user need to click:
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]
****************************************************************************************************************
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-29-2024 10:26 AM - edited 11-29-2024 10:28 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2024 04:12 AM
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
********************************************************************************************************
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2024 05:53 AM
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.