Hi all,
I'm trying to build an Initializer script in Behaviours that when the create issue (so should work with an issue create screen) window is opened (from the customer portal) reads the current Customer Request Type and hides/shows some fields. I'm having troubles in fetching the value of Customer Reuqest Type field. So far I have the current code:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.CustomFieldManager
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def optionsManager = ComponentAccessor.getOptionsManager()
def customField = customFieldManager.getCustomFieldObjectByName("Customer Request Type")
log.info("customField: " + customField)
def fieldConfig = customField.getRelevantConfig(getIssueContext())
def options = optionsManager.getOptions(fieldConfig)
log.info("options: " + options)
but at this stage it doesn't deliver any value in options when I open create issue window from customer portal:
2019-07-16 15:19:08,664 /rest/scriptrunner/behaviours/latest/jsd/jsd/validatorsByPid.json [c.o.j.groovy.user.FieldBehaviours] options: []
2019-07-16 15:19:08,663 /rest/scriptrunner/behaviours/latest/jsd/jsd/validatorsByPid.json [c.o.j.groovy.user.FieldBehaviours] customField: Customer Request Type
Any help?
Hi this suggestion worked for me if (getRequestTypeName() == 'IT Help')
hope this helps
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.
Hi,
The only way I've found is using this:
getFieldById("summary").getFieldBehaviours().properties.formContents.requestTypeId
It return the Customer Request Type ID.
I still have to write the code to retrieve the Request Type details that match this ID.
Hope this can help some other peoples and if someone have a better way, feel free to share.
JF
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you very much.
getRequestTypeName () is broken and causes a crash in the script when the logged in user to SD is a client, not an actor.
You don't even know how much trouble you saved me.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
LoL @Jacek Zarzycki , thank you as well.
I switched to @Mazen AKIKI [Infosysta] solution few days ago and didn't notice the bug you've just mentioned.
I definitely confirm that this:
String customerRequestTypeName = (getRequestTypeName())
Must be replaced by something like this:
import com.amundi.jira.ProjectPortal
import com.atlassian.jira.project.ProjectCategory
ProjectPortal projectPortal = new ProjectPortal(project)
String customerRequestTypeId = getFieldById("summary").getFieldBehaviours().properties.formContents.requestTypeId
String customerRequestTypeName = projectPortal.getRequestById(customerRequestTypeId.toInteger()).getName()
Note: I'm on Jira Software 8.5.6 + Jira SD 4.5.6
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
In order for the script to work with both Jira Service Desk and Jira Core "Create" use this:
import static MyUtil.MyFunctions.RequestTypeName
/*
RequestTypeName- Is my own function
This function convert diferente values like
"41"
"f3a26973-8692-4537-bc92-3516469e728f"
"XXX/f3a26973-8692-4537-bc92-3516469e728f"
"New Server"
It returns the string with the name "Request Name ABC" or ""
*/
static com.atlassian.jira.issue.IssueFieldConstants.SUMMARY
String tmpRequest = ""
String RequestTypeValue = ""
try {
def Summary = getFieldById(SUMMARY)
tmpRequest = Summary.getFieldBehaviours().properties.formContents.requestTypeId.toString()
}
finally {
RequestTypeValue = RequestTypeName(tmpRequest)
}
// User does not use Service Desk but Jira Core "Create" or "Edit"
// if you try validate tmpRequest here it want work
if ( RequestTypeValue == "") {
try {
def RT = getFieldByName("Request Type")
tmpRequest = RT.getValue().toString()
}
finally {
RequestTypeValue = RequestTypeName(tmpRequest)
}
}
if (RequestTypeValue == "Request Name ABC" ) {
do something ...
}
I'm on Jira Software 8.5.4 + Jira SD 4.5.4
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.
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.