Getting Value from variable and Updating to Form field in Requested Item table
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-09-2019 07:35 AM
Hi All,
I have a case where I need to get the value from the variable(i.e.,requestedFor) and Update to a form field(sc_req_item.request.requested_for). Both variable and Form are part of Requested Item table. I want to Update this value before updating the value to a database. So I was trying with a before business rule on "sc_req_item" table. Below is the business rule I am using but no luck.Value is not getting updated.
(function executeRule(current, previous /*null when async*/) {
var grRITM = new GlideRecord('sc_req_item');
grRITM.addQuery('request', current.sys_id);
grRITM.query();
while (grRITM.next()) {
if (!JSUtil.nil(grRITM.variables.requested_for)) {
current.requested_for = grRITM.variables.requested_for;
}
}
}
I have seen in the community that I cannot use variables on the client script. We need a script include to do so. How can I achieve my requirement either with client script or business rule?
Below is the screenshot attached of variable and form field.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-09-2019 07:50 AM
Hi Ivakare,
Is your before business rule executing?
If yes, pls try current.request_for = current.variables.requested_for;
I hope this will work for you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-10-2019 12:32 AM
Hi kirankumarv11,
Thanks for the reply. You are right my business rule is not executing don't know why it's not executing. Any idea on why it's not running?
Even I tried with updating current.request_for = current.variables.requested_for; but still requested for in form field is blank. Because my business rule is not executing.
Thanks,
Lokesh.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-10-2019 01:16 AM
Hi Lokesh,
I believe, for this catalog item you have created one workflow. In workflow, by using run script you can achieve this. In run script add the below code:
current.request_for = current.variables.requested_for;
Current.update();
Regards
Kiran
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-10-2019 01:24 AM
Hi,
add condition of catalog item for which you want to run this and use below code
current.requested_for = current.variables.varaible_name;
current.update();
Thanks,
Vishal