Good afternoon.
I am attempting to call four nearly identical workflow runs simultaneously from Wavemaker. two of them complete successfully, and two of them error out with "TypeError: Cannot read property "0" from null". If I rerun the failed workflows manually, they are successful. The method that the failed workflows error on is "ActiveDirectory.search("UserGroup" , Group);"
Has anybody seen this before?
I don't recall seeing this particular error... it may be beneficial to provide additional detail in the form of screenshot(s) and/or attach package with workflow if possible. If you run these simultaneously only from vCO, do they run successfully? Is it ONLY when called from Wavemaker you have the issue?
In "Find Group", try changing this:
var GroupsArray = ActiveDirectory.search("UserGroup" , Group) Usergroup = GroupsArray[0];
to this:
var GroupsArray = ActiveDirectory.search("UserGroup" , Group); if(GroupsArray != null){ Usergroup = GroupsArray[0]; }else{ System.log("No groups named "+Group+" found..."); }
and in Find Users in group, change this:
GroupMembers = Usergroup.userMembers var UsersinGroup = new Array(); var j = 0; for (var i = 0; i < GroupMembers.length; i++) { UsersinGroup[j++] = GroupMembers[i].name; } Users = UsersinGroup
to this:
if (Usergroup != null){ GroupMembers = Usergroup.userMembers var UsersinGroup = new Array(); var j = 0; for (var i = 0; i < GroupMembers.length; i++) { UsersinGroup[j++] = GroupMembers[i].name; } Users = UsersinGroup }
I doubt that this will stop the error from occurring, but at least it may help identify problem areas...
It may also be helpful random delay in the workflow...
I have made the changes. Now, all three runs finish, however two of them come back with "No groups named X found". If I manually re-run either, they come back successful.
Okay, so somehow "X" is being passed to the workflow rather than a valid workflow name? Or did you just put X to hide the actual AD Group that was there? If the latter, no worries - gotta keep proprietary info off public forums My next step would be to introduce a random sleep duration prior to doing the search...
As a dumbed down attempt to simulate what you're doing, I created a test workflow that launches 5 copies of the "Get Users in Group" workflow at the same time with 5 different group names (1 for each workflow). I looped this to run 5 times... Every instance was successfull in finding the group that I had specified. :smileyconfused:
The X was put there by me :smileygrin:.
Did you run the workflows at the exact same time or sequentially? If I run sequentially, all runs succeed, however if I run workflows on a timer, set to go off at the same time, or from Wavemaker, I run into issues.
I used a "Nested Workflow" object to launch 5 at the same time.. after dropping nested workflow onto pallette, you must provide which workflow(s) you wish to execute at the same time... I typically only use this for a single workflow, but you presented me with a use case to run 5 at the same time
I just tried with a Nested workflow and received the same results as running them via a schedule or via Wavemaker. Are there any logs I could look at that may provide more detailed troubleshooting? Lacking that, how can I add a random sleep to the beginning of the workflow?
The following line generates a random number betwee 1 and 60: (multiply by 1000 if using for sleep since sleep time is in millisec)
var i = Math.floor((Math.random() * 60)+1);
If that doesn't work out for you, then you should certainly get in touch with GSS to get support as there seems to be an issue with your vCO. From the vCO Configuraiton Page, there is a section that lets you set your log level. During normal usage, log level should be at Info, Warn, or Error. When preparing a log bundle for GSS, they may ask you to turn up the log level to Debug, perform operations, then generate log bundle. Be sure to turn log level back down after troubleshooting.
Log files are found in <vCO Install folder>/app-server/server/vmo/log
Similar code here:
var sleepTime = Math.round(Math.random() * 5000);
System.log("Sleeping for " + sleepTime/1000 + " seconds");
System.sleep(sleepTime);
Will sleep from 0 to 5 seconds.
This is of course a work around. Running at the same time should not be a problem. You may want to open a support request and provide example code to reproduce.
Christophe.