Attempting to run it through the Script Runner console, what could the issue be?
Both JIRA and Confluence are linked to each other with oAuth(not impersonated), and both have green light for connectivity.
Full error:
com.atlassian.applinks.api.CredentialsRequiredException: You do not have an authorized access token for the remote resource. at com.atlassian.applinks.oauth.auth.ThreeLeggedOAuthRequestFactoryImpl.retrieveConsumerToken(ThreeLeggedOAuthRequestFactoryImpl.java:93) at com.atlassian.applinks.oauth.auth.ThreeLeggedOAuthRequestFactoryImpl.createRequest(ThreeLeggedOAuthRequestFactoryImpl.java:86) at com.atlassian.applinks.core.auth.ApplicationLinkRequestFactoryFactoryImpl$AbsoluteURLRequestFactory.createRequest(ApplicationLinkRequestFactoryFactoryImpl.java:180) at com.atlassian.applinks.api.ApplicationLinkRequestFactory$createRequest.call(Unknown Source) at Script3.run(Script3.groovy:64)
Hi Kelvin
That's a fairly basic use case.
def fieldA = getFieldByName('User Picker A')
def fieldB = getFieldByName('User Picker B')
def currentField = getFieldById(fieldChanged)
fieldA.clearError()
fieldB.clearError()
if(fieldA.value == fieldB.value){
currentField.setError("Please select a different user. $currentField.value was already used.")
}
Put this script in the server-side script for both fields.
It will set an error message in the most recently modified field and clear the error if either fields are corrected.
Adjust for your actual field names (of change to getFieldById('customfield_xxxxx'))
Hi Peter.
Thank you so much for the assist. I've tested the script and it is working perfectly.
Kind regards,
Kelvin
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Peter,
Just a follow up question, I noticed when both fields are empty the error would appear. Is there a way for the error not to appear when both fields are empty?
Thanks.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
If you only want to validate when the fields are not empty, you can add some logic like this:
if(fieldA.value && fieldB.value){
if(fieldA.value == fieldB.value){
currentField.setError("Please select a different user. $currentField.value was already used.")
}
}
or combine it:
if(fieldA.value && fieldB.value && fieldA.value == fieldB.value){
currentField.setError("Please select a different user. $currentField.value was already used.")
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Good afternoon. I would be very grateful for help with the question of how to compare the user selection field with the multiple selection of users. and if there is a match, issue an error message. cannot be done on its own.
an example of an article where the fields are compared with the user's choice.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Here thus I try to compare on matches of a field of a multiple choice of users. but i lack skills
import com.atlassian.jira.component.ComponentAccessor
// Get a pointer to my custom fields
def SelectList1 = getFieldByName("customfieldname")
def SelectList2 = getFieldByName("customfieldname2")
def currentField = getFieldById( fieldChanged )
SelectList1.clearError()
SelectList2.clearError()
// Get the Value of My Select Field
def selectVal1 = SelectList1.getValue() as String
def selectVal2 = SelectList2.getValue() as String
// If the first option is selected in the multi select list then make the text field required.
SelectList1.getValue().each {
if(selectVal1.contains(selectVal1) == selectVal2.contains(selectVal2)) {
currentField.setError( "Пожалуйста, выберите другого пользователя. Значение $currentField. уже было использовано." )}
}
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.