Hi,
I am struggeling with a scripted workflow validation to check wether an attachment has been added on the create issue transition when using JIRA service desk´s customer portal.
EDIT: Actually I need to check if Attachments are added during issue creation ONLY if a custom fields has a specific value. Having this, simple solutions like the Field Required validation of JMWE plugin does not work in my case.
I found that the Script Runner plugin provides some very useful hints but the examples from adaptavist only seen to apply to the plain JIRA issue creation transition and not to the customer portal of the service desk.
I am running JIRA 7.4.2 with Service Desk 3.6.2 and Script Runner 5.0.14 and my validation script looks like this:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.IssueFieldConstants
import com.atlassian.jira.issue.attachment.TemporaryWebAttachment
import com.atlassian.jira.issue.attachment.TemporaryWebAttachmentManager
import com.opensymphony.workflow.InvalidInputException
import webwork.action.ActionContext
import org.apache.log4j.Logger
import org.apache.log4j.Level
def log = Logger.getLogger("de.agileworks.ValidateAttachments")
log.setLevel(Level.DEBUG)
log.debug "VALIDATING 1"
def temporaryAttachmentUtil = ComponentAccessor.getComponent(TemporaryWebAttachmentManager)
def formToken = ActionContext.getRequest()?.getParameter(IssueFieldConstants.FORM_TOKEN)
log.debug "VALIDATING 2 => " + ActionContext.getRequest()
if (formToken) {
log.debug "VALIDATING 2.1"
def tempWebAttachments = temporaryAttachmentUtil.getTemporaryWebAttachmentsByFormToken(formToken)
tempWebAttachments.each { TemporaryWebAttachment it ->
log.debug "VALIDATING 2.1.1"
log.debug "Uploaded attachment name: ${it.filename}"
}
log.debug "VALIDATING 2.2"
def attachmentSize = tempWebAttachments.size()
log.debug "VALIDATING 2.3 => " + tempWebAttachments.size()
if(attachmentSize >= 1) {
log.debug "VALIDATING 2.3.1 => SUCCESS"
} else {
throw new InvalidInputException(IssueFieldConstants.ATTACHMENT,"SIZE: " + attachmentSize + " - You must add an screen shot at this transition!!!")
}
}
log.debug "VALIDATING 3"
As already mentioned it works fine when creating issues from within JIRA:
2017-08-18 11:50:55,331 DEBUG [agileworks.ValidateAttachments]: VALIDATING 1 2017-08-18 11:50:55,332 DEBUG [agileworks.ValidateAttachments]: VALIDATING 2 => com.atlassian.plugin.servlet.PluginHttpRequestWrapper@625be7de 2017-08-18 11:50:55,332 DEBUG [agileworks.ValidateAttachments]: VALIDATING 2.1 2017-08-18 11:50:55,332 DEBUG [agileworks.ValidateAttachments]: VALIDATING 2.1.1 2017-08-18 11:50:55,333 DEBUG [agileworks.ValidateAttachments]: Uploaded attachment name: jira.png 2017-08-18 11:50:55,333 DEBUG [agileworks.ValidateAttachments]: VALIDATING 2.2 2017-08-18 11:50:55,333 DEBUG [agileworks.ValidateAttachments]: VALIDATING 2.3 => 1 2017-08-18 11:50:55,333 DEBUG [agileworks.ValidateAttachments]: VALIDATING 2.3.1 => SUCCESS 2017-08-18 11:50:55,333 DEBUG [agileworks.ValidateAttachments]: VALIDATING 3
But when I try to do the same via the customer portal it does not:
2017-08-18 11:58:08,555 DEBUG [agileworks.ValidateAttachments]: VALIDATING 1 2017-08-18 11:58:08,555 DEBUG [agileworks.ValidateAttachments]: VALIDATING 2 => null 2017-08-18 11:58:08,555 DEBUG [agileworks.ValidateAttachments]: VALIDATING 3
As you can see the if-block covering the formToken will be skipped and it seems that the request is null or empty.
Did anyone encounter this situation already? Any hint or workaround would be very much appreciated.
Best Regards,
Christian
as mentioned within my first reply above, I've been able to successfully implement the requested behaviour with the help of Jira Workflow Toolbox.
A matching use case is documented here.
Just please be aware of a known bug JSDSERVER-5781: you can only attach your custom error message to the end of the generic one and therefore have to select the Summary field at Field to show the message in the post function configuration.
Best regards,
Thorsten
Not trying to revive a dead topic here. I'm still struggling to find the answer. I've tried numerous plugins.. and doing this 3 different ways. A custom script, Universal Boolean Validation, and through JQL all of which fail.
I'm starting to think that an attachment is attached differently through the portal then when to an issue seeing as though a JQL validation isn't even working from the portal. All these methods work on all other places on the workflow except on create.
Does anyone have any suggestions on how to do this? (I am after the same exact thing I believe - Conditionally validating an attachment through the portal based on a CF single select field selection)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Steven Mustari,
having tested the use case documented here just now, I'd recommend having a look at Jira Workflow Toolbox, since it should solve your problem.
If you run into problems, feel free to ask.
Cheers,
Thorsten
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Thorsten,
are you sure this really works with JIRA Service Desk Portal as well???
If so, please convert your reply to an answer so I can mark it as solution to this question.
Thank you & Best Regards,
Christian
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Added my reply as a seperate answer.
Cheers.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hey do we have some way to check and scan the attachments in confluence, before they are uploaded and stop them with a message if it has sensitive data through script runner?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Prudhvi,
your reply to my question sounds like a whole new question and is moreover Confluence related while this thread is Service Desk related. Re-using existing questions for new topics is never a good idea.
I would recommend opening a brand new question instead - it´s dead-simple, believe me ;-)
Best Regards,
Christian
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hey thanks, I have opened one.
https://community.atlassian.com/t5/Confluence-questions/Confluence-groovy-script-to-scan-the-uploaded-file-for-sensitive/qaq-p/949219
Thank you
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You could try the JIRA Misc Workflow Extensions . There is a validator "Fields Required". You only add the field you want to validate and the error message if the validator fails.
Hope I helped
BR, Athina
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Athina,
thank you for your reply. I have the JMWE plugin installed but the Fields Required validation only provides a check against a single criteria (e.g. Custom Field) but not against a combination of criterias like CF 1 eq "A" AND File Attached during transition as I require. Or do I missed something?
Regards, Christian
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hey again,
Yeah, you can add 2 Fields required conditions or more.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I just had a look and yes you are right the Field Required validation can check multiple fields as required BUT NOT criterias like Attachment required if a CF have a specific value.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I have the same requirement and also would like a solution for this in Jira ServiceDesk.
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.