When service-desk agent wants do log work it duplicates:
Please help me to solve this problem.
Hi Jamil,
I see that you appear to have duplicate work log entries here. I have not yet seen this problem before, and I can't seem to find any other reports of this. However I'd like to try to learn more about your environment here.
I tried to recreate this problem in my own Jira Service Desk, but so far I have not been able to. Perhaps if we can learn more about your environment here I can better help guide you to a solution.
Andy
We have log work transition on customer portal:
//------------------------------------------------------------------------------------------------
Agents do log work using screen:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Andy Heinzer
Service Desk Version:
JIRA Service Desk 3.16.1
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Andy Heinzer
This problem rarely happens but we want avoid this.
Normally it indicates only one log work but sometime it can be duplicated.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I'm having some difficulties trying to replicate this problem. Could we take a closer look at the workflow being used for this step? I'd be interested to see what steps it might have for the post-functions here.
Also are you using any sort of plugins for Service Desk here? In my setup, the customer portal doesn't quite have all the same options I can see in yours, so I'd be interested to better understand why there is a difference between the available options here.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Post-functions:
//---------------------------------------------------------------------------------------------
Used script for log work:
/*
@id=1
@name=""
log work for participants
*/
import com.atlassian.jira.issue.CustomFieldManager;
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.issue.IssueManager;
import com.atlassian.jira.issue.worklog.WorklogImpl2
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.worklog.DefaultWorklogManager
import com.atlassian.jira.security.roles.ProjectRoleManager
import com.atlassian.jira.user.ApplicationUser
import org.apache.log4j.Category
def Category log = Category.getInstance("com.onresolve.jira.groovy.PostFunction")
//log.setLevel(org.apache.log4j.Level.DEBUG)
//def issue = ComponentAccessor.getIssueManager().getIssueObject("SD-52450")
def actionUserName
def componentManager = ComponentManager.getInstance()
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def minutesSpent = customFieldManager.getCustomFieldObjectByName("Minutes spent")
def minutes = issue.getCustomFieldValue(minutesSpent) as Integer
def actionUser = customFieldManager.getCustomFieldObjectByName("Action User")
def ActionUser = issue.getCustomFieldValue(actionUser) as ApplicationUser
if(ActionUser != null)
actionUserName = ActionUser.getKey()
log.debug("actionUserName: $actionUserName")
log.info("actionUserName: $actionUserName")
log.debug("minutes: $minutes")
log.info("minutes: $minutes")
String comment = transientVars.comment as String
log.debug "comment: " + comment
log.debug "transientVars : " + transientVars
if (!comment)
{
comment = transientVars.get("Comment")
log.debug "comment is null, new value: " + comment
}
//def reporter = issue.reporter.name
def worklogManager = ComponentAccessor.getWorklogManager();
if (minutes != null && actionUserName != null)
{
ProjectRoleManager projectRoleManager = ComponentManager.getComponentInstanceOfType(ProjectRoleManager.class) as ProjectRoleManager
def UsersRole = projectRoleManager.getProjectRole("Users")
long timespent = minutes * 60 as long
log.debug("minutes : $timespent")
log.info("minutes : $timespent")
def worklog = new WorklogImpl2(issue, null, actionUserName, comment, new Date(), null, null, timespent, UsersRole)
worklogManager.create(issue.reporter, worklog, 0L, true)
log.debug("worklog created")
log.info("worklog created")
log.debug("actionUserName: $actionUserName")
log.info("actionUserName: $actionUserName")
//return actionUserName
}
else {
log.debug("skipped")
log.info("skipped")
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Andy Heinzer
As you can see from the post-functions image there used JWT plugin and the script.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I'm afraid I'm not very familiar with using the JWT plugin or this script itself. Could you let me know more about this? I suspect that step 3 in postfunctions it what is responsible for converting the minutes input into a worklog entry. This script is being run via the scriptrunner plugin, right?
I'm not sure I understand what steps 2,5,6 are actually doing here. I can read what they say, but since I'm not familiar with the use of the JWT plugin, it's unclear to me what steps they might be taking in addition to that script itself which looks like groovy code.
I suspect that the action to log work is somehow getting called twice within the same thread, but having reviewed the script there, it is not clear to me yet why that might be. I'd be interested to see if it's possible to remove the other JWT post functions there to see if the log work still functions. If not, then perhaps changing the order here might prove beneficial as sometimes the order in which a post-function appears in the workflow can have significant effects on its behavior.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Jamil Rahimov , @Andy Heinzer ,
from what I see, post function #2 is used to set a 'helper field' 'Action User' with the current user if no dedicated action user is present.
Post functions #5 and #6 are used to clear the 'Action user' as well as the 'Minutes spent' afterwards.
All of the aforementioned post functions should have no effect on the actual work logging. That said, duplicate entries must come either from a duplicate creation within the script itself, or a duplicate execution of this transition. The second option could be excluded if comments that are entered appear only once.
That said, is there a specific reason you're not using the JWT post function to log work @Jamil Rahimov ?
Cheers
Thorsten
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.