Modification during postfunction shown in history but are not effective

Hi everyone,

I developped a function that copy an issue and then modify some fields in the source issue. I can execute it manually, or from a post function.

My problem is that when I execute it from the post function, the modifications are shown in the history but I can not see them in the issue itself, event after reindexing :

And as you can see, some time after the post function, if i run the same manually, it works perfectly :

When I debug my code, it runs exaclty the same bunch of code, with exactly same values…

I also tried to put my function as the last operation in the postfunction, to be sure nothing would modify the issue after me, but this doesn’t work either.

I’m stuck with this problem, so some help would be really appreciated.

Thanks in advance for your answers.

Can you maybe show us your function?

I can not, since the code is kind of private… Just know that we call in each case the “updateIssue” method from the IssueManager.
As I tested with debug, either with manual of with post-function, the value in the mutableIssue are exactly the same, both are shown in the history… But one works, not the other one…

Hi MlanieGeffre,

As Taylan mentioned it is quite difficult without a code snippet. When you say you use the “updateIssue” method of the IssueManager do you also access the issue via the IssueManager (getIssue…)?

If so then I think that might be the problem here. You have to access the issue in the following way

public class MyFunction extends AbstractJiraFunctionProvider {
public void execute(Map transientVars, Map args, PropertySet propertySet) throws WorkflowException {
		MutableIssue issue = getIssue(transientVars);
}
}

(https://developer.atlassian.com/server/jira/platform/workflow-modules/#function-configuration)

Regards,
Christian

Hi @ChristianSantej,
Yes we are using the getIssueObject to get the issue (as the “getIssue” is deprecated). I can show you a part of the code :

MutableIssue mutableSourceIssue = issueManager.getIssueObject(sourceIssue.getId());
try {
    mappingService.applyParentUpdateMappingResult(jiraTarget.getUpdateSourceFields(), mutableSourceIssue); //Update some fields
} catch (ExocetException e) {
    return Option.some(e.getErrorCollection());
}
// Issue has modified fields ?
if (mutableSourceIssue.getModifiedFields().size() > 0) {
    //When I pass in debug here the fields are properly updated with the expected values
    issueManager.updateIssue(user, mutableSourceIssue, com.atlassian.jira.event.type.EventDispatchOption.ISSUE_UPDATED, true);
}

Hi @MlanieGeffre,

As i stated in my previous post you have to access the actual issue of the PostFunction and not lookup it manually.

If you are extending the AbstractJiraFunctionProvider class then you can gain access to the current MutableIssue instance with MutableIssue mutableSourceIssue = getIssue(transientVars);

If you are not extending the AbstractJiraFunctionProvider class then you can gain access to the current MutableIssue instance with MutableIssue mutableSourceIssue = (MutableIssue)transientVars.get(“issue”);

Regards,
Christian