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.

0 votes
Eddie Webb Community Champion Mar 23, 2014

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

0 votes
Eddie Webb Community Champion Mar 23, 2014

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

0 votes
Eddie Webb Community Champion Mar 23, 2014

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 Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

2,991 views 12 18
Join discussion

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
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot