Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Verify attachment length Script Runner Cloud

Hi,

I created a Fast-track Post Function that verifies if there are any attachments on the Issue and if there aren't, it transitions the issue, this is what I have on the 

I tried with both conditions below but I had the same error.

021-06-08 16:55:42.661 ERROR - Cannot get property 'length' on null object on line 1
condition:issue.fields.attachments.length == 0
condition:issue.attachments.lenght == 0

 Any suggestions?

By the way,  issue.attachments.lenght is valid on the Expression Tester App.

Daniel

1 answer

Hi @Daniel Alonso , you have typo in your condition.

You have:

  • lenght 

but it should be

  • length 

I change it and it keeps showing the error:

2021-06-08 16:55:42.661 ERROR - Cannot get property 'length' on null object on line 1
2021-06-08 16:55:42.675 ERROR - Class: com.adaptavist.sr.cloud.workflow.FastTrackIssue, Config: [className:com.adaptavist.sr.cloud.workflow.FastTrackIssue, uuid:71369c1f-0147-4c52-b5de-899a697c2046, enabled:true, executionUser:ADD_ON, condition:issue.attachments.length == 0, description:, additionalCode:, comment:Attachment is mandatory, please review, transitionId:101, transitionName:Back to Hiring Manager, accountId:XXXX]

I also tried with a filter option that actually works on the Expression Tester but on the fast-track condition doesn't:

 

021-06-09 12:58:10.292 ERROR - startup failed:
Script1.groovy: 1: unexpected token: > @ line 1, column 38.
   issue.attachments.filter(attachment => attachment.mimeType == 'application/pdf').length > 0
                                        ^

1 error

2021-06-09 12:58:10.309 ERROR - Class: com.adaptavist.sr.cloud.workflow.FastTrackIssue, Config: [className:com.adaptavist.sr.cloud.workflow.FastTrackIssue, uuid:71369c1f-0147-4c52-b5de-899a697c2046, enabled:true, executionUser:ADD_ON, condition:issue.attachments.filter(attachment => attachment.mimeType == 'application/pdf').length > 0, description:, additionalCode:
, comment:Attachment is mandatory, please review, transitionId:101, transitionName:Back to Hiring Manager, accountId:XXXX]

 Screen Shot 2021-06-09 at 9.01.47 AM.png

Hi @Daniel Alonso I just tested it and if validator does not pass, email notification comes to my email inbox with message:

Selection_336.png

And my validator looks like:

Selection_337.png

Do you have similar configuration?

Thanks @Martin Bayer _MoroSystems_ s_r_o__ 

I cannot use a regular SR validator, or even a jira workflow validator/condition because I want to block an approval transition and right now it is not being blocked, even with a built-in validation/condition. That's why I used the Fast-track transition to catch if the issue doesn't have any attachment go back to the approval status.

Can you please try on your end using a Fast-track transition, then you will see what I'm talking about.

Thanks, Daniel

Suggest an answer

Log in or Sign up to answer
TAGS

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you