Hi everyone
I’ve created an automation where, when a user creates an issue and enters a device name in a custom field, the automation checks the IT hardware asset sheet for a matching device name.
If the device name matches an existing asset, the automation simply adds a comment saying the device name matches and takes no further action.
If the device name does not match, the automation creates a new asset record with that device name.
My current challenge is adding a condition to validate the device name format. For example, if the device name entered doesn’t follow the required pattern (like starting with “ABC” followed by digits, e.g., ABC1245
), the automation should fail, notify the user that the device name is invalid, and not create a new asset.
I’m struggling to design the correct structure using “If → Else” conditions to make this work properly.
this: is the condition {{issue.customfield_xxxx.trim.match("^ABS\\d{5}$")}}
would be much grateful for any ideas I can write down the whole structure i have
Step | Action | Details |
---|---|---|
Trigger | Issue Created or Field Changed | Device name field |
Action | Lookup rows/issues | Filter: deviceName = {{issue.fields.deviceName}} |
Condition (if/else) | If lookup count > 0 | Device exists → Do nothing or comment |
Else | Create asset | Use device name from issue |
Add comment | "New asset created with name: ..." |
Hello @Shi
Welcome to the Atlassian community.
I recommend that you use an Else-if to validate the name provided in the issue against a regex. If the name is acceptable, execute the Create Object action. Then the final Else handles reporting that the name was invalid.
That’s strange I am not able to see more than one else in an IF branch - so using IF or else
gives me only one else and this is my main problem I wonder if this is the license am using?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
No, there is no difference in this functionality based on the license.
Can you provide a screen image of what you see?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
this is all I can see
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
FYI am on the premium plan
so not sure if that feature is only on enterprise plan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I tried to add same structure manually could not find a way but - when I ask the jira AI to do it by if else if then else than that worked
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The manual way:
At the point where you want to and the If-ElseIf-ElseIf-Else:
Click Add component
Click IF: Add a condition
Click IF or ELSE: Add condition options
Add a Condition
Click the Add Component button directly below that IF in the diagram on the left and add an action
Click the Add Else button below that.
Click the Add Condition button in the dialog on the left, then select a condition. Notice that a new Add Else button appears in the diagram on the left.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This clears a lot
sorry for the delay
I have attached a screenshot of the layout iv done but the automation stills fails as the last else still creating an object in jira asset regardless what is the input so the idea that if if I add anything other than ABC followed by 6 numbers I only get that comment device name is wrong - and nothing is added in the asset , but if the user enters a correct device name then automation should lookup this device if it match I get comment saying it match and it won’t add a new device name
in case the device name entered correct and it does not match what’s in the asset sheet the automation then should add a new device name and give me that comment that device name was added successfully
so here am using only one custom field where the user enters the device name
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks Trudy
your lay out was actually perfect
so first trigger value change with custom field
then
IF
match regex
lookup in asset
then
else if
Lookup object greater than 0
then add comment device already exists
then
else
then create object in schema
then comment wrong device name
that worked perfectly
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello @Shi
Just to make sure there has not been a misunderstanding, can you provide screen images that show your entire rule from the beginning? The images you showed in you next to last reply and the text you put in your last reply indicate a flow that does not match my recommendation, and I am concerned that it will not work as you intend.
I think the "If match regex then lookup objects" should not be part of the IF-Else block.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you @Shi . The structure of your rule looks correct.
I suggest changing one last thing. In this comparison:
Instead of {{lookupObjects.size}} I recommend that you use
{{lookupObjects.size|0}}
That says if lookupObjects.size is null then use "0" for the comparison. Comparisons to null can have unexpected results.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello @Shi
Dont struggle with it, do the following:
Set a validation on the Name attribute in your asset object using regex.
Then use your automation to check if it was able to create the object, and if not, send a message to the requester.
much more simple and clear.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
That won't work.
When the validation fails and the object can't be created, that will cause an error to occur in the rule and none of the steps after that will be executed.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.