Calculate the Display Name value on an asset

booher04
Tera Guru

I'm trying to calculate the Display Name value on an asset, but I need it to be different based on model category.   For example:   I need the Display name to be different for the model category "vehicle", all the others can stay the same.   Right now, Display Name is a calculated field with :

current.display_name= current.ci.manufacturer.getDisplayValue() + '   ' + current.model.getDisplayValue() .  

This works to pull the Manufacturer and the Model into the Display Name, but I tried adding in a business rule to change this if the model category is "vehicle" change field value "Display Name" to:

current.display_name= current.u_number.getDisplayValue() + ' ' + current.u_vehicle_year.getDisplayValue() + ' ' +current.ci.manufacturer.getDisplayValue() + '   ' + current.model.getDisplayValue()

It basically blanks out the Display Name if the model category is vehicle, but if it's not vehicle the Display Name value displays as it should.   Is it possible to do this?   Does this need to go into the script section under the Advanced tab instead?

6 REPLIES 6

tanumoy
Tera Guru

You can not use both. Either you have to go with the Business Rule or calculated value.


Thanks for the reply.   That's what I was afraid of.  



So in order to get the display name value to work how I need it to, can I put a script together with an if/else statement on a business rule?   Unless you have any ideas on a better way to pull that information?   I need the Display Name to pull the Manufacturer and Model for all assets other than when the model category is "Vehicle", then it needs to pull Number, Vehicle Year, Manufacturer and Model.  


In this case Business rule with that if/else statement is the best option I believe.


current.display_name= current.u_number + ' ' + current.u_vehicle_year + ' ' +current.ci.manufacturer.getDisplayValue() + '   ' + current.model.getDisplayValue()




I assume that the u_number and the u_vahicle_year are not reference field. So, getDisplayValue is not required. Above code will give you the result.


Just put the condition properly, it will work.