I have been working on this and it is nearly working, but I need help to understand why I can't get the right function with a user command.
I am running patients through a release resource, though it is ambiguous which resources they have. I want all patients to release resources, but avoid throwing exceptions if the label does not exist.
This works, when put into the Resource field:
/**Custom Code*/ Object current = param(1); Object patient = current; treenode activity = param(2); Token token = param(3); treenode processFlow = ownerobject(activity); Array ret = []; if (patient.Locations?){ for (int i = 1; i <= patient.Locations.length; i++){ ret.push(i); } } else{ ret.push(0x0); } return ret;
But similar code does not work when I run it as a user command (it also doesn't work when I run it as code directly in the Resource field).
/**Custom Code*/ Object current = param(1); Object patient = current; string lbl = param(2); Array ret = []; if (patient.labels[lbl]){ for (int i = 1; i <= patient.labels[lbl].subnodes.length; i++){ ret.push(i); } } else{ ret.push(0x0); } return ret;
What am I missing here?