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

This widget could not be displayed.

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

This widget could not be displayed.

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

This widget could not be displayed.

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

This widget could not be displayed.

No. It is still a open question.

This widget could not be displayed.

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

Thanks.

This widget could not be displayed.

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

This widget could not be displayed.

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

This widget could not be displayed.

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

This widget could not be displayed.

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

This widget could not be displayed.

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
Community showcase
Posted Tuesday in Jira

What modern development practices are at the heart of how your team delivers software?

Hey Community mates! Claire here from the Software Product Marketing team. We all know software development changes rapidly, and it's often tough to keep up. But from our research, we've found the h...

87 views 0 1
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