Here is the code that I have so far:
import com.atlassian.jira.component.ComponentAccessor
import org.apache.log4j.Logger;
import org.apache.log4j.Level;
//log.setLevel(Level.DEBUG);
def xMultiSelectPtr = getFieldByName("xx_sfi_apps");
def xMultiSelectVal = xMultiSelectPtr.getValue();
log.info("xMultiSelectVal =====>"+xMultiSelectVal)
//xMultiSelectVal returns something like [1, 3, 6]
// If xMultiSelectVal.size() > 1//{Ask if user meant to choose more than one//}
I am trying to find a way to set the help text if the user chose more than one option.
Any help would be greatly appreciated!!! :)
...AnnaG...
Hi @annag,
I don't have any active script with me, but I'm modifying adaptavist script according to your requirement. I haven't tried in my system though, this may require minor changes.
import com.atlassian.jira.component.ComponentAccessor
import org.apache.log4j.Logger;
import org.apache.log4j.Level;
//log.setLevel(Level.DEBUG);
import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript
@BaseScrip FieldBehaviours fieldBehaviours
def xMultiSelectPtr = getFieldByName("xx_sfi_apps");
def xMultiSelectVal = xMultiSelectPtr.getValue();
log.info("xMultiSelectVal =====>"+xMultiSelectVal)
//xMultiSelectVal returns something like [1, 3, 6]
if (xMultiSelectVal.size() > 1){
xMultiSelectPtr.setLabel("Help text here")
xMultiSelectPtr.setDescription("Field Description here")
}
Here is the page from adaptavist for reference
Hope this gives you some idea
BR,
Leo
Thank you for your response!!! It gives an error on the .size() parameter, which is what I have been running in to. I have tried every option except for the correct one. Lol Here is a screenshot and I would appreciate any suggestion on how to resolve this:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
If you modify your getValue() code like below may fix your issue
def xMultiSelectVal = xMultiSelectPtr.getValue() as List
or you can iterate over the object and count them(mostly above one should fix your issue)
BR,
Leo
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You are Awesome!!! It is finally giving me the size. It doesn't show the help text (This is a behaviour in a Create/Update Issue screen). I will play with trying to display some type of message to the user. Basically, I want to call to attention that they chose more than one application and give them a chance to modify their selection. I was hoping for a Are you sure dialog box, but I have not found anything like this. Thanks so much!!!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Leo, your code worked purrfectly! I just missed seeing the help description. I will work on making it more prominent to the user. For anyone looking for the answer, this is the code that worked:
import com.atlassian.jira.component.ComponentAccessor
import org.apache.log4j.Logger;
import org.apache.log4j.Level;
//log.setLevel(Level.DEBUG);
import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript
@BaseScript FieldBehaviours fieldBehaviours
def xMultiSelectPtr = getFieldByName("xx_sfi_apps");
def xMultiSelectVal = xMultiSelectPtr.getValue() as List;
log.info("xMultiSelectVal =====>"+xMultiSelectVal)
log.info("xMultiSelectVal.size ------------->>"+xMultiSelectVal.size())
//xMultiSelectVal returns something like [1, 3, 6]
if (xMultiSelectVal.size() > 1){
log.info("******I am inside the If statement *******")
xMultiSelectPtr.setLabel("Help text here")
xMultiSelectPtr.setDescription("Are you sure you meant to choose multiple applications?????????????")
Thanks again!!!
...AnnaG...
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.