Populate the selected values from one screen to another screen

How can we populate the selected values from one screen to another screen as below:

1. create isssue screen - multiselect custom field , selected 3 values from 50 values.

2. In one of workflow transition screen want to appear these three values (selected while create issue screen) to appear in textbox or multi select control. It should be non editable fields.

How it could be possible ?

Through scripted field or any other way ?

NOTE: don't want to use same control.

6 answers

1 accepted

try with the following code by adding in field description or in plugin

<script type="text/javascript">
jQuery(document).ready(function($) {
	JIRA.bind(JIRA.Events.NEW_CONTENT_ADDED, function (e,context) {
		callEditFunction();
	});
	callEditFunction();
	
function callEditFunction(){
		var editFunction=$('#edit-issue-submit').val();
		var issueType = $("#type-val").text();
		var afterTrim = $.trim(issueType);		
		//change issue type name
		if(editFunction === 'Update' && afterTrim == 'Bug') ){
		//changes custom field id's, following ids are related to text/textarea fields 
		$('#customfield_14310').val( $.trim($('#customfield_13532-val').text()));
		
		}
	}

});
</script>

if this is what you expecting then accept as answers so it will close it!!

Hi,

Once you have created the issue, We are going to take the values from the view screen, while you do a transition or edit, the values wil be read from the view screen, so make sure, you have the fields in the view screen.

I will explain the code below

getValue(($('#customfield-val').text()).trim());

The "#customfield-val" is the ID of the source field, It will be like "#customfield11450-val"

if(AJS.$('#transitionscreenButtonId').val() == "somevalue"){

Here "#transitionscreenButtonId" is nothing but destination screen button Id, ex "#edit-issue-submit"

AJS.$('#destinationcustomfield').val() = val;

Here "#destinationcustomfield" is nothing but your destination custom field.

Hope this Helps!


0 vote

I'm not sure I understand the question here, but I *think* what you're asking for is a field that *displays* data without allowing edit on a transition screen?

On that assumption, then yes, you will need a scripted field. I used to use the "velocity" fields in the Jira toolkit to do this because they could pull data from a field and render it as a non-editable area, but they don't exist any more. So you will need a simple "display field X" scripted field. (Or write a view-only field plugin that pulls data from the actual data field and displays it no matter what mode the screen is in)

you can create a read-only field and populate it with selected multi-select field values through a post-function

This is not an ideal solution, as you'll be duplicating data in the read-only field.

You'll also need to think about maintaining it, which pretty much rules out a post-function unless you can bee 100% sure that your field will never be edited and only ever changed on transitions.

As Dhaval already suggested, a scripted field that reads and displays the data at the time that the screen is drawn (when it's reading and preparing for edit already) is a much better solution

Hi,

You can write a JS Plugin which will pull data from the actuall data field which is present in the view issue page, from there you can copy it to the destination field where it resides.If you want some example please let me know will help you.

Hope this helps.

No, Not in description, but a plugin itself. will explain with a example.

Create a maven plugin

write a JS file inside that

Add few lines of code to atlassian-plugin.xml

do a maven package to create a .jar file

Add or upload it to JIRA plugins

Do you mean to write javascript on descritption to achieve this ?

Can you please share example ?

Or, instead of .js and having to call out to other screens, write a .vm file that can use the issue context that's already on the current screen and display a field from there. Will need a couple of lines of java too.

Create a plugin,

write a javascript code as below,

jQuery(document).ready(function($) {
    JIRA.bind(JIRA.Events.NEW_CONTENT_ADDED, function (e,context) {
        getValue(($('#customfield-val').text()).trim());
    });
    function getValue(val){
               if(AJS.$('#transitionscreenButtonId').val() == "somevalue"){
         jQuery(document).ready(function($) {
     JIRA.bind(JIRA.Events.NEW_CONTENT_ADDED, function (e,context) {
        AJS.$('#destinationcustomfield').val() = val;
     });
});
         )
    }
});

In your atlassian-plugin.xml add the following

<web-resource key="getValue-js" name="transition">
        <description>gets a value from view and sets a value in xxxxx transition screen
        </description>
        <resource name="getValue.js" type="download"
            location="templates/js/getValue.js" />
        <context>atl.general</context>
    </web-resource>

Add the .jar to the plugins

Hope this helps.

Thanks for the example stuff.

Have some queries on this, how this stuff will do assign values for related issue as it seems, it will execute from javascript and no issue ID is there to assign source field to destination field for particular issue and it will execute on every time for all project and issue type.

To use this stuff as i understand, i suppose to keep - source field customfield-val as "customfield_11237" i.e. multiselect field.

For destination, i'll add one multi line textbox - "destinationcustomfield" as "#customfield_11238".

For #transitionscreenButtonId will be the create issue button ID.

Please correct me if any thing wrong i understand to replace and about query.

Thank You


Many thanks on this script but, i have some queries as below to use this.

It would be really great if you have help me out.

So, i have following fields in CREATE ISSUE screen,

MULTI SELECT list, Date picker control

these needs to copy and appear as read only in EDIT issue screen and transition screen

(also, not to use same custom field as in create issue screen, these will be duplicate readonly field). (basically, i have a screen like - REVIEW type , where just matching - EXPECTED and ACTUAL bussines fields).

so,in above given stuff, i suppose to replace - "transitionscreenButtonId" with "#create-issue-submit" ID of create issue screen. //only for EDIT screen, i want to copy fields which are entered in CREATE screen then how i should use.

When this "NEW_CONTENT_ADDED" event gets executed ?

#customfield-val // is this a source field and have to give its ID example: #customfield-11450 OR its view screen value like '-val' ?

pleaes let me know on this so, i could use it accordingly.

Sure! Preparing your answer.

Thanks Nitram. I am still looking into this.

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Julia Dillon
Posted Apr 17, 2018 in Jira

Tell us how your team runs on Jira!

Hey Atlassian Community! Today we are launching a bunch of customer stories about the amazing work teams, like Dropbox and Twilio, are doing with Jira. You can check out the stories here. The thi...

767 views 2 19
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