- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2024 12:45 AM
Hello Everyone,
Greetings All!
I have been trying to link an incident to a problem using background script. I have used the below script but it is not quite working for me.
Can anyone help me out with this:
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2024 07:51 AM
Hi @PapaiD
You need to use sys_id of the problem record since that is reference field.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2024 08:10 AM - edited 09-14-2024 08:10 AM
Hi @PapaiD ,
As the problem_id field is a reference field it only stores the sys_id of the problem record, so instead of using
gr.problem_id = "PRB0001000", use the sys_id of the problem record (PRB0001000)
Below is the updated script:
var gr = new GlideRecord('incident');
gr.addQuery('number','INC0010008');
gr.addNullQuery('problem_id');
gr.query();
while(gr.next()){
gr.problem_id = "<sys_id of the Problem record PRB0001000>"; // replace it with actual sys_id
gr.update();
}
If this solution helps you then, mark it as accepted solution ✔️ and give thumbs up 👍!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2024 07:39 AM
@PapaiD You can use the sys_id of the Problem record to update it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2024 07:51 AM
Hi @PapaiD
You need to use sys_id of the problem record since that is reference field.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2024 08:10 AM - edited 09-14-2024 08:10 AM
Hi @PapaiD ,
As the problem_id field is a reference field it only stores the sys_id of the problem record, so instead of using
gr.problem_id = "PRB0001000", use the sys_id of the problem record (PRB0001000)
Below is the updated script:
var gr = new GlideRecord('incident');
gr.addQuery('number','INC0010008');
gr.addNullQuery('problem_id');
gr.query();
while(gr.next()){
gr.problem_id = "<sys_id of the Problem record PRB0001000>"; // replace it with actual sys_id
gr.update();
}
If this solution helps you then, mark it as accepted solution ✔️ and give thumbs up 👍!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2024 08:23 AM
Thank you!