HI,
I have written a customfield extending TextCFType . I override method
public void validateFromParams(CustomFieldParams relevantParams,
ErrorCollection errorCollectionToAddTo, FieldConfig config)
Here i want to put validation logic based on current project and issuetype. But i do not find any api to get those details from parameters.
Can anybody suggest a solution?
Regards,
Vijaya Kumar Reddy
Hi Vijay,
You can use ComponentAccessor to retrive the projects and issue types. Hope this helps you. You can use it by importing ComponentAccessor in the class.
-Patina
Actually what I see is a map of the keys defined this way (as the tiny-comment-no-one-seems-to-read-before-removing-and-fails-to-appear-in-any-other-tutorial-or-documentation advices to do):
fieldId + ':' + key
This bundles all values from the same key and creates an entry like key => [values]
if your inputs have the name only fieldId, they go to the null key.
So I have my own keys, and that's it; no issue nor way to find it; nada, rien, niente. I'm working in a standalone server.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I was mistaken, the value I saw locally was "requireProjectId" - but non idea where it came from. - do you only see the "null" param?
SDK Locally
[INFO] [talledLocalContainer] ====================KEY: null [INFO] [talledLocalContainer] ====================KEY: issue [INFO] [talledLocalContainer] ====================KEY: requireProjectIds
Test Standalone
[INFO] [talledLocalContainer] ====================KEY: null
Also the issue you linked to ius resolved - can't vote for it, and likely ignored by support. I cloned to a new ticket and cited the quesitons I have found here - https://jira.atlassian.com/browse/JRA-37627
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hmm, I have filled the code with logs, but have seen no issue around.
Where do you say "requireIssue" is to be set?
I found an ancient RFE[1] from 2009 with this very request. Maybe if we gather enough votes they do something...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Users of JIRA 6.2.1 (and above?) can get this from the passed Params.
public void validateFromParams(CustomFieldParams relevantParams,ErrorCollection errorCollectionToAddTo, FieldConfig config) { Issue passedIssue = (Issue) relevantParams.getFirstValueForKey(ISSUE_KEY); // safety catch 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; } ... }
See my other question for the cautionary tail https://answers.atlassian.com/questions/276206/issue-missing-from-relevantparams-in-customfield-validate for JIRA versions < 6.2.1
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi, I have the same problem. I want to know current project and issuetype in the validateFromParams when I create an issue. I installed my custom field into JIRA 6.3.4 and tried to debug. There is no issue in the relevantParams. When I edit an existing issue, I can see com.atlassian.jira.internal.issue_id. But there is nothing during the creation. Any advice would be helpful. hiro
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I was able to get this from Issue issue = (Issue) revelantParams.getFirstValueWithKey("issue");
But I changed somehting and that key, along with "requireIssue" are missing. I assume "requireIssue" is specified somewhere as true will make it come back, but I hanvent found where yet.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi, I need to validate the issue's status and can't get the issue in MyCustomFieldType.validateFromParams(). Has anyone found a solution?
Thanks.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
No. It is still a open question.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Did you found a solution? Having the same problem...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Rambabu,
It looks you misunderstood my query. I want to get current issue's project and issuetype in validateFromParams method. is there a way?
Regards,
Vijaya Kumar Reddy
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Vijay,
Is your question is to get the issue from the params? If you are able to get the issue then you can get current issues project and issue type using Issue.getProjectObject() and getIssueTypeObject().
Thanks,
Rambabu
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
If you are able to get the issue
That's exactly what I'm trying to do...
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.