
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2018 11:08 AM
Hi community.
This is my first community post here, so please bear with me 🙂
I have been trying to change the Business Rule on Calculate Display Name for alm_asset. The current value (default) is: current.asset_tag.changes() || current.model.changes() || current.operation() == 'insert'
Basically, what I am trying to change is that the display name is calculated not from an asset tag but from a serial number. Question is: wouldn't it be logical to just change asset_tag to serial_number and it should work?
Here's the screenshot on what I have now (Kingston):
So, how do you go about changing asset_tag to serial_number that works? What are the steps I need to take to make this happen? I have been mind-boggled for two days now and nothing I try is working.
I would like to change the behavior for current assets and any new assets that get loaded either via load data or manually.
Please help.
Thank you in advance.
Solved! Go to Solution.
- Labels:
-
Enterprise Asset Management

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2018 03:32 AM
There are different views on this but I personally don't really like to alter ootb business rules but rather create copies of them and then deactive the ootb rule when the new one works.
As for what you are trying to do you wouldn't actually look in the busines rule itself to change it from using serial number instead of asset tag since it's using a AssetUtils which is a Script Include (see below). The only thing you would accomplish by changing asset_tag so serial_number in the condition-field is just change so that it triggers when serial_number is change and not asset_tag. In order to change the value you would either have to change the code in the script include or just create a new BR which accomplishes the same thing without changing an OOTB script include. The negative part to not use the script include is that if that function is used in some other business rule, script etc then you would get the asset_tag again and not the serial_number.
Anyway the code need to set the display name to serial_number + model should be the code snippet below. Now this doesn't take into account if the serial_number of model is missing so if both were missing you would just get a display name like " - " but a check like that can easily be added. You have one in the script include for example
current.display_name = current.serial_number + " - " + current.model.display_name;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2018 02:36 PM
Hi Asmir,
First, if this Business Rule is OOB, I suggest to create a copy of it and then you can add the changes. You need to test both scenarios to see which one would be the best depending of the business process. For serial number, you need to add something like this in your conditions:
current.serial_number.changes()
Hope this helps,
Pedro Lopez

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2018 03:06 AM
Hi Pedro.
I am unsure I understand what you meant. Care to elaborate a bit more please?
Or at least point me to some instructions?
Thanks in advance.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2018 03:32 AM
There are different views on this but I personally don't really like to alter ootb business rules but rather create copies of them and then deactive the ootb rule when the new one works.
As for what you are trying to do you wouldn't actually look in the busines rule itself to change it from using serial number instead of asset tag since it's using a AssetUtils which is a Script Include (see below). The only thing you would accomplish by changing asset_tag so serial_number in the condition-field is just change so that it triggers when serial_number is change and not asset_tag. In order to change the value you would either have to change the code in the script include or just create a new BR which accomplishes the same thing without changing an OOTB script include. The negative part to not use the script include is that if that function is used in some other business rule, script etc then you would get the asset_tag again and not the serial_number.
Anyway the code need to set the display name to serial_number + model should be the code snippet below. Now this doesn't take into account if the serial_number of model is missing so if both were missing you would just get a display name like " - " but a check like that can easily be added. You have one in the script include for example
current.display_name = current.serial_number + " - " + current.model.display_name;

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2018 03:59 AM
Hi Simon, this works, thanks a lot.
Just a question thou, how would I go about updating all the assets which have already been loaded with asset tag + model as display name?
The snippet works if I create a new asset, but how would I batch change loaded assets prior to changing the script?
Mind you, I have nearly 90k assets there, and would hate to reload everything.
Once again, thank you.