
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-14-2016 02:42 PM
Hello, Is there a way to set a default value ONLY if certain conditions on the record are true?
As an example, I want to set a default value on an Asset Tag ONLY if the CI type is not a network adapter or storage.
Thanks!
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-04-2016 08:51 AM
Yes, you can do that with an After business rule.
conditions: Is Virtual is true
script: set your default value here
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-14-2016 03:17 PM
Hi,
You can use a client callable script include function that returns the value based on the condition.
something like javascript: getDefaultAssetTag()

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-04-2016 08:46 AM
Hi Venkat, I am having a timing issue with this solution. The record needs to be created first and then the default value needs to be set.
I want to set a default value on an asset tag if the "Is Virtual" flag is FALSE.
The record must be created with the is virtual flag first then the default value can evaluate the condition. Is there a way I can do that with an "after" business rule?
Thanks!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-04-2016 08:51 AM
Yes, you can do that with an After business rule.
conditions: Is Virtual is true
script: set your default value here

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-04-2016 11:34 AM
One note about Abhinay's response - I would change this from an AFTER business rule to BEFORE.
BEFORE rules are generally used to manipulate the current object, then you get an implicit update following it.
current.u_my_field = 'Some value';
AFTER rules are generally used to manipulate other records (typically they will have a GlideRecord query in there somewhere) AFTER your record has been updated. If you put the current.u_my_field statement in an AFTER business rule, it will require a current.update() to get it saved to the database. current.update() is going to retrigger ALL the business rules again for that record - wasting a lot of time and generating a Recursive Business Rule error.
FYI - The condition remains unchanged.