Help with creating a field that copies the value of another field and NOT be edited

Aisha M September 18, 2019

Hi,

 

I want to create a scripted date field (FIELD 1) that copies the value of another date field (Due Date).

But, after issue creation, the field FIELD 1 must be LOCKED. 

 

Can someone please help me with how to achieve this . thank you 

1 answer

0 votes
Joe Pitt
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 18, 2019

Only put the new field on the View screen. 

Aisha M September 18, 2019

@Joe Pitt  Thank you for the comment !

Okay, but how I copy the value of the Due date field to the new field and then lock the new field ?

Ravi Sagar _Sparxsys_
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.
September 18, 2019

In the new scripted field write this code.

issue.dueDate

May be 2 more configurations if you are dealing with date field.

Searcher: Date Time Range picker
Template: Date Time

You may need to add more code to handle errors. It is bare minimum.

Ravi

Aisha M September 18, 2019

@Ravi Sagar _Sparxsys_  Thank you for the comment.

I have not written scripts. 

does the above line copy the field value to the new field. But how do I ensure that that the value entered first is fixed

Joe Pitt
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 18, 2019

There are some plugins, I use jira suite utilities (JSU) to copy fields during a transition. JIRA has the ability to copy some fields. I don't know if due date is one of them. The plugins expand the list of fields. You must copy to another date field. JIRA has no way of 'locking' a field. that is why I said to only put the new field on the view screen. The only way to update it would be with a script or post function. A user can't edit it. 

Like Andrew Laden likes this
Ravi Sagar _Sparxsys_
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.
September 18, 2019

Hi @Aisha M 

Yes that is the job of the scripted field, it will have the due date. What do you mean by "..value entered first is fixed"?

I should have asked, why are you doing this? What is your objective?

Ravi

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.
September 18, 2019

With @Ravi Sagar _Sparxsys_ 's answer, he mentions a "scripted field" - these are created by Adaptavist's ScriptRunner, and don't contain editable data - they calculate something (even if it's just a copy of the data of another field) and expose it as a field, but it can't be edited, even if you put it on the edit screen.

There are other apps that can do something similar.  I'm less familiar with them because I work for Adaptavist too, and hence just use SR 99% of the time.

Aisha M September 19, 2019

@Ravi Sagar _Sparxsys_ 
Hi . I mean to say the new field must copy the first DUE DATE value entered. Later, if the DUE DATE is changed, the new field must NOT take the new value. Basically, the first value copied must be fixed.

We want to do this for some certain tracking purposes. 

 

Thank you

Ravi Sagar _Sparxsys_
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.
September 19, 2019

Now it is clear. In that case use a post function to update the "Original Due Date" custom field not a scripted field. What you are doing is baselining. Also take a look at some apps like BigPicture or Portfolio, these have such features built in but for the time being post function should do the job.

Aisha M September 19, 2019

@Ravi Sagar _Sparxsys_ But how do I make sure that the new field value when someone changes the Due Date ? What conditional statement should I use for this. Can you please help.

Thank you !

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.
September 19, 2019

The post-function runs at a certain point in the workflow.  If you do not go through that transition again, the value in the field will not change.

Suggest an answer

Log in or Sign up to answer