Customer Portal: Sign-up should ask for Company / Group

Dear all,

I'm trying to setup Service Desk 2.0 for Evaluation and I would like to add "Company/ Group" as pre-filled values upon Customer Signup, so I can easily divide tasks based on the reporter - his company.

Am I blind or is there no, or at least none easy to find, option for that?

 

thanks,

Matt

3 answers

1 accepted

1 vote
Accepted answer

Hi Matt,

Below is the script we use. As said, this script relies on the fact that we (manually) assign "customer" groups to users. The script tries to match the customer group of a user with the customers defined in JIRA and set a custom field if a match is found.

Hope it helps.

Geert

 

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.customfields.manager.OptionsManager
import com.atlassian.jira.security.groups.GroupManager
import com.atlassian.jira.security.JiraAuthenticationContext
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.atlassian.jira.issue.ModifiedValue
def compAccessor = new ComponentAccessor()
def customFieldManager = compAccessor.getCustomFieldManager()
def optionsManager = compAccessor.getOptionsManager()
def groupManager = compAccessor.getGroupManager()
def authContext = compAccessor.getJiraAuthenticationContext()
// Retrieve all the customer companies known in JIRA
def customerField = customFieldManager.getCustomFieldObject(10403 as Long)
// do not set the field if it already has a value
if (!customerField.getValue(issue)) {
    def fieldConfig = customerField.getRelevantConfig(issue);
    def optionObjects = optionsManager.getOptions(fieldConfig);
    def optionList = optionObjects.getRootOptions()
    def companies = new HashSet()
    // Retrieve String values from the Option objects
    for (option in optionList) {
        companies.add(option.getValue())
    }
     
    // Retrieve the groups the current user has
    def user = authContext.getUser()
    def groups = groupManager.getGroupNamesForUser(user) as Set
     
    // Determine the overlap in companies and groups
    // 0 -> unknown customer (or mismatch in group/customer name)
    // 1 -> match: set the customer field
    // > 1 -> undetermined, do nothing
    def company = companies.intersect(groups)
    if (company.size() == 1) {
        // get the matching Option object
        def selectedOption = null
        for (option in optionList) {
           if (option.getValue() == company[0]) {
               selectedOption = option
               break
           }
        }
        def changeHolder = new DefaultIssueChangeHolder();
        customerField.updateValue(null, issue, new ModifiedValue(issue.getCustomFieldValue(customerField), selectedOption),changeHolder);
    }
}

Hi Matt,

You could use the Domain of reporter field from the JIRA Toolkit plugin. This field is derived from the reporter's email address. If your customers signup with their company mail addresses, you could use this to divide the tasks.

We have a slightly different use case, where we authorize our customers to access the Service Desk using groups. To know which company a reporter belongs to, we use the Script Runner to match the group the reporter is in with our known customers and setting that value in a custom field Customer. If you are interested I can provide you with the script.

Regards,

Geert

I'd love to see this as well.

Dear Geert,

for the Domain, that's a great idea but would only solve about 50% of my cases,
in the remaining 50% the domain of the mail is equal but still different "company".
Because we are using the domain group-wide and some daughter companies have the same domain even for me they are different companies / groups.

If you can share your script I would love to try it out.

 

Thanks,

Matt

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Aug 13, 2018 in Jira Service Desk

Jira Service Desk – Don’t be afraid, the journey begins with curiosity!

...be more productive while being fun to use at the same time. For some, getting started can be a bit intimidating. This is especially true if Jira Service Desk is your first exposure to Atlassian...

36,318 views 13 39
Read article

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