How do I restrict text to 100 characters of a custom field via the JIRA API?

Please post the sample code for better understandings. I am pretty new to plugin development and jira.

2 answers

1 vote

Depends - are you using an existing field? Are you writing your own field? Do you want to do it in html, or just validate the length after the user posts something? Or drop the extra characters?

As an aside, you probably won't get sample code here. We prefer you to understand what you're doing than parrot code that someone else has made the effort to learn/write etc.

I am using an existing field that is out of the box. I want to restrict to 100 characters only to a specific project . I want to do it in a simple way so that it is easy to apply in different environments. This needs to be done before posting . I have tried javascript but it didn't work. This what I tried in Javascript

<script type="text/javascript">
customLimitField = document.getElementById("customFieldId_10900");
customLimitField.onKeypress = limitText;
function limitText(){
customLimitField = document.getElementById("customFieldId_10900");
if(customLimitField.text.length >= 50)
customLimitField.value = customLimitField.value.substring(0,50);

Please help me to understand this and fix it.

Javascript is not a perfect solution. I wrote my own custom field and restricted to 100 characters using the API and sample code from google.

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Posted Wednesday in Jira

Join our webinar: How 1B+ feature flag events helped us build the new Jira

Every time you release software, there's a bit of risk – that there's a bug, that something breaks, or that the feature doesn't resonate with customers. Feature flagging helps make high stakes s...

100 views 0 1
Join discussion

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you