Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,559,187
Community Members
 
Community Events
184
Community Groups

How to set a length size on a custom field using scriptrunner behaviour in Jira cloud

I'd like to set a size in a custom field. I need allow only 65 characters

2 answers

Hi @Jyoti Mane 

Just to confirm, you're using Behaviors for Cloud, right?

I'm not sure if you will be able to do that, but other possible option would be using validators and setting this restriction in the create transition.

Go to Project Setting > Workflows

Edit the workflow for the affected issue type

Switch to Diagram mode

On Create transition, click on the Validators

Choose Add Validator > Regular Expression Check

If you would like to restrict the field to a specific length:  enter [0-9]{n}$

(n) reflects your desired field length.

You just need to set this on the required workflow transition (ideally after the initial field input is required)

(Originally posted here: https://community.atlassian.com/t5/Adaptavist-questions/How-do-I-set-a-character-limit-on-a-custom-field-using/qaq-p/762038)

try this

 

def formField = getFieldById('customfield_XXXX')
def value = formField.getFormValue() as String
//formField.setAllowInlineEdit(false)

    if ((value).length() > 65 ) {
        //formField.setRequired(true)
        formField.setError("Max number of characters is 65")
    } else {
        formField.clearError()
        //formField.setRequired(true)


    }

Thanks @Joel Batac 

This code did not work in ScriptRunner Behaviours for JIRA Cloud.

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 04, 2023

I'm afraid Jira does not yet support SR's abilities to do a lot of things in Cloud, but we are working with Atlassian to try to get this sort of stuff added.

Like # people like this

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
PERMISSIONS LEVEL
Site Admin
TAGS
AUG Leaders

Atlassian Community Events