Good morning.
I am trying to add automation that tests an issue reporter's membership in a customer organization.
I'm using the OrganizationService is com.atlassian.servicedesk.api.organization and the getById method, where I pass in the reporter's ApplicationUser object and specific customer organization IDs I wish to test against.
I'm getting a response of 'sd.customer.organisation.error.user.no.view.permission : 'You do not have permission to view this organization'
This response makes sense to me, the reporter I am passing in is not yet trusted. That is what I am trying to determine.
How can I, as a trusted automation/administrator, query the customer organization membership of the reporter?
Hi James,
The use of the OrganizationService.getById() seems ok, but I am not sure that gives you the result you want
Quoting their javadocs (which make no sense)
/**
* Checks whether the user is an agent or a member of the organization. True if
* - valid licensed,
* - is a member if the organization
*
* @param user the user who you want to check
* @param organizationId the ID of the organization you want retrieve.
* @return the organization.
*/
But I believe the error you get it may has to do with permissions that the logged in user has (or in your case has not) and not the reporter
Apart from that could you please try the following script (check your logs for the debug messages or errors )?
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.servicedesk.api.organization.OrganizationService
def loggedInUser = ComponentAccessor.jiraAuthenticationContext.getLoggedInUser()
def issue = ComponentAccessor.issueManager.getIssueByCurrentKey("ATG-1") //the issue to get the reporter from
def reporter = issue.reporter
def organisationService = ComponentAccessor.getOSGiComponentInstanceOfType(OrganizationService)
def organizationQuery = organisationService.newOrganizationsQueryBuilder().serviceDeskId(1).build()
def organizationsInProjectResult = organisationService.getOrganizations(loggedInUser, organizationQuery)
if (organizationsInProjectResult.isLeft()) {
log.error organizationsInProjectResult.left().get()
return
}
def organizationA = organizationsInProjectResult.right().get().results.find {it.name == "OrgA"}
log.debug "Organization is $organizationA"
def usersInOrganizationQuery = organisationService.newUsersInOrganizationQuery().customerOrganization(organizationA).build()
def usersInOrganization = organisationService.getUsersInOrganization(loggedInUser, usersInOrganizationQuery)
if (usersInOrganization.isLeft()) {
log.error usersInOrganization.left().get()
return
}
def isUserInOrganization = usersInOrganization.right().get().results.find {it.key == reporter.key} ? true : false
log.debug "Is user in organizaion ? $isUserInOrganization"
Regards, Thanos
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.