
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-22-2023 03:01 AM
Hi,
On a demand form we have a related list called Affected Cost Centre where users can select one or more cost centres associated with the demand record. There is now a requirement to have the primary cost centre as a field on the demand record, so we have created a new reference field. Is there a way to relate the two, such that if the user selects CC123 in the new field, CC123 is automatically added to the related list?
Thanks
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-22-2023 03:07 AM - edited ‎11-22-2023 03:12 AM
Hi @Cirrus ,
yep, you can create a scripted async / after business rule running on the demand form. So whenever the new reference field is not empty (e.g. filed with CC123), then read the field and populate it to the related list. I have done the exact same thing with a custom configuration item field in the incident form.
It is off course depended on how you related list is created, which table it refers to etc. etc...
If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.
best regards
Anders
If my answer has helped with your question, please mark my answer as the accepted solution and give a thumbs up.
Best regards
Anders
Rising star 2024
MVP 2025
linkedIn: https://www.linkedin.com/in/andersskovbjerg/

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-24-2023 01:49 AM
The script was wrong as I suspected The following async on insert resolved:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-24-2023 01:55 AM - edited ‎11-24-2023 01:56 AM
Hi @Cirrus ,
Create you got it resolved - otherwise please see below solution:
I created the reference field u_cost_code in my PDI:
Created the relationships between dmn_demand and task_cost_center:
And created the business rule to updated the related list whenever the cost code is not empty:
(function executeRule(current, previous /*null when async*/) {
// get the current demand costcenter
var costCenter = current.u_cost_code;
if (costCenter != '') {
var cost = new GlideRecord('task_cost_center');
cost.initialize();
cost.task = current.sys_id;
cost.cost_center = current.u_cost_code;
cost.insert();
gs.addInfoMessage('Cost center ' + current.u_cost_code + ' has been added to affected cost centers');
}
})(current, previous);
If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.
best regards
Anders
If my answer has helped with your question, please mark my answer as the accepted solution and give a thumbs up.
Best regards
Anders
Rising star 2024
MVP 2025
linkedIn: https://www.linkedin.com/in/andersskovbjerg/

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-22-2023 03:10 AM
Hi,
It is not possible with OOB related list.
Please check below link to set filter condition on OOB related list.
Or another way is to create custom relationship and add the filter criteria to show record as per your requirement.
Thanks
Anil Lande