Validate the name of an asset
I need to write a validation that ensures the name of an asset starts with an "A". Normally I can write startsWith(attributes.'FieldName'.first(),("A"), message:"Must start with A"). But I cant figure out what to call the asset name. I have tried Name, Full Name, and Display Name. Any ideas?
Thanks
S Benson
Posted 1 year ago · Edited 1 year ago·Last reply 1 year ago
7 comments
Laurenz Hiller
·1 year ago · EditedHi @scottbenson
the names of an asset (Full Name, "Display" Name) aren't attributes of the asset. Therefore, you cannot call them using "attributes.X". Instead you can call them by just referring to displayName (or name, if you want to use the full name instead). Please check my answer in this thread for some more details.
S Benson
OP1 year ago@laurenzhiller1 Thanks for the great response. Do you also know how I can access an asset's status? I need to perform certain validations based on an asset's status.
Scott
Laurenz Hiller
·1 year ago · EditedYou just need to replace name by status in the example above.
S Benson
OP1 year ago@laurenzhiller1 Thats what I thought but it doesn't work. I don't have the exact script in front of me, but I have a "given" clause, followed by a "when" that looks something like: startsWith('status'.first(),("Canceled"). I've also tried startsWith(attributes.'status'.first(),("Canceled") - but neither seems to find assets with that status.
Thanks again
Laurenz Hiller
·1 year agoJust use status without any ' or .first() or attributes.
S Benson
OP1 year ago@laurenzhiller1 I tried your idea and it doesnt work. The validation does not recognize the "canceled" status.
Grant Rollerson
·1 year agoExamples are here, including some against *asset name* Validation script examples