what could we use in the Business Rule script similar to the client side scripting which uses g_form.getValue('o_employee'); //'o_employee' is a variable in service request?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-22-2018 05:00 AM
Hi Experts,
I have an onoload client script which calls a script include which populates the value of the variable in the service request
qrykey = 'type=keyboard^install_status=1^assigned_to='+g_form.getValue('o_employee'); //'o_employee' is a variable
// in service request
ga.addParam('sysparm_name','populateKeyboard');
ga.addParam('sysparm_table_name',"cmdb_ci_peripheral");
ga.addParam('sysparm_encoded_query', qrykey);
ga.getXMLAnswer(function(answer)
{
var str = answer.slice(0,-1);
g_form.setValue('o_asset_keyboard',str);
});
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-22-2018 06:08 AM
Hi Ashutosh,
The above code didn't work.
BR is on the User table (sys_user) after update but the 'o_employee ' is the variable in the Requested item. This requested item is created on after Update business Rule of User table(sys_user) table.
To add here,
The onload client script works perfect with the below code. but since I am trying to use the same client script for my business Rule. I should replace g_form int the qrykey. I tried different options But it doesn't work.
qrykey = 'type=keyboard^install_status=1^assigned_to='+g_form.getValue('o_employee'); //'o_employee' //is a variable
// in service request
ga.addParam('sysparm_name','populateKeyboard');
ga.addParam('sysparm_table_name',"cmdb_ci_peripheral");
ga.addParam('sysparm_encoded_query', qrykey);
ga.getXMLAnswer(function(answer)
{
var str = answer.slice(0,-1);
g_form.setValue('o_asset_keyboard',str);
});

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-22-2018 06:33 AM
Hi,
Then try this :
current.o_asset_keyboard = str;
If this is a before insert/update BR dont use current.update and use current.update in after BR
Thanks,
Ashutosh Munot
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-22-2018 08:23 AM
This didn't work either.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-22-2018 11:02 AM
Hi,
Are you getting Value in STR?
Thanks,
Ashutosh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-28-2018 08:26 AM
I achieved it though glide record.