How to get current project and issuetype in method validateFromParams method in my customfield plugin

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

10 answers

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

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

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

If you are able to get the issue

That's exactly what I'm trying to do...

Did you found a solution? Having the same problem...

No. It is still a open question.

Hi, I need to validate the issue's status and can't get the issue in MyCustomFieldType.validateFromParams(). Has anyone found a solution?

Thanks.

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.

https://answers.atlassian.com/questions/276206/issue-missing-from-relevantparams-in-customfield-validate

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

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

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...

[1]https://jira.atlassian.com/browse/JRA-19321

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

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.

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published 2 hours ago in Jira

5 ways you can make the most of Jira Software and Bitbucket Cloud

As part of the Bitbucket product team I'm always interested in better understanding what kind of impact the use of our tools have on the way you work. In a recent study we conducted of software devel...

13 views 0 3
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you