Need a custom field to automatically take value from another field

Hi,

I have an urgent requirement wherein i want my custom field "Original Planned Date" to automatically take value from another custom field "Planned Start Date" and "original Planned Date" should be read only.So if i edit "Planned start date" then whatever value it gets should automatically appear for "original planned date" which should be non-editable as i mentioned above.

Please suggest some alternatives for this and if nothing in scopoe then i'll go for plugins. Please suggest plugin as well if there i sno other alternative.

10 answers

This widget could not be displayed.

Use a scripted field from the "Script runner" plugin.

You can't do this in native Jira, so you'll need a plugin no matter what - if you write a function to duplicate the data or just show it on-screen (a scripted or derived field - not actually stored in the database, but looks like a read-only field, can be searched and so-on). The Script Runner provides a framework for doing a lot of the clever things plugins can do and saves you a LOT of work.

Hi Nic,

Could you please guide the steps that i need to follow to achieve this.

I'm just a novice in jira.

1. Download and install 'Script Runner' from the marketplace. (It isn't available for OnDemand)

2. Create a custom 'Scripted Field' in JIRA

3. Go to the Add-Ons tab in JIRA and under the Script Runner section click on Scripted Fields, and then click edit on the field you created.

4. You can use the JIRA API and follow some of the examples in the Script Runner documentation. Sometimes the preview button is a little touchy so you may have to refresh the page before actually doing a preview.

This widget could not be displayed.
Joe Pitt Community Champion Jun 16, 2014

Another option would be to use the copy field from the jira suite utilities IF the Planned Start Date is required at creation time. Then use the copy field post function to copy it to the original planned date field and only display that field on the View screen.

Hi Joe,

Could you stepwise mention the steps that i would need to follow. I have almost fair undertsanding about jira its worflows and transitions.

So you can mention the steps precisely. But it would be of great help to me if you list the sequential steps.

Would probably work providing no one changed this field, or you had a listener that copied the field wherever it might change.

Hi Joe,

There is slight change in the requirement here.

Could you please assist me on this.

The change is that for the first time "Original Planned Date" should take value from "Planned Start Date". Later on this "Planned Start Date" can be edited and made to take any value during lifecycle of issue but "original plannecd date should retain its initial value forever and as i mentioned it should be read only field which as per your suggestions is perfectly correct to be in view screen. But the trouble is that post function will change value of "Orinigal Palnned Date" everytime there is change is "Planned start Date".

Is there any solution on how to fix the value of "Original Planned Date" to retain its initial value that it got from "Planned Start Date" during first transition post function throughout the issue lifecycle?

Please provide me some solution on this.

This widget could not be displayed.
Joe Pitt Community Champion Jun 16, 2014

first install the jira suite utilities. put the planned start date on the Creation screen and set it to required in the field configuration. Define the Original date field and make it usable by the project/issue and place it on the View screen. Add the copy field post function in the transition during creation. FYI, JIRA allows separate Create, View, and Edit screens. As their names imply, the create screen is used during issue creation and often has fewer fields. Edit is used when the edit function is invoked. The View screen is for fields you don't want to be to entered or edited except in transitions or post functions.

Hi Joe,

Many thanks for your suggestions. Will surely try out this.

Will come back to you if any further help needed.

This widget could not be displayed.
Joe Pitt Community Champion Jun 17, 2014

Ashley,

Post functions are unique to the transition, not the fields involved. If you put it on the transion from the create screen to the Open status as I originally said it will only execute that one time. The user can then change the planned date field later through the edit screen or another transition without updating the original date.

Hi Joe,

Actually i wanted to say like i have a transition from say Approve Request->waiting wherein there is a validator that "Planned Start Date" manadatory to be filled so here if somebody updates it then resulting post function will for first time copy that value for "Original Palnned date" but this transition might need to be executed several times during issue lifecycle so i fear it will change value for"Original Planned Date" everytime this transition is executed

Please let me know your suggestions on this.

This widget could not be displayed.
Joe Pitt Community Champion Jun 17, 2014

An easy work around is to have 2 transitions that look at the value of the original field. If the field is blank allow the transition and execute the post funtion, if it has a value don't. For the other transition; if it has a value allow it, but don't put the post function in that transition and don't allow the transition. this way you get the result you want and the user will only see one transition.

Hi Joe,

Actually i wanted to say like i have a transition from say Approve Request->waiting wherein there is a validator that "Planned Start Date" manadatory to be filled so here if somebody updates it then resulting post function will for first time copy that value for "Original Palnned date" but this transition might need to be executed several times during issue lifecycle so i fear it will change value for"Original Planned Date" everytime this transition is executed

Please let me know your suggestions on this.

Hi Joe,

Could you also help me on one more thing.

Like you mentioned 'If you put it on the transion from the create screen to the Open status as I originally said it will only execute that one time' here i would like to see that in my workflow open is coming as step not under transition scolumn so how can i avail the facility to edit that as transition and add my post function.

BR,

Ashley

Hi Joe,

I really appreciate your workaround.

But could you please elaborate it with a small example stepwise so that i can implement it for my project.

Would really need your help on this.

Many thanks,

Ashley

Actually open is the first state my ticket will have so i can only edit transitions that originate from open status. But open status is the status that my issue gets into once created. so how can i add post function to a transition that drives the issue to open status(here issue creation).

Also if i am correct we can add propert to open step but i don't know what prioperty key and value to use.

Could you help me on this.

I'm not much skilled in jira.

BR,

Ashley

This widget could not be displayed.
Joe Pitt Community Champion Jun 17, 2014

start by building 2 identical transitions. In #1, use the condition function when defining it to test to see if the Original field is empty and add the post function to copy the planned field. In #2 test to see if the orginal field is not empty and don't add the post function. then when you go through the transition if the orignal field is set you will only transition #2 as an option, but if it isn't set you'll see transition #1. I would name the transitions slightly different, perhaps with a period at the end so you can easily tell which one is available but would look the same to the users. You can find how to add a condition in the JIRA workflow documentation.

Hi Joe,

I can't see any condition under my transition in my jira hosted web app(6.1.3) wherein it gives me option to select "execute if given custom field is empty" or execute " if given custom field is not empty".

How should i then add condition?

Also could you suggest me how can i add post function to a transition that drives the issue to open status(here issue creation) because open status would be first status in my workflow so i can't see any transition where i can ad post function that results in open state.

This widget could not be displayed.

Hi,

There should be a condition "Value Field". You can use it to Add required parameters to the Condition.

Or you can use scripted condition to check the value is not null.

Vijay

Hi Vijay,

I don't see any suvch condition.

Please send me screenshot of any such condition if you have

Hi,

Sorry first option is not available for the date fields.

Second option holds true still.

I added a simple scripted condition and it worked well for date fields.

cfValues['Detected on Date'] == null

Put this condition on transition and it will not allow the transition if the field has a value.

Vijay.

Hi Vijay,

Under Value Field condition what shopuld i select for following parameters:-

Field: Original Planned Date

Condition:<,>,<=,>=,=,!=

Value:

Comparison Type:string,number,optionid

Select Condition : !=

Value : <leave it blank>

Comparision Type : String

Hi Vijay,

The problem is that under field drop down it doesn't list any date custom field.

What to do now?

This widget could not be displayed.
Joe Pitt Community Champion Jun 18, 2014

I'm not sure what is available on a OnDemand intance. I only have experience with local installs on our servers. I'm not supporting JIRA at my current assignment so I can't send any screen shots. You may need the jira suite utilities, but I believe they are available in the OnDemand systems

Hi Joe,

I would like to mention here that related to custom field we have only one condition that is "Allow to execute a transition if the given value of field is equal to a constant value or simply set" and on choosing that i get following parameters:-

Field:

Condition:<,>,<=,>=,=,!=(drop down options)

Value:

Comparison Type:string,number,optionid(drop down options)

I don't know how to use it to execute what you suggested but i would very much like to use your suggestion because i like that suggestion.

Please help me on this somehow.

This widget could not be displayed.
Joe Pitt Community Champion Jun 18, 2014

Ashley,

Have you triedthe = or != tests for an empty field as a string?

Yes Joe i just tried by making a dummy field initially non-empty and added in the condition using =. Post function for this that date field copies value from another date field.

Next i made similar transition with almost similar name and again used this dummy field with != condition but this time no post function.

So my purpose got served .

many thanks for your help.

Really appreciate that!

Will look forward to more suggestions from you with other questions coming p..

Have a nice day!

BR,

Ashley

This widget could not be displayed.
Joe Pitt Community Champion Jun 18, 2014

Glad to help.

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted yesterday in Jira

Atlassian Research Workshop opportunity on Sep. 28th in Austin, TX

We're looking for participants for a workshop at Atlassian! We need Jira admins who have interesting custom workflows, issue views, or boards. Think you have a story to sha...

54 views 2 2
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