"Add Post Function To Transition applicable that We can report for the number of days between the creation date and the closed date."

Hi,

We want to add Post Function To Transition applicable that we can report  for the number of days between the creation date and the closed date.

Detail:  Calculation (Current Day Time - ) 

Refer to target spot: 

I want to know how to configure by "ScriptRunner for JIRA" installed.

Best Regards,

Pabayos Alaine

1 answer

This widget could not be displayed.
Vasiliy Zverev Community Champion Jan 18, 2016
  1. Create a scripted field
  2. Place a code for scriptRunner to calculate requared value. Somethink like this:

    import com.atlassian.jira.component.ComponentAccessor
    import com.atlassian.jira.issue.Issue
    import com.atlassian.jira.issue.fields.CustomField
    
    import java.sql.Timestamp
    
    
    return (int) ( System.currentTimeMillis() - getMillsForCstFd("custom field name 1", issue))/(1000*60*60*24)
    
    public long getMillsForCstFd(String _customFiledname, Issue _issue){
        CustomField customField = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName(_customFiledname);
        if(customField == null)
            return 0
    
        Timestamp cstFldDate = (Timestamp) _issue.getCustomFieldValue(customField);
        return (cstFldDate == null) ? 0 : cstFldDate.getTime();
    }
  3. Do reindexation to set values.

Vasiliy Zverev Community Champion Jan 18, 2016

In your case "Accepted Date Time" is a custom field.

In this case, a scripted field is a much nicer answer than a post-function plus a custom field.  I just wanted to add that you probably want to set the output to a "number" type, so that you can search it

Hi,

I have executed according to instruction.

>1.Create a scripted field

Issus > Custom Fields > Add Custom Field > Select a Field Type "Scripted Field"

>2.Place a code for scriptRunner to calculate requared value. Somethink like this:

Issus > Custom Fields > Scripted Field  > Configurations > Edit Configuration

>3.Do reindexation to set values.

System > Indexing > (Lock JIRA and rebuild index)Re-Index

But there was nothing changed.

What is the configure of shortage ?

Best Regards,

Pabayos Alaine

Have you added the field to the issue view screen?

When you added the script, did you use the "preview" box at the bottom of the script definition page to test what the output would be?  What did that do?

Sorry.

Your instruction is bellow:

Issus > Custom Fields > Scripted Field  > Configurations > Edit Configuration

is it correct?

 

In the following another way...

Add-On > Script Console> Script

Which is correct?

No, no-one has mentioned the script console because you're working with a scripted field, so the script console is the wrong place to look.

Go to the scripted field, put in the script you want and select an issue to test it with.  What does the preview tell you?

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Aug 22, 2018 in Marketplace Apps

How a Marketplace app tech team is achieving gender diversity

Hello! My name is Genevieve Blanch, and I'm the Marketing Manager at RefinedWiki, creators of apps to give teams the tools to customize Atlassian platforms. Currently, 44% of the tech team at Re...

489 views 3 18
Read article

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