Populate the selected values from one screen to another screen

dhaval soni
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 15, 2013

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

2 votes
Answer accepted
RambanamP
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 18, 2013

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>

RambanamP
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 18, 2013

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

1 vote
Nitram
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 18, 2013

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 votes
Nitram
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 15, 2013

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.

dhaval soni
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 16, 2013

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


dhaval soni
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 17, 2013

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.

Nitram
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 18, 2013

Sure! Preparing your answer.

dhaval soni
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 18, 2013

Thanks Nitram. I am still looking into this.

0 votes
Nitram
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 15, 2013

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.

Nitram
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 15, 2013

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

dhaval soni
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 15, 2013

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

Can you please share example ?

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 15, 2013

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.

0 votes
Dipti Ranjan Behera
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 15, 2013

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

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 15, 2013

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

0 votes
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 15, 2013

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)

Suggest an answer

Log in or Sign up to answer