I've ran into an issue with an Insight workflow script. The error is "Property 'appRole' not found" Here is a code snip-it where the error occurs. The code runs fine from the workflow console. The error line this. In the workflow console, I get all the log.warn posted and I can also see the values via the returns. When I try from the issue itself, I get no logging.
Yes, I have published the workflow many times. I even assigned it to "oldSubTask" and when I do that I get "Property 'oldSubTask' not found".
if (appRole.subTaskX.getStatus().name != "Open")
def iIdx = 0;
for(AppRole appRole in appRoles)
{
iIdx++;
//TESTING ONLY
//return "for(AppRole appRole in appRoles) - 1 - " + appRole.key;
log.warn "for(AppRole appRole in appRoles) - 1 " + iIdx;
//TESTING ONLY
appRole.supportOwner = userManager.getUserByKey("xxx");
//If we don't have a subtask assigned to this app role, create one
if (appRole.subTaskX == null)
{
//TESTING ONLY
//return "if (appRole.subTaskX == null) - 1 - " + appRole.key;
log.warn "for(AppRole appRole in appRoles) - 2 " + iIdx;
//TESTING ONLY
//return "for(AppRole appRole in appRoles) - appRole.subTaskX = null";
MutableIssue newSubTask = issueFactory.getIssue();
newSubTask.setSummary("App Assignment for " + appRole.roleName);
newSubTask.setParentObject(parentIssue);
newSubTask.setPriorityId(priority.id);
newSubTask.setProjectObject(parentIssue.getProjectObject());
newSubTask.setIssueTypeId(eacSubTaskIssueType.id);
newSubTask.setAssignee(appRole.supportOwner);
newSubTask.setReporter(reporterUser);
newSubTask.description = "Please grant app/role access to " + appRole.roleName + " to caregiver " + caregiverName;
//TESTING ONLY
log.warn "for(AppRole appRole in appRoles) - 3 " + iIdx;
// Add any other fields you want for the newly created sub task
Map<String,Object> newIssueParams = ["issue" : newSubTask] as Map<String,Object>;
issueManager.createIssueObject(appRole.supportOwner, newIssueParams);
subTaskManager.createSubTaskIssueLink(parentIssue, newSubTask, appRole.supportOwner);
//*****************************************************************************************//
//*** Update the Insight custom field 'Application Security Role' on the subtask screen ***//
//*****************************************************************************************//
//findObjectBeansByAttributeValue(objectTypeAttributeId, comparison, compare value)
def objects = objectFacade.findObjectBeansByAttributeValue(332, "=", appRole.roleKey)
if (!objects.isEmpty()) {
MutableIssue mi = (MutableIssue) newSubTask;
mi.setCustomFieldValue(securityRoleCF, objects);
ComponentAccessor.getIssueManager().updateIssue(currentUser, mi, EventDispatchOption.DO_NOT_DISPATCH, false);
}
//*****************************************************************************************//
//TESTING ONLY
//return "for(AppRole appRole in appRoles) - newSubTask id == " + newSubTask.id;
log.warn "for(AppRole appRole in appRoles) - 4 " + iIdx;
}
else
{
//TESTING ONLY
//return "if (appRole.subTaskX != null) - 1 - " + appRole.key;
log.warn "for(AppRole appRole in appRoles) - 5 " + iIdx;
//if (iIdx == 1)
//{
// return "if (appRole.subTaskX != null) - 1 - key = " + appRole.key + " subTaskX = " + appRole.subTaskX.toString() + " subTaskX Status = " + appRole.subTaskX.getStatus().name;
//}
//TESTING ONLY
//def oldSubTask = appRole.subTaskX;
//TESTING ONLY
//if (iIdx == 3)
//{
// return "if (appRole.subTaskX != null) - 1 - key = " + appRole.subTaskX.key + " subTaskX = " + appRole.subTaskX.toString() + " appRole.subTaskX Status = " + appRole.subTaskX.getStatus().name;
//}
//TESTING ONLY
log.warn "for(AppRole appRole in appRoles) - 6 " + iIdx;
//Get current status. If it's Open there is nothing to do
// ERROR LINE
if (appRole.subTaskX.getStatus().name != "Open")
{
//TESTING ONLY
log.warn "for(AppRole appRole in appRoles) - 7 " + iIdx;
//https://docs.atlassian.com/jira/7.1.0/com/atlassian/jira/workflow/WorkflowTransitionUtil.html
WorkflowTransitionUtil workflowTransitionUtil = (WorkflowTransitionUtil) JiraUtils.loadComponent(WorkflowTransitionUtilImpl.class);
workflowTransitionUtil.setIssue(appRole.subTaskX);
workflowTransitionUtil.setUserkey(currentUser.key);
//log.warn msgPrefix + "before sub-task " + appRole.subTaskX.key + " reset to Open"
workflowTransitionUtil.setAction(1); //Reset to Open (1)
log.warn "for(AppRole appRole in appRoles) - 8 " + iIdx;
if (workflowTransitionUtil.validate().hasAnyErrors()) {
//Something went wrong
log.warn msgPrefix + "Error: " + workflowTransitionUtil.validate()
//return false;
}
workflowTransitionUtil.progress();
//log.info msgPrefix + "Sub task reset: ${appRole.subTaskX.summary}"
//TESTING ONLY
log.warn "for(AppRole appRole in appRoles) - 9 " + iIdx;
}
//TESTING ONLY
log.warn "for(AppRole appRole in appRoles) - 10 " + iIdx;
//*****************************************************************************************//
//*** Update the Insight custom field 'Application Security Role' on the subtask screen ***//
//*****************************************************************************************//
//findObjectBeansByAttributeValue(objectTypeAttributeId, comparison, compare value)
def objects = objectFacade.findObjectBeansByAttributeValue(332, "=", appRole.roleKey)
if (!objects.isEmpty()) {
MutableIssue mi = (MutableIssue) appRole.subTaskX;
//TESTING ONLY
//if (iIdx == 1)
//{
// return "if (appRole.subTaskX != null) - 1 - key = " + appRole.subTaskX.key + " subTaskX = " + appRole.subTaskX.toString() + " appRole.subTaskX Status = " + appRole.subTaskX.getStatus().name;
//}
//TESTING ONLY
mi.setCustomFieldValue(securityRoleCF, objects);
ComponentAccessor.getIssueManager().updateIssue(currentUser, mi, EventDispatchOption.DO_NOT_DISPATCH, false);
}
//*****************************************************************************************//
//TESTING ONLY
log.warn "for(AppRole appRole in appRoles) - 11 " + iIdx;
//if (iIdx == 2)
//{
// return "if (appRole.subTaskX != null) - 1 - key = " + appRole.key + " subTaskX = " + appRole.subTaskX.toString();
//}
}
//TESTING ONLY
log.warn "for(AppRole appRole in appRoles) - 12"
//return "for(AppRole appRole in appRoles) - Exit";
}
Here are the classes. I know I could have used one class and just have two instances, but I separated it out for troubleshooting.
public class AppRole {
public String key
public String appKey
public String appName
public String roleKey
public String roleName
public ApplicationUser supportOwner
public Issue subTaskX
AppRole() {}
AppRole(String key, String appKey, String appName, String roleKey, String roleName, ApplicationUser supportOwner, Issue subTaskX) {
this.key = key
this.appKey = appKey
this.appName = appName
this.roleKey = roleKey
this.roleName = roleName
this.supportOwner = supportOwner
this.subTaskX = subTaskX
}
}
public class AppRoleSubTask {
public String key
public String roleKey
public ApplicationUser supportOwner
public Issue subTaskX
AppRoleSubTask() {}
AppRoleSubTask(String key, String roleKey, ApplicationUser supportOwner, Issue subTaskX) {
this.key = key
this.roleKey = roleKey
this.supportOwner = supportOwner
this.subTaskX = subTaskX
}
}
I've given up on trying to find a solution and have rewritten all the code. Now it works.
Ok,
Thanks for the update!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Eric,
I would recommend to strip down the code just to make it simpler to find the error, ie remove what has been commented out and all the inner for loops, and focus on the outer one initiated on line 3, as it seems it's this one that is not functioning correctly, as it can't find the appRole variable.
Is there any difference if you replace it with
for(AppRole appRole:appRoles)
I am not personally an expert on groovy script, but this is what I would recommend you to look into.
Best Regards
Alexander
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I've determined that getting an issue subtask is throwing the error.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Eric,
OK, thanks for the update. Then it seems to be more related to Jiras Api then I think. I would advise you to look more into that and let us know what you find.
Best Regards
Alexander
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
There something funny happening. If I comment out or delete this for loop and publish the changes, I still get the error. It's like it's keeping the code in cache somewhere.
The only way for me to stop the error is to delete the workflow status and rebuild a new one. At this point I can add the code without the for loop and it works. Add the for loop back in and I'm back in the same place. This makes it very hard to troubleshoot.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This is the error in the log. Funny thing is that the variable isn't in my code any longer.
2018-02-01 10:29:46,262 http-nio-80-exec-23 ERROR er16568 629x434158x1 1c55w8g 172.16.221.80 /secure/CommentAssignIssue.jspa [c.a.jira.workflow.OSWorkflowManager] Caught exception while attempting to perform action 81 from workflow 105333 on issue 'EAC-39'com.opensymphony.module.propertyset.PropertyImplementationException: Property 'thisSubTask' not found at com.opensymphony.module.propertyset.ofbiz.OFBizPropertySet.getType(OFBizPropertySet.java:162) at com.opensymphony.module.propertyset.AbstractPropertySet.getAsActualType(AbstractPropertySet.java:83) at com.opensymphony.workflow.util.DefaultVariableResolver.getVariableFromMaps(DefaultVariableResolver.java:53) at com.opensymphony.workflow.util.DefaultVariableResolver.translateVariables(DefaultVariableResolver.java:90) at com.opensymphony.workflow.AbstractWorkflow.executeFunction(AbstractWorkflow.java:1002) at com.opensymphony.workflow.AbstractWorkflow.transitionWorkflow(AbstractWorkflow.java:1407) at com.opensymphony.workflow.AbstractWorkflow.doAction(AbstractWorkflow.java:557) at com.atlassian.jira.workflow.OSWorkflowManager.doWorkflowActionInsideTxn(OSWorkflowManager.java:829) at com.atlassian.jira.workflow.OSWorkflowManager.doWorkflowAction(OSWorkflowManager.java:786) at com.atlassian.jira.bc.issue.DefaultIssueService.transition(DefaultIssueService.java:492) at com.atlassian.jira.web.action.issue.CommentAssignIssue.doExecute(CommentAssignIssue.java:162) ... 1 filtered
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
That seems really strange. Could be another post function on the same transition doing something similar?
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.