Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Validation in the transition to check ticket has an attachment with file name (RAM) and format

Ravi Kumar Boddu
May 9, 2023

Hi All,

Need help to implement transition validation with JIRA MISC WORKFLOW EXTENSIONS

  • Validate whether the ticket has an attachment with the specified file name 
  • Validate the specified file is in excel format.

Please share your thoughts on this how to implement this? Also, https://community.atlassian.com/t5/Jira-Software-questions/Use-Case-Verify-Attachment-Type-When-Transitioning/qaq-p/1631128 I tried this but this is limited to transition screen and this is not working for me :)

Any help would be appreciated and TIA

2 answers

1 vote
Danyal Iqbal
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Champions.
June 19, 2018

forget the above script.

Workaround:

* create project version field as a checkboxes type field and add all options.

* use a behaviour to hide project versions based on the project picker field.

Thomas Hardin
Contributor
June 19, 2018

Do you have an example? Maybe a sample snippet of code?

Danyal Iqbal
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Champions.
June 20, 2018

You should be able to find a proper example here:

https://scriptrunner.adaptavist.com/latest/jira/behaviours-overview.html#_examples

 a js snippet to hack away if you have had enough with jira and doing things the proper way:

<script type="text/javascript">
source=document.getElementById('customfield_15428')//project field
if (source) {
      if (source.value == 21544)//check value of project field
{
$('#customfield_14401-2').parent().hide() //14401 is the project version field & 14401-2 is the second option
$('#customfield_14401-3').parent().hide() //14401 is the project version field & 14401-3 is the second option
}
 source.onchange=function() {
          if (this.value == 21544) {
$('#customfield_14401-2').parent().hide() //14401 is the project version field & 14401-2 is the second option
$('#customfield_14401-3').parent().hide() //14401 is the project version field & 14401-3 is the second option

                  }

          if (this.value != 21544) {              
//so something on change here as well :)
                  }
            
      }
  }
an so on
}

put this in the description of any text field on the page.

Like Network Operations likes this
0 votes
Thomas Hardin
Contributor
June 26, 2018

Good morning,

I've made some strides with this effort, but am not quite there yet. I've taken some examples from the community and have been able to populate my versions field with the applicable values from a particular project, but that value was placed in the script. I am still missing a piece where I can use the actual value from the project picker. My thought is that I need to somehow define the field value, but I can't seem to figure it out. Here is the latest code:

def issueManager = ComponentAccessor.getIssueManager()
def optionsManager = ComponentAccessor.getOptionsManager()
def customFieldManager = ComponentAccessor.getCustomFieldManager()

//Define Project Name custom field
def projectName = getFieldByName("Project Name")
def projectNameField = customFieldManager.getCustomFieldObject(projectName.getFieldId())
def projectNameConfig = projectNameField.getRelevantConfig(getIssueContext())
def projectNameOptions = optionsManager.getOptions(projectNameConfig)
String projectNameValue = projectName.getValue()

//Define Project Version custom field

def projectManager = ComponentAccessor.getProjectManager()
def project = projectManager.getProjectObjByName("Websites (Core)")

def versionManager = ComponentAccessor.getVersionManager()
def versions = versionManager.getVersions(project)


def versionOptionsFld = getFieldByName("Project Version")

versionOptionsFld.setFieldOptions(versions)

 

As you can see, when I use a static value in the code, "Websites (Core)", I am able to populate the Versions drop down field. This works. I just need to somehow, get the value from the project picker field , "Project Name", to be the source of that data.

 

Thank you all for the continued support. Any help is always greatly appreciated.

Suggest an answer

Log in or Sign up to answer