How to dynamically update a field value
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-17-2015 07:27 AM
Hello,
I have the following question:
I am dealing with a request item, and I am setting the assignment_group field on the request item = to the assignment _group field from a specific catalog task. (to make this easier, I basically set up 2 variables on the Request Item / Catalog Task and am having the assignment_group field write to this variable so the coding was easier.
current.variables.AssignmentGroup = task.assignment_group;
current.assignment_group = current.variables.AssignmentGroup;
This is populating the Assignment Group field on the Request Item based on the assignment_group from the catalog task. However, if I update the assignment_group on the catalog task, it won't update the Request item assignment group.
Does anyone know how to make this dynamically update ? We would like to be able to update the task assignment group and have it flow all the way to the request item assignment group..
Thanks!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-17-2015 08:35 AM
Hi Sandra,
You have to create after BR(check insert and update to true) on catalog task table(sc_task). Here you go.
var request = current.request_item.getRefRecord();
request.assignment_group = current.assignment_group;
request.update();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-17-2015 11:55 AM
Hi Pradeep:
I replied to Mani (below), but thought I would respond to you as well
I tried this business rule and it didn't seem to do anything
So here is the flow again (because I know it's difficult to follow if you don't have it in front of you 😞
Catalog Task - there is an assignment group field
Catalog Task / Request Item - I have created a variable called AssignmentGroup. There is code to populate the AssignmentGroup variable with the value from the assignment_group field-here is the code:
current.variables.AssignmentGroup = task.assignment_group;
Next,I have the Request Item assignment_group field reading from the AssignmentGroup variable using this code:
current.assignment_group = current.variables.AssignmentGroup;
This works fine, unless I update the assignment_group field on the catalog task.
What I need to have happen is for when the assignment_group field is changed, for the AssignmentGroup variable to be changed, thus updating the Assignment_Group on the request item.
I hope that might help clarify. Any suggestions would be welcomed!
Thanks!!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-26-2018 02:59 AM
Hi, I have created a UI action for converting an incident to a service request. In this i am able to autofill request fields as per incident fields but not able to map the requested items field.
I am able to update short description and description also.
function OpenSR()
{
var cartId = GlideGuid.generate(null);
var cart = new Cart(cartId);
var SR = cart.addItem('aa1ba9a7131f4f00492f5e7f3244b0f4');
var rc = cart.placeOrder();
var req = new GlideRecord("sc_request");
req.addQuery('sys_id','=',rc.sys_id);
req.query();
if (req.next()) {
req.opened_by= current.caller_id;
req.opened_at = current.opened_at;
req.requested_for = ('NULL');
req.update();
}
var reqt = new GlideRecord("sc_req_item");
reqt.addQuery('request','=',rc.sys_id);
reqt.query();
if (reqt.next()) {
reqt.requested_by= current.caller_id;
reqt.opened_by= current.caller_id;
reqt.opened_at = current.opened_at;
reqt.short_description = current.short_description;
reqt.description = current.description;
reqt.requested_for = ('NULL');
reqt.parent = current.sys_id;
GlideSysAttachment.copy('incident', current.sys_id, 'sc_req_item', reqt.sys_id);
reqt.update();
}
gs.addInfoMessage(rc.number);
action.setRedirectURL(rc);
current.close_code = 'Converted to Service Request';
current.incident_state='7';
current.close_notes=(rc.number);
current.update();
}
OpenSR();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-17-2015 08:39 AM
Sandra,
You can write a business rule of sc_task which would be something like:
Business Rule:
Type: OnAfter
Condition: current.assignment_group.changes()
Table : sc_task
Script:
var item = new GlideRecord('sc_req_item');
item.get(current.request_item.sys_id);
item.assignmnet_group = current.assignment_group;
item.update();