Hi,
I am trying to generate a summary automatically with the value of a field.
The problem is that if I change the value of that field when creating the task, it does not update the summary field with the new value.
I have created a behavior that works only when I update the creation screen or when I update the issue already created.
Behavior:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.type.EventDispatchOption
def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser().getDisplayName()
def summary = getFieldById("summary")
def inf = getFieldById("customfield_15900").value
summary.setFormValue("${inf}" + ":" + " " + "${currentUser}")
How can I make the summary field to be updated with the new value that I put in the field from which I take that value?
Where did you put your behavior script?
It should be against the server-side script for the custom field that should trigger an update.
But be careful, you don't want future users that edit the issue to cause the summary to be refreshed to that user.
So either make sure your script only runs on create or if you want to allow the summary to be changed during future edits of the custom field, then you'll need to use the reporter details instead of the current user.
Option 1 - only run during creation:
import com.atlassian.jira.component.ComponentAccessor
if(underlyingIssue) return //underlying issue doesn't exist during creation, and we only want to run initially during creation
def currentUser = ComponentAccessor.jiraAuthenticationContext.loggedInUser
def summary = getFieldById("summary")
def inf = getFieldById("customfield_15900").value
summary.setFormValue("$inf: $currentUser.displayName")
Option 2 - user currentUser during creation and reporter after:
import com.atlassian.jira.component.ComponentAccessor
//first assume the reporter is the current user (for issue creation)
def reporter = ComponentAccessor.jiraAuthenticationContext.loggedInUser
if(underlyingIssue) {
//if an issue exists, the reporter is whoever was set as the reporter field on the issue
reporter = underlyingIssue.reporter
}
def summary = getFieldById("summary")
def inf = getFieldById("customfield_15900").value
summary.setFormValue("$inf: $reporter.displayName")
Hello Peter,
First of all thanks for your reply.
I have tried the option 1- only run during creation - in the behavior and I have the same problem.
When I put some CF option I need to refresh the page so that the summary changes.
I can NOT find any option to update the summary without refreshing the creation page.
Do you know where I can look for this error?
Attach the examples
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Can you share a screenshot of your behaviour configuration?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Peter;
Yes! attach the script,
-----------------------------------------------------------------
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.type.EventDispatchOption
if(underlyingIssue) return //el problema subyacente no existe durante la creación, y solo queremos ejecutarlo inicialmente durante la creación
def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser().getDisplayName()
def summary = getFieldById("summary")
def inf = getFieldById("customfield_15900").value
//summary.setFormValue("$inf: $currentUser.displayName")
//def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser().getDisplayName()
summary.setFormValue("${inf}" + ":" + " " + "${currentUser}")
-----------------------------------------------------------------
I have tried to combine your answer with the behavior I just created because some option does not give the result we are looking for.
Example of summary --> value: currentuser
Thakyou very much for your help Peter!!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
There is nothing wrong with the script, but what I asked for is a screenshot of the behaviour configuration page so that I can know for sure where the script is being called from.
I do have a question about the script...
Why this?
summary.setFormValue("${inf}" + ":" + " " + "${currentUser}")
And not this
summary.setFormValue("$inf: $currentUser")
Isn't the second one much easier to read?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Peter,
I think it doesn't matter the line, this way it shows me the result in the summary field as requested.
Do you think it is a problem to leave it like that?
Does it influence the problem that the summary field is not updated?
I attach the configuration
Thanks for your help!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
No that line has nothing to do with the issue with the summary.
I was just curious why you kept the more complex version.
The problem is where your script is located.
Only scripts linked to fields that are changed are executed. Add the "informacion que deseo modificar" field to the behaviour configuration and then copy your scrirpt there.
You can delete the server-side script from summary field.
When that field is updated, the script will run and the summary will be updated.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hello peter,
I was misinterpreting the behavior.
I have just changed the configuration to the corresponding field and it is now displayed correctly.
thank you very much for your help and patience.
best regards
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.