I have been researching different ways to show certain users as VIPs and it doesn't look promising. We would specifically like to see this on the Create Issue Screen as well as the other issue screens. This would help our agents know if they are talking to a VIP as soon as they take the call and input their name.
I am wondering if you can use a ScriptRunner Scripted Field to automatically pull the reporter that you enter and check if they in a few certain groups and display the result right on the Create Issue Screen.
I do not have a lot of experience with writing code but I can follow along.
It also doesn't necessarily have to be ScriptRunner either. Anything that can accomplish what we are looking for would be great!
We are running Jira 8.2.3 and Jira SD 4.2.3 and Scriptrunner is close the latest and can be easily updated.
Thanks!
Hi,
Do you already have the users mapped out somehow? Probably in a group?
If so, you could use Script Runner Behaviours.
It's an easy method of assessing Jira forms and making decisions/changes based on the field values.
I'm thinking something of a Read only field, or maybe even a checkbox.
As soon as the form Loads, the behavior should check the reporter, if that reporter is part of the "VIP" group, then it should either write the Read only field or maybe check a box "VIP Customer"
I don't currently have them mapped out but yes I was thinking of using groups such as VIP, Internal, External, etc.
When you say, "As soon as the form loads", are you saying as soon as the reporter field is filled out or when the issue is created? I'm looking to for it to reflect the information immediately on the create issue screen while they are still talking to the user and filling out ticket details.
This sounds promising though. We already have a behaviour setup to only allow certain priorities depending if the user is in a certain group. I just wasn;t sure how we would use that to display something new on the screen.
Again, not much of a coder so I could use some help on that.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Now I understand that the agent, while on the phone call creates the issue for the user.
In that case I would add a checkbox field named "Type".
Example values = "Internal", "External", "VIP".
Add a behavior for the specific project/issue type
Add a server script for field Reporter
The basic script would look something like this (tested)
import com.atlassian.jira.component.ComponentAccessor
def groupManager = ComponentAccessor.getGroupManager()
def group1 = groupManager.getUserNamesInGroup('jira-administrators')
def reporter = getFieldById("reporter").getValue()
if(group1.contains(reporter)){
getFieldByName("Type").formValue = 10202 //checkbox option of VIP
}else{
getFieldByName("Type").formValue = ""
}
Of course you would need to enhance this script based on your field name and also some if/else or switch cases based on multiple user groups.
Hope this helps
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Okay so I think I'm close but I cannot get this to work. I made the script a server side script for the reporter field but do I need an initialiser also?
Scriptrunner does not give any errors for the script.
It does not update the field on either the create or view/edit screens.
import com.atlassian.jira.component.ComponentAccessor
def groupManager = ComponentAccessor.getGroupManager()
def ITManagers = groupManager.getUserNamesInGroup('Jira-Managers-IT')
def VIP = groupManager.getUserNamesInGroup('Jira-VIP')
def ITDev = groupManager.getUserNamesInGroup('Jira-Dept-Dev')
def ITSP = groupManager.getUserNamesInGroup('Jira-Dept-SP')
def reporter = getFieldById("reporter").getValue()
if(ITManagers.contains(reporter)){
getFieldByName("User Priority").formValue = "IT Manager" //checkbox option of VIP
}else if(VIP.contains(reporter)){
getFieldByName("User Priority").formValue = "VIP"
}else if(ITDev.contains(reporter)){
getFieldByName("User Priority").formValue = "IT"
}else if(ITSP.contains(reporter)){
getFieldByName("User Priority").formValue = "IT"
}else{
getFieldByName("User Priority").formValue = ""
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I think your problem lies in the values. If you use formValue you need to specify the select option ID. You can find this in the URL when you try to edit the value of an option.
Take a look at the value I used.
In case you want to use the text values I believe you need to query over the possible options of the custom field, for that context.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I also tried using:
getFieldByName("User Priority").setFormValue("IT Manager")
I definitely need it to fill out a Text box because if I do checkboxes it will fill up too much of the page. I'm not sure where to go form here though.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Would it be feasible to do it with a "Select List (single choice)" field and make it read-only?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Okay, so I remade the custom field as a "Select List (single choice)" with a few options. Added them to the create and view/edit screens for a Service Desk project. Created a new Behaviour with no Validator plugin, no guide workflow, and no initialiser. Added a server-side script for the Reporter field. Edited each custom field option to get the option value id at the end. Mapped it to all issue types for the project.
Here is the script (it gave no errors):
import com.atlassian.jira.component.ComponentAccessor
def groupManager = ComponentAccessor.getGroupManager()
def ITManagers = groupManager.getUserNamesInGroup('Jira-Managers-IT')
def Fed = groupManager.getUserNamesInGroup('Jira-Oversight')
def VIP = groupManager.getUserNamesInGroup('Jira-VIP')
def ITDev = groupManager.getUserNamesInGroup('Jira-Dept-Dev')
def ITSP = groupManager.getUserNamesInGroup('Jira-Dept-SP')
def reporter = getFieldById("reporter").getValue()
if(ITManagers.contains(reporter)){
getFieldByName("User Priority").formValue = 10502
}else if(Fed.contains(reporter)){
getFieldByName("User Priority").formValue = 10504
}else if(VIP.contains(reporter)){
getFieldByName("User Priority").formValue = 10503
}else if(ITDev.contains(reporter)){
getFieldByName("User Priority").formValue = 10505
}else if(ITSP.contains(reporter)){
getFieldByName("User Priority").formValue = 10505
}else{
getFieldByName("User Priority").formValue = ""
}
It does not update the field before or after creating the ticket.
Then, I created a custom field called Type as a Checkbox field with the only option as VIP. Used the script from above and changed only the group and value.
It did not work. Is there something I'm missing on my end?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I have created a custom field "User Priority" of type "Checkboxes".
I have configured a Behavior and added a Server Side Script on the "Reporter" Field.
This script executes correctly for me on the Create Issue Screen.
Can you check again? (Type of Custom Field and if correct Group Names)
import com.atlassian.jira.component.ComponentAccessor
def groupManager = ComponentAccessor.getGroupManager()
def group1 = groupManager.getUserNamesInGroup('jira-administrators')
def group2 = groupManager.getUserNamesInGroup('jira-software-users')
def reporter = getFieldById("reporter").getValue()
if(group1.contains(reporter)){
getFieldByName("User Priority").formValue = 10200
}else if(group2.contains(reporter)){
getFieldByName("User Priority").formValue = 10201
}else{
getFieldByName("User Priority").formValue = ""
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Doesn't seem to be working for me.
Created the Checkbox Custom Field named User Priority and attached it to the proper screens:
Grabbed the values from the options:
Created the Behaviour:
Tested with users in the software and admin groups:
And nothing happens. Even if I create the ticket, it doesn't check the box on the view screen.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Try and change the mapping type from Service Desk, to project/issuetype
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Success! Thank you!
Is there a way I can make this read only so that they cannot change it?
Thanks!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Sure, you could either add a mapping for the custom field, or simply append this line after setting the custom field value
getFieldByName("User Priority").setReadOnly(true)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
While that does work, it makes the field yellow. Is there a way around that?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Forgot to put in the boolean argument.
What do you mean yellow? Does not happen to me
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I think this is normal greyed out. Maybe you want to set it hidden then?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.