Scripting to not update a field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-19-2023 10:41 AM
Hello,
I have a requirement to "not" update "Most Recent Discovery" field under a certain condition. I'm trying to do it via an onBefore script.
Any help on the scripting to not update "Most Recent Discovery", which by default updates everytime the CI is found in the network, would be appreciated.
-Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-19-2023 10:53 AM - edited 07-19-2023 10:54 AM
As far as i know, you can't really prevent a field to be updated through a BR.
The reason for that is because BR's run in order one after another and they change the data on every step.
The way to prevent the update would be to actually do changes in the scripts that do them.
Now there is a way to prevent data on field of being updated when conditions are met.
You can do this by setting up a Data Policy -> add condition - when true -> set a target field to read only.
They work exactly as UI Policies, BUT not even server side updates will be able to update the field.
The problem with this is tho that i think the policy will return as error for any BR that tries to update the field when it matches the condition. I assume that would abort the entire BR from updating any other fields as well.
Ofc you could test this yourself. But I think it wont be as easy.
Another thing you can try is actually write back the previous value to the field.
Make a onAfter BR
Set the order to be some very high (last BR script to run).
Then set a condition and if it's true.
Add code:
current.fieldName = previous.fieldName;
current.update();
This would technically put back the value before the change back on the same field again.
Would still recommend to do the logic in the scripts that change the field instead.
Any other solution is unpredictable.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-19-2023 11:34 AM
Hi @Priyanka Ghosh - the most recent discovery field is update by the IRE engine while discovery is in the process of identifying and classifying a device.
There are ways to handle the behavior of IRE and you can find more information by going to the below link:
Identification and Reconciliation engine (IRE)
Hope this helps you to move in the right direction.
Thanks,
Swapnil