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

Matthias Paul Bachler September 15, 2014

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
Answer accepted
Geert Graat
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 15, 2014

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);
    }
}
1 vote
Geert Graat
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 15, 2014

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

BrianBeaulieu October 22, 2014

I'd love to see this as well.

0 votes
Matthias Paul Bachler September 15, 2014

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
TAGS
AUG Leaders

Atlassian Community Events