- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-21-2022 09:18 PM
Hello everyone,
I have one issue on ServiceNow.
Currently I'm performing one Business Rule that required not be allowed sync new data on one field from Software Model to Software Catalog.
Specifically as follow: When I change value on Model Number field of table Software Model, I want that new value not sync to Software Catalog, it means respective field on Software Catalog table still keep old value.
Ex: Model Number field has attribute name is model_number in Software Model
and is product_id in Software Catalog (they correspond to each other)
But Model Number field in Software Catalog still save new value when changing value from Software Model.
Please help me this issue. Thanks!
Specs:
When to run: After - Update
Parent table: [cmdb_software_product_model]
Child table: [pc_software_cat_item]
My coding:
(function executeRule(current, previous /*null when async*/) {
if(current.sys_class_name == 'cmdb_software_product_model') {
var chil = new GlideRecord("pc_software_cat_item");
chil.addQuery('parent', current.sys_id);
chil.addQuery('product_id', current.model_number);
chil.query();
while(chil.next()) {
current.setAbortAction(true);
current.update(); }
}
})(current, previous);
Tuan
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-21-2022 10:34 PM
@nguyennguyent The product ID is synced OOB, but you can handle it from a before update BR on "pc_sofware_cat_item" with condition "product id changes and product id is not empty", with below code:
current.product_id = previous.product_id;
Please mark the answer correct/helpful accordingly.
Raghav
MVP 2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-21-2022 10:34 PM
@nguyennguyent The product ID is synced OOB, but you can handle it from a before update BR on "pc_sofware_cat_item" with condition "product id changes and product id is not empty", with below code:
current.product_id = previous.product_id;
Please mark the answer correct/helpful accordingly.
Raghav
MVP 2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-21-2022 11:21 PM
Hi @RaghavSh
Wonderful. You're expert! Thanks a lot!
When I created other BR and with conditions that you suggested, it works fine 😊
It's good to be able to handle in a single BR.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-21-2022 11:29 PM
@nguyennguyent glad that worked!!!
Raghav
MVP 2023