You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
The Atlassian Community can help you and your team get more value out of Atlassian products and practices.
Hi
I have following code to set field as required and the following code works as expected:
import com.onresolve.jira.groovy.user.FormField
FormField num = getFieldByName("Change Request Number");
num.setRequired(true)
I would like to write a wapper class around to avoid duplicate code every where.
Created groovy file called FieldAttr.groovy in behaviourutil folder
package behaviourutil
import com.onresolve.jira.groovy.user.FieldBehaviours
import com.onresolve.jira.groovy.user.FormField
@BaseScript FieldBehaviours fieldBehaviours
def showRequired(String field) {
log.info("inside showRequired...." + field);
FormField sField = getFieldByName(field)
sField.setRequired(true)
}
Issue is with following code, where trying to import above groovy code
import behaviourutil.FieldAttr
def d = new FieldAttr()
d.showRequired("Change Request Number");
This gives me following error:
Script function failed on issue: (create issue) project/issuetype: fieldId: customfield_11122, file: <inline script>
java.lang.NullPointerException: Cannot invoke method getFieldIdByName() on null object
at com.onresolve.jira.groovy.Behaviour$getFieldIdByName$2.call(Unknown Source)
at com.onresolve.jira.groovy.user.FieldBehaviours.getFieldByName(FieldBehaviours.groovy:53)
at com.onresolve.jira.groovy.user.FieldBehaviours$getFieldByName.callCurrent(Unknown Source)
at behaviourutil.FieldAttr.showRequired(FieldAttr.groovy:19)
at behaviourutil.FieldAttr$showRequired.call(Unknown Source)
at Script1.run(Script1.groovy:5)
Community moderators have prevented the ability to post new comments.