Hi,
I have a service desk portal with multiple forms. I have a specific form which I want to be visible to users, but the user should NOT be able to click "create"
I have tried adding a script on the Create transition of the service desk workflow, but nothing happed.
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.servicedesk.api.requesttype.RequestTypeService
import com.onresolve.scriptrunner.runner.customisers.PluginModule
import com.onresolve.scriptrunner.runner.customisers.WithPlugin
@WithPlugin("com.atlassian.servicedesk")
@PluginModule
RequestTypeService requestTypeService
def currentUser = ComponentAccessor.jiraAuthenticationContext.loggedInUser
def query = requestTypeService.newQueryBuilder().issue(issue.id).build()
def requestType = requestTypeService
.getRequestTypes(currentUser, query)
.results
.first()
def requestTypeName = requestType?.name
return requestTypeName != "Test request form"
Is there any way this could be done ? I don't want to restrict the form, because that will completely hide it from the portal.
Hi @Aisha M
The standard approach to hiding UI Elements via ScriptRunner for Jira DC is to use the Fragment.
However, this is not supported in Jira Cloud as Jira Cloud doesn't have the Hide UI Element built-in script.
As an alternative, I suggest looking into the Issue Security schemes
Thank you and Kind regards,
Ram
Let me summarize your scenario to see if I read and understand your scenario correctly. You have a request on your portal that has a form and you want people to see it but not be able to submit it or create requests with it.
If that is a correct summarization, I have done it before in data center and cloud with a workaround since there is no easy, built-in way to achieve it. Note that we have already migrated so unfortunately I can't give you exact step-by-step instructions.
Basically, you need to add a new required question to the end of your form that has an impossible validation. For example, a checkbox or radio buttons that the required choice or number of choices cannot be true. In cloud, I can add a checkbox with no options but is still required. I think those are the most elegant ways to misuse validation but you could also have a text field with a maximum number of 0 characters.
You can experiment with different wording for the final question so you can convey why the request cannot be created.
I hope this helps and works for you!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Bret Jacobsen Lol, that sounds like a good workaround, but since my org is at a point where they are doing a customfield cleanup in preparation for the cloud migration, not sure if they would be okay. Let me check though
So coming back to your answer, is it more like creating a radio option with no value and then making it required on the form ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Aisha M, I understand that they may be at a point where they don't want any more changes to request types. But I believe this is the simplest, most effective way to prevent a specific request from being submitted.
You are correct. Creating a radio option with no value and requiring it would be another solution from the same bag of tricks.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
HI @Aisha M
Scripts don't apply on a JSM portal.
On Cloud there are no options to change UI items on the product.
Best solution is to set a validator on the create condition of the workflow used by the work type of the request based on a field required, just don't place this field on the request, so then it can't be created.
Or do place it on the request, but set a validator to be provided an option, that does not exist.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Marc -Devoteam- For now, the changes I want to implement is on the DC environment.
I cannot find a suitable validator, perhaps a JQL one to imply, customer request type != the form , in order for the create transition to happen
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
HI @Aisha M
Just use a field required validator, just use field from your system, that is not used in the create screen.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Marc -Devoteam- But the "Customer request type" is not a filed, rather the type of form. So, not sure how a field required validator would help.
Also, we have multiple other forms on the service desk portal. I don't want any of the other forms to be affected.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Aisha M
You are using form on request types, yes?
Request types are linked to an issue type, an issue type has a workflow linked, so on the create action of the workflow set a field required validator not used anywhere in a request or form.
This will prevent the create action of the workflow to be executed.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Marc -Devoteam- , I tried adding a JMWE "Field required" validator at the create transition for the request type field. But I get this warning that says "JSM fields might not work as intended" . . Is that okay ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Aisha M
This might not work as JWME conditions can be skipped by JSM.
Lets use another completely different approach, on the permission scheme used for the JSM space, remove "Service Space Customer - Portal Access" on the "Create Issue" permission.
This should prevent any portal user to create an issue.
You will see an error on the JSM project as an agent, but this can be ignored, as tis based on removing this permission.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Marc -Devoteam- But wouldn't altering the permission affect ALL the customer forms on the portal ? I want this limitation on only one form
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Aisha M
Yes it would.
The best option I can give then is use a User Validator, set the criteria, the the user is in a role, best is to think to limit this to the admin role.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello @Aisha M
I’d like to better understand the use case here.
For what purpose should the form be visible in the portal if users are not allowed to create requests from it?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Ugnius Aušra , We are in the process of migrating to Cloud. So, the form deals with app integrations with Jira. Despite the form having a NOTE on stop suggesting things are temporarily on hold, users still go ahead and submit the request. So want to disable to submit/create button.
We want the users to know the form exists, but just that requests cannot happen now
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
A couple of things might work.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Alan Bruce I did try the 1st option. But, it still creates the form even if the field is hidden. And I see a prompt that says "Set default value for hidden field" on the field edit page
Not sure if I'm doing it right, or if that's how its supposed to be . .
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yeah, that makes sense that it will not work because you have to provide a default value. The alternative would be to add a validator in the workflow that includes a field that is NOT on the form.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes, thats right. Hiding did nothing
And, adding a field validator on the workflow transition would impact the other forms on the Service Desk portal, wouldn't it not ? . . So, I'm at a loss
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
It would impact any other request types that are using the same workflow. You would have to create a unique workflow for this specific request type.
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.