- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-25-2022 10:37 AM
Hi All,
Field name : manufacturer checkbox is available on req , ritm and SCTask tables.
On ritm and SCTask it is read-only. On request table it is editable
I'm having a requirement when a field (ex: manufacturer ) is selected on request table, then automatically the same field manufacturer on the ritm and SCTask should be made active.
When on request it is unchecked , then on both ritm and SCTask it should be unchecked.
Please guide me how can this be achieved.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-25-2022 12:46 PM
To change the value of a field on different table(s) you would use a Business Rule. If you want to (also) make the field not read only, you would need an onLoad Client Script to do that. Create the Business Rule on the sc_request table after Insert and Update with the Filter Condition <<field>> changes. Your script on the Advanced tab would look like this:
(function executeRule(current, previous /*null when async*/) {
var ritm = new GlideRecord('sc_req_item');
ritm.addQuery('request', current.sys_id);
ritm.query();
if (ritm.next()) {
ritm.manufacturer = current.manufacturer;
ritm.update();
var sctask = new GlideRecord('sc_task');
sctask.addQuery('request_item', ritm.sys_id);
sctask.query();
while(sctask.next()){
sctask.manufacturer = current.manufacturer;
sctask.update();
}
}
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-25-2022 12:40 PM - edited 10-25-2022 12:42 PM
Create a business rule on the Request table. Make sure it's set to run on Update
In the script field, this should work
//update RITM
var ritm = new GlideRecord('sc_req_item');
ritm.addQuery('request', current.sys_id);
ritm.query();
while (ritm.next()) {
ritm.u_manufacturer = current.u_manufacturer;
ritm.update();
}
//update SC Task
var task = new GlideRecord('sc_task');
task.addQuery('request', current.sys_id);
task.query();
while (task.next()) {
task.u_manufacturer = current.u_manufacturer;
task.update();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-25-2022 07:51 PM
Hi Mike,
The BR should be after Business rule??
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-25-2022 12:46 PM
To change the value of a field on different table(s) you would use a Business Rule. If you want to (also) make the field not read only, you would need an onLoad Client Script to do that. Create the Business Rule on the sc_request table after Insert and Update with the Filter Condition <<field>> changes. Your script on the Advanced tab would look like this:
(function executeRule(current, previous /*null when async*/) {
var ritm = new GlideRecord('sc_req_item');
ritm.addQuery('request', current.sys_id);
ritm.query();
if (ritm.next()) {
ritm.manufacturer = current.manufacturer;
ritm.update();
var sctask = new GlideRecord('sc_task');
sctask.addQuery('request_item', ritm.sys_id);
sctask.query();
while(sctask.next()){
sctask.manufacturer = current.manufacturer;
sctask.update();
}
}
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-04-2022 03:05 AM
Hi @Brad Bowman ,
It is working fine if all the 3(req,ritm,sctask) are generated before the time of manufacturer is selected.
But for few scenarios, when REQ is created and if manufacturer is selected and by that time no RITM and sctask are available, then the above solution is not working.
Only in REQ, Manufacturer checkbox is selected and for other 2 it is not.
Please help me what changes have to be made for this type of scenario