- 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
11-04-2022 05:46 AM
It sounds like you need an additional Business Rule on the sc_req_item table, and a third on sc_task so that the script will trigger before insert. The script just needs to check the related REQ to grab the manufacturer and populate it on the current record. Since there is a request field on both the sc_task and sc_req_item table, the script is the same for both rules:
(function executeRule(current, previous /*null when async*/) {
current.manufacturer = current.request.manufacturer;
})(current, previous);