- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-02-2020 03:38 PM
Hello all,
I created a BR to update a custom field from the incident table to a field I created in the sys_journal_field table. The ultimate goal here is to print the additional comments and their respective priority level onto an email notification. Right now I am pulling from the Priority field on the incident table. The issue is that every time the additional comments are updated, the priority level will be different. I need a way to store the priority levels for each comment.
So, I decided to store the priority level from the incident table into a custom field I created in the sys_journal_field table. The issue is that this BR creates a new record in the sys_journal_field table, it doesn't add the priority level into the additional comments. Here is what I have so far.
(function executeRule(current, previous /*null when async*/) {
var gr = new GlideRecord('sys_journal_field');
gr.initialize();
gr.u_new_priority=current.priority; //I need to store the priority into the u_new_priority
gr.insert();
})(current, previous);
The first snap shot is what I get. The second snapshot, is where the Priority level from the incident form should go.
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-02-2020 04:36 PM
Write an 'onBefore' ---> 'insert' business rule on the table sys_journal_field table
condtion--> current.name=='incident'
Add the below code to your business rule-
(function executeRule(current, previous /*null when async*/) {
var priority='';
var gr=new GlideRecord('incident');
gr.addQuery('sys_id', current.element_id);
gr.query();
if(gr.next())
{
priority=gr.priority;
}
current.u_new_priority=priority;
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-02-2020 04:30 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-02-2020 04:36 PM
Write an 'onBefore' ---> 'insert' business rule on the table sys_journal_field table
condtion--> current.name=='incident'
Add the below code to your business rule-
(function executeRule(current, previous /*null when async*/) {
var priority='';
var gr=new GlideRecord('incident');
gr.addQuery('sys_id', current.element_id);
gr.query();
if(gr.next())
{
priority=gr.priority;
}
current.u_new_priority=priority;
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-03-2020 03:01 PM
Thank you Manoj,
This worked but I had to make some adjustments.
I had to change,
from:
priority=gr.priority;
to:
priority=gr.getDisplayValue('priority');
Because only the numeric value was displayed, this fixed it.
Thank you again.