- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-11-2023 04:02 AM
Im trying to get the value of a field "status" on the table "task_sla" into a custom field I created in the "task [TASK]" table (the field name in "task" is "u_status"), Im using a BR to do this but Im not really sure how to do it, can anyone help ?
BR:
BR Code:
(function executeRule(current, previous /*null when async*/) {
var gr = new GlideRecord('task');
gr.addQuery('u_status');
gr.query();
gr.u_status = current.u_status;
})(current, previous);
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-11-2023 04:45 AM
u_status on task table is of what type?
Out of the box task_sla doesn't have Status field.
Did you change the label of an existing field?
The logic will be something like this
(function executeRule(current, previous /*null when async*/) {
var gr = new GlideRecord('task');
if(gr.get(current.task)){
gr.u_status = current.statusField; // this is the field on task_sla table
gr.update();
}
})(current, previous);
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-11-2023 04:57 AM
Hello @F_bio Santos
use the same code of @Ankur Bawiskar
(function executeRule(current, previous /*null when async*/) {
var gr = new GlideRecord('task');
if(gr.get(current.task)){
gr.u_state = current.u_status; // this is the field on task_sla table
gr.update();
}
})(current, previous);
, just do the modification which i shared.
Plz Mark my Solution as Accept and Give me thumbs up, if you find it helpful.
Regards,
Samaksh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-11-2023 04:10 AM
Hello @F_bio Santos
(function executeRule(current, previous /*null when async*/) {
var gr = new GlideRecord('task');
gr.query();
while(gr.next()){
gr.u_status = current.u_status;
}
})(current, previous);
Modify your script with mine.
Plz Mark my Solution as Accept and Give me thumbs up, if you find it helpful.
Regards,
Samaksh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-11-2023 04:19 AM
Hello @Samaksh Wani, I tried it but when I create the record the "status" value is empty on the "TASK" table and on the "task_sla" is "On Track".
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-11-2023 04:31 AM
Hello @F_bio Santos
Check after updating the state of table. Your BR will work at Update.
Plz Mark my Solution as Accept and Give me thumbs up, if you find it helpful.
Regards,
Samaksh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-11-2023 04:45 AM
u_status on task table is of what type?
Out of the box task_sla doesn't have Status field.
Did you change the label of an existing field?
The logic will be something like this
(function executeRule(current, previous /*null when async*/) {
var gr = new GlideRecord('task');
if(gr.get(current.task)){
gr.u_status = current.statusField; // this is the field on task_sla table
gr.update();
}
})(current, previous);
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader