- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-21-2019 09:18 AM
Hello Guys,
can you please suggest what to do here, in the below code so that things will work fine again .
My Code :
var grProblem = new GlideRecord('problem');
grProblem.initialize();
grProblem.setValue('short_description', 'PRB generated from P1 ' + current.getDisplayValue());
grProblem.insert();
current.assignment_group='Database Atlanta'; // Not working
current.assigned_to='bow.ruggeri@example.com'; // Not working
current.setValue('problem_id', grProblem.getUniqueValue());
current.update();
Thank you in advance
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-21-2019 09:40 AM
hello Bright,
As assignment_group & assigned_to is reference field, you need to pass a sys_id of assignment_group & assigned_to.
current.assignment_group='SYS ID of Database Atlanta'; // Not working
current.assigned_to=' SYS ID of bow.ruggeri@example.com'; // Not working
OR
Try using below code:
current.setDisplayValue('assignment_group','Database Atlanta');
current.setDisplayValue('assigned_to','bow.ruggeri@example.com');
For more details:
Few recommendations:
1. I would recommend to use grProblem.getValue('sys_id') in place of grProblem.getUniqueValue();\
2. If you are using BEFORE BR then No Need to of current.update();
3. If you are using AFTER BR then you can add one more line current.setWorkflow(false); before current.update(); OR Not to use current.update();
Please mark as Correct Answer/Helpful, if applicable.
Thanks!
Abhishek Gardade
Abhishek Gardade
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-21-2019 09:40 AM
hello Bright,
As assignment_group & assigned_to is reference field, you need to pass a sys_id of assignment_group & assigned_to.
current.assignment_group='SYS ID of Database Atlanta'; // Not working
current.assigned_to=' SYS ID of bow.ruggeri@example.com'; // Not working
OR
Try using below code:
current.setDisplayValue('assignment_group','Database Atlanta');
current.setDisplayValue('assigned_to','bow.ruggeri@example.com');
For more details:
Few recommendations:
1. I would recommend to use grProblem.getValue('sys_id') in place of grProblem.getUniqueValue();\
2. If you are using BEFORE BR then No Need to of current.update();
3. If you are using AFTER BR then you can add one more line current.setWorkflow(false); before current.update(); OR Not to use current.update();
Please mark as Correct Answer/Helpful, if applicable.
Thanks!
Abhishek Gardade
Abhishek Gardade
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-22-2019 01:05 AM
Hey Thank you Abhishek Gardade 🙂

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-21-2019 06:56 PM
Abhieshek has provided some great information. Supplementing his advice, I would solve this by following the steps below.
- When setting more than one reference field to a static value, I'd recommend using Templates.
Create a Template on the Incident table called 'System - P1 Incident - Database Atlanta'.
Please note that this solution assumes your Group and User Sys ID's are the same in each environment, otherwise you will have to use System Properties. - Populate 'Short description' with a note indicated that it is used by your Business Rule (specify which one)
- Populate 'Assignment Group' to "Database Atlanta" and 'Assigned to' "Bow Ruggeri".
- Ensure Template does not have 'Global' checked and is assigned to a system user such as admin
- This is one of the rare circumstances where you have to use current.update() on an after Business Rule. This should generally be avoided but I see no choice here.
Ensure 'When' is set to "After" - Populate your Advanced Script as follows:
var grProblem = new GlideRecord('problem'); grProblem.initialize(); grProblem.setValue('short_description', 'PRB generated from P1 ' + current.getDisplayValue()); grProblem.insert(); // current.update() must be used here, as the relationship to the problem is stored on the incident record which has already been updated. current.applyTemplate('System - P1 Incident - Database Atlanta'); current.setValue('problem_id', grProblem.getValue('sys_id')); current.setWorkflow(false); // Prevent recursive update to Incident current.update();
ServiceNow Nerd
ServiceNow Developer MVP 2020-2022
ServiceNow Community MVP 2019-2022
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-22-2019 01:04 AM
Hey Thank You Paul Morris 🙂