My validatation method works great locally, but not on standalone instance.
public void validateFromParams(CustomFieldParams relevantParams, ErrorCollection errorCollectionToAddTo, FieldConfig config) { // not sure why running with the SDK this value is present... Issue passedIssue = (Issue) relevantParams.getFirstValueForKey(ISSUE_KEY); //likewise on SDK running locally I get 3 values here // value //issue // boolean issueRequired
//but only 1 in actual instance - the value. for (String key : relevantParams.getAllKeys()) { log.warn("====================KEY: {}",key); } if(null != passedIssue){ log.error("Unable to get the current issue during Edit, cannot validate !!"); errorCollectionToAddTo.addError(fieldName, "There is an issue with the Reservation system, please report to Support. You may clear this field to save other updates."); return; }
IN SDK instance running locally I get:
INFO] ====================KEY: null
[INFO] ====================KEY: issue
[INFO] ====================KEY: requireProjectIds
and I can cast that Param to a real Issue and get project and other feilds.
BUt when I run in our test standalong instance I only see the null key, and cant get value.
014-03-24 12:51:52,038 http-bio-8080-exec-9 ====================KEY: null
Similar questions
https://answers.atlassian.com/questions/58011/custom-field-validation-how-to-get-an-issue-instance
Community moderators have prevented the ability to post new answers.
FOUND IT!
Upgrade to JIRA 6.2.1 and its working.
2014-03-24 16:39:37,008 http-bio-8080-exec-21 WARN n0158588 999x425x1 xabnj2 10.103.91.63,127.0.0.1 /secure/QuickEditIssue.jspa [jira.customfields.slots.BookableDateTimeCFType] ====================KEY: null
2014-03-24 16:39:37,008 http-bio-8080-exec-21 WARN n0158588 999x425x1 xabnj2 10.103.91.63,127.0.0.1 /secure/QuickEditIssue.jspa [jira.customfields.slots.BookableDateTimeCFType] ====================KEY: issue
2014-03-24 16:39:37,008 http-bio-8080-exec-21 WARN n0158588 999x425x1 xabnj2 10.103.91.63,127.0.0.1 /secure/QuickEditIssue.jspa [jira.customfields.slots.BookableDateTimeCFType] ====================KEY: requireProjectIds
I suspect they must have updated the method I referenced in my comment.
Well, I think I'm gonna have to wait a bit.
I'm still with 6.1.2...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
FOUND IT!
Upgrade to JIRA 6.2.1 and its working.
2014-03-24 16:39:37,008 http-bio-8080-exec-21 WARN n0158588 999x425x1 xabnj2 10.103.91.63,127.0.0.1 /secure/QuickEditIssue.jspa [jira.customfields.slots.BookableDateTimeCFType] ====================KEY: null
2014-03-24 16:39:37,008 http-bio-8080-exec-21 WARN n0158588 999x425x1 xabnj2 10.103.91.63,127.0.0.1 /secure/QuickEditIssue.jspa [jira.customfields.slots.BookableDateTimeCFType] ====================KEY: issue
2014-03-24 16:39:37,008 http-bio-8080-exec-21 WARN n0158588 999x425x1 xabnj2 10.103.91.63,127.0.0.1 /secure/QuickEditIssue.jspa [jira.customfields.slots.BookableDateTimeCFType] ====================KEY: requireProjectIds
I suspect they must have updated the method I referenced in my comment.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I found the method in JIRA core that filters out the parameters, but not sure if we can override.
CustomFieldImpl
//------------------------ HELPER METHODS ---------------------------// /** * Returns custom field parameter from the given map that are relevant to this custom field. * * @param params map of parameters * @return custom field parameter from the given map that are relevant to this custom field */ protected CustomFieldParams getRelevantParams(Map<String, String[]> params) { final CustomFieldParamsImpl customFieldParams = new CustomFieldParamsImpl(this); for (final Map.Entry<String, String[]> entry : params.entrySet()) { final String key = entry.getKey(); final String customFieldKey = CustomFieldUtils.getCustomFieldKey(key); if (key != null && getId().equals(customFieldKey)) { String[] p = entry.getValue(); if (p != null && p.length > 0) { for (int i = 0; i < p.length; i++) { if (p[i] != null && p[i].length() > 0) { customFieldParams.addValue(CustomFieldUtils.getSearchParamSuffix(key), Arrays.asList(p)); break; //exit for loop } } } } } return customFieldParams; }
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I had though of something like that, but since I have more prioritaries issues, I have left it for later: and now you reminded me.
But what I thought was a bit different:
instead of a visible input; use a hidden, just like I use for the fieldId; and don't forget to set the name as fieldId[:key]. Something like this:
<input id="custom-field-id" value="$issue" type="hidden" name="${field_uid}:key">
Here you will have the issue in the key "key". Feel free to use the name of your convenience (or none at all, and will appear in the null key). I haven't tried this because I would have to make a special case for this.
Tell me if it worked, so I can try it as well.
Luck
Edit: fixed a typo in the example HTML. I meant value="$issue"
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I found I can expose Issue directly as a field via the velocity template
#if($issue)
<input class="text medium-field datepicker-input" id="issue" name="issue" type="text" value="$issue" />
#end
But it still doesnt make it back to the Validate method!!!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Voted; let's hope we can get to the kind heart of Atlassian :-)
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.
Community moderators have prevented the ability to post new answers.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.