Developing anything on Jira Service Desk is hard. Each time you need to worry which user is accessing your panel / page. Some endpoints work only for Jira users, so you need to use service desk specific rest API to handle customers. But there is a special case of customers: Jira users with site access only.
Documentation is clear: “A user who has no application access is also considered a customer.”
And every Service Desk view seems to follow this principle. Such users can do everything what customers can, so we should treat them the same. Now to the point, how as app developers, can we check if a user has site-access only?
Let’s try to figure it out for serviceDeskPortalRequestCreatePropertyPanels module.
- It seems that a customer has a prefix in accountID, so we can use it:
const isCustomerLoggedIn = async () => {
const myself = await createRequest(`${REST_API_3}/myself`);
return myself?.accountId?.startsWith('qm');
};
So far, so good, but it doesn’t solve our problem with site-access only users , because such users don’t have the qm prefix.
- Lets try new feature released recently. AP.user.getCurrentUser returns now accountType
AP.user.getCurrentUser(user => console.log(user.accountType));
Now login with site access only user
Quick check in the console and we get: “atlassian”
Dead end
- So maybe, use conditions! You can use condition in query parameters: Context parameters
3 conditions seems to be promising:
** servicedesk.is_agent
** servicedesk.is_customer
** can_use_application
Let’s try it out, add it to url in atlassian-connect.json and then console.log on server side
"url": "/customer-portal/request?requestTypeId={servicedesk.requestTypeId}&serviceDeskId={servicedesk.serviceDeskId}&isAgent={condition.servicedesk.is_agent}&isLicensed={condition.addon_is_licensed}&isCustomer={condition.servicedesk.is_customer}&hasSiteAccess=condition.can_use_application(jira-core)"
Unfortunately we will get nothing useful:
{
requestTypeId: '46',
serviceDeskId: '1',
isAgent: '',
isLicensed: 'false',
isCustomer: '',
hasSiteAccess: 'condition.can_use_application(jira-core)'
}
I give up for now, maybe you know how to solve this mystery?