Hello there,
In my Jira workflow, I'm using the JMWE plugin validator for Sub: Task issue type (Field Required Validator). In this, I'm only making the "Time Spent" field required for particular groups, which means that only those group members need to fill out the "Time Spent" field.
And I configured this condition, and it works perfectly; see the condition below.
issue.get("issuetype")?.name == "Sub: Task" && (ComponentAccessor.getGroupManager().isUserInGroup(currentUser, "Siva Apple1") || ComponentAccessor.getGroupManager().isUserInGroup(currentUser, "Siva Apple2") || ComponentAccessor.getGroupManager().isUserInGroup(currentUser, "Siva Apple3"))
But I need to make a minor change to this condition so that the "Time Spent" field in Sub:Task is only required when parent is Story type."
And I tried configuring the script below, but it didn't work. Please assist me in resolving this issue where I'm missing a step and I'm not a script specialist. Please guide me on this and your help appreciated.
(issue.get("issuetype")?.name == "Sub: Task" && parentIssue.get("issuetype")?.name == "Story") && (ComponentAccessor.getGroupManager().isUserInGroup(currentUser, "Siva Apple1") || ComponentAccessor.getGroupManager().isUserInGroup(currentUser, "Siva Apple2") || ComponentAccessor.getGroupManager().isUserInGroup(currentUser, "Siva Apple3"))
Thanks,
Siva.
Hi @siva
The reason why this script didn't work is because the parentIssue variable only exists in the context of workflow extensions that relate to the parent issue of the current issue.
In other cases, to access the parent of the current issue, use:
issue.parentObject
Thus to test the parent issue's issue type:
issue.parentObject?.get("issuetype")?.name == "Story"
Thank you for your prompt response, and I have replaced the script with the
issue.parentObject?.get("issue type")?.name == "Story"
And when you try to move the status, it displays the error notice shown in the screenshot below. And here's the script I used in the validator. Please advise me on this matter.
(issue.get("issuetype")?.name == "Sub: Task" && issue.parentObject?.get("issue type")?.name == "Story") && (ComponentAccessor.getGroupManager().isUserInGroup(currentUser, "Siva Apple1") || ComponentAccessor.getGroupManager().isUserInGroup(currentUser, "Siva Apple2") || ComponentAccessor.getGroupManager().isUserInGroup(currentUser, "Siva Apple3"))
Thanks,
Siva.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @siva
Sorry, autocorrect on my phone added a space between "issue" and "type" in my snippet. I have corrected it above.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you very much for your assistance; the script works flawlessly, and I greatly appreciate your assistance.
Thanks,
Siva.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.