- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-30-2022 10:41 PM
Hello All,
I have created custom field with integer type on problem form, I want to show related incidents count on that field when user is checking on problem.list view, Is there any way I can achieve this ?
I tried with display business rule, but that is displaying count only when user is opening the problem form, not working on list view.
Any kind of help is greatly appreciated!
Regards,
Ujjwala
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-30-2022 11:32 PM
Hi,
Since we are talking here about Incident related to Problem, so it can be that Problem might have been created from Incident or may be you have added your Incident using Related List on a Problem record, Problem Field on Incident record will always be updated as shown below:
So what I would suggest here is write a After Update Business Rule on Incident Table itself and update the count in your custom field instead of doing a query how many incident are linked and then storing it.
BR:
Table: Incident
After Update
Condition of BR: Problem Changes
Script:
(function executeRule(current, previous /*null when async*/) {
// Add your code here.
var count = 1;
var gr = new GlideRecord('problem');
gr.addQuery('sys_id',current.problem_id);
gr.query();
if(gr.next()){
gr.u_linked_incident = gr.u_linked_incident + count; // Replace "u_linked_incident" with your Field Name in Problem Table
gr.update();
}
})(current, previous);
Result:
Hope this helps. Please mark the answer as correct/helpful based on impact.
Regards,
Shloke
Regards,
Shloke

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-30-2022 10:49 PM
Hi,
You need to go for On Demand Script Include in this case.
Create a On Demand Script Include (use the below link for reference)
https://developer.servicenow.com/dev.do#!/learn/learning-plans/quebec/new_to_servicenow/app_store_learnv2_scripting_quebec_on_demand_script_include
Right click on your field --> Configure Dictionary --> Default Value -> javascript:ScriptIncludeName();
Mark this as Helpful/Correct if Applicable.
Regards,
Sourabh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-30-2022 10:57 PM
Hi,
what type of field it is?
how are you populating it?
you can make that field as calculated type and it would show on list and form both
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-30-2022 11:32 PM
Hi,
Since we are talking here about Incident related to Problem, so it can be that Problem might have been created from Incident or may be you have added your Incident using Related List on a Problem record, Problem Field on Incident record will always be updated as shown below:
So what I would suggest here is write a After Update Business Rule on Incident Table itself and update the count in your custom field instead of doing a query how many incident are linked and then storing it.
BR:
Table: Incident
After Update
Condition of BR: Problem Changes
Script:
(function executeRule(current, previous /*null when async*/) {
// Add your code here.
var count = 1;
var gr = new GlideRecord('problem');
gr.addQuery('sys_id',current.problem_id);
gr.query();
if(gr.next()){
gr.u_linked_incident = gr.u_linked_incident + count; // Replace "u_linked_incident" with your Field Name in Problem Table
gr.update();
}
})(current, previous);
Result:
Hope this helps. Please mark the answer as correct/helpful based on impact.
Regards,
Shloke
Regards,
Shloke
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-31-2022 12:18 AM