I am trying to build a URL that prepopulates fields on a JSM form.
I have a select list field and a custom asset field that I want to populate using the following format:
<jiraBaseURL>/servicedesk/customer/portal/<id>/create/<formid>?customfield_xxxxx=<value>&customfield_yyyy=<key>
In this format, customfield_xxxxx
represents the select list field. Although it works when I provide the option ID instead of the actual value, validation fails for the issue, resulting in an error requiring the field to be filled even when there is a value prepopulated in the field.
Additionally, customfield_yyyy=<key>
is the asset field, and <key>
represents the object key. However, this does not populate any values in the field.
Please suggest a way to prepopulate the custom fields using a URL in the JSM portal form
Does this article help you ?
Regards
Thank you @Florian Bonniec
I did go over the link but the link do not have the answer I was looking for.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Base on the documentation Asset is not supported.
If you have script runner you could try to get the url content and force the field to be populated.
import com.atlassian.jira.component.ComponentAccessor
def url = request.getHeader("referer")
def url_params = url.substring(url.indexOf("?") + 1)
def string_params = url_params.tokenize('&')*.tokenize('=').collectEntries()
string_params.each{ k,v ->
if(getFieldById(k.toString()) != ''){
getFieldById(k.toString())?.setFormValue(v.toString())
}
}
You will probably have to create a function to get the proper content to set instead v.toString()
Regards
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I will try to run the script on the environment.
What does 'k' and 'v' refer to in the script?
Thank you.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
k is the field id ex customfield_XXXXX
v is the value set in the url customfield_XXXXX=YYYY
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.