Alfresco task completed - alfresco

I have the following form:
Option 2 is ok, but option 1 is not....
The aim of the option 1 is to move the document from my main dashlet to a (new) "pending" dashlet.
It is used when required info is missing (and unknown to the user) and so they can't completely fill out the form (i.e., they need to save it as a draft).
When they're ready to complete the form, we re-open the document (from the "pending" dashlet), fill out totally the form and use option 2.
For the moment, when I click on option 1 button, the document is moved to my pending dashlet but as a completed task....
This is what I have tried:
My XML:
<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:activiti="http://activiti.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC" xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI" xmlns:tns="http://activiti.org/bpmn20" typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://activiti.org/bpmn20" id="review-definitions" name="">
<process id="activitiValidationDocumed" name="Validation Documed" isExecutable="true" isClosed="false" processType="None">
<extensionElements>
<activiti:executionListener event="start" class="org.alfresco.repo.workflow.activiti.listener.ScriptExecutionListener">
<activiti:field name="script">
<activiti:string><![CDATA[execution.setVariable('wf_approveCount', 100);
execution.setVariable('wf_actualPercent', 100);
execution.setVariable('wf_reviewerCount', bpm_assignees.size());
execution.setVariable('wf_requiredPercent', wf_requiredApprovePercent);]]></activiti:string>
</activiti:field>
</activiti:executionListener>
</extensionElements>
<startEvent id="start" activiti:formKey="wf:submitParallelReviewTask"></startEvent>
<sequenceFlow id="flow1" sourceRef="start" targetRef="validationSecretaire"></sequenceFlow>
<userTask id="validationSecretaire" name="Validation secrétaire" activiti:assignee="${reviewAssignee.properties.userName}" activiti:formKey="wfvd:activitiReviewTask">
<extensionElements>
<activiti:taskListener event="create" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
<activiti:field name="script">
<activiti:string><![CDATA[if (typeof bpm_workflowDueDate != 'undefined') task.setVariableLocal('bpm_dueDate', bpm_workflowDueDate);
if (typeof bpm_workflowPriority != 'undefined') task.priority = bpm_workflowPriority;
logger.system.out("task.getVariable(reviewAssignee) onCreate : "+task.getVariable("reviewAssignee"));]]></activiti:string>
</activiti:field>
</activiti:taskListener>
<activiti:taskListener event="complete" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
<activiti:field name="script">
<activiti:string><![CDATA[<import resource="classpath:alfresco/extension/workflows/js/validation-documed.js">
mainValidationSecretaire();]]></activiti:string>
</activiti:field>
</activiti:taskListener>
</extensionElements>
<multiInstanceLoopCharacteristics isSequential="false" activiti:collection="bpm_assignees" activiti:elementVariable="reviewAssignee">
<completionCondition>${wf_actualPercent >= wf_requiredApprovePercent}</completionCondition>
</multiInstanceLoopCharacteristics>
</userTask>
<sequenceFlow id="flow2" sourceRef="validationSecretaire" targetRef="reviewDecision"></sequenceFlow>
<exclusiveGateway id="reviewDecision" name="Review Decision"></exclusiveGateway>
<sequenceFlow id="flow3" sourceRef="reviewDecision" targetRef="validationMedecin">
<conditionExpression xsi:type="tFormalExpression"><![CDATA[${execution.getVariable('wfvd_reviewOutcomeMed') == 'DEMANDE'}]]></conditionExpression>
</sequenceFlow>
<userTask id="validationMedecin" name="Validation Médecin" activiti:assignee="${wfvd_medecin.properties.userName}" activiti:formKey="wfvd:activitiReviewTaskMedecin">
<documentation>The document was reviewed and approved.</documentation>
<extensionElements>
<activiti:taskListener event="create" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
<activiti:field name="script">
<activiti:string><![CDATA[<import resource="classpath:alfresco/extension/workflows/js/validation-documed.js">
if (typeof bpm_workflowDueDate != 'undefined') task.setVariableLocal('bpm_dueDate', bpm_workflowDueDate);
if (typeof bpm_workflowPriority != 'undefined') task.priority = bpm_workflowPriority;
OncreateValidationMedecin();]]></activiti:string>
</activiti:field>
</activiti:taskListener>
<activiti:taskListener event="complete" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
<activiti:field name="script">
<activiti:string><![CDATA[<import resource="classpath:alfresco/extension/workflows/js/validation-documed.js">
mainValidationMedecin();]]></activiti:string>
</activiti:field>
</activiti:taskListener>
</extensionElements>
</userTask>
<endEvent id="end"></endEvent>
<sequenceFlow id="flow6" sourceRef="reviewDecision" targetRef="end"></sequenceFlow>
<exclusiveGateway id="exclusivegateway1" name="Exclusive Gateway"></exclusiveGateway>
<sequenceFlow id="flow7" sourceRef="validationMedecin" targetRef="exclusivegateway1"></sequenceFlow>
<sequenceFlow id="flow8" sourceRef="exclusivegateway1" targetRef="end">
<conditionExpression xsi:type="tFormalExpression"><![CDATA[${execution.getVariable('wfvd_reviewOutcomeMedecinDpe') == 'DPE'}]]></conditionExpression>
</sequenceFlow>
<userTask id="validationRefusSecretaire" name="Validation refus secrétaire" activiti:assignee="${bpm_assignee.properties.userName}" activiti:formKey="wfvd:activitiReviewTaskRefusSecretaire">
<extensionElements>
<activiti:taskListener event="create" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
<activiti:field name="script">
<activiti:string><![CDATA[if (typeof bpm_workflowDueDate != 'undefined') task.setVariableLocal('bpm_dueDate', bpm_workflowDueDate);
if (typeof bpm_workflowPriority != 'undefined') task.priority = bpm_workflowPriority;
task.setVariable("bpm_workflowDescription",execution.getVariable("bpm_workflowDescription"));
task.setVariable("bpm_priority",execution.getVariable("bpm_priority"));]]></activiti:string>
</activiti:field>
</activiti:taskListener>
<activiti:taskListener event="complete" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
<activiti:field name="script">
<activiti:string><![CDATA[<import resource="classpath:alfresco/extension/workflows/js/validation-documed.js">
mainValidationSecretaire();]]></activiti:string>
</activiti:field>
</activiti:taskListener>
</extensionElements>
</userTask>
<sequenceFlow id="flow9" sourceRef="exclusivegateway1" targetRef="validationRefusSecretaire">
<conditionExpression xsi:type="tFormalExpression"><![CDATA[${wfvd_reviewOutcomeMedecinReturn == 'RETOUR'}]]></conditionExpression>
</sequenceFlow>
<exclusiveGateway id="exclusivegateway2" name="Exclusive Gateway"></exclusiveGateway>
<sequenceFlow id="flow10" sourceRef="validationRefusSecretaire" targetRef="exclusivegateway2"></sequenceFlow>
<sequenceFlow id="flow11" sourceRef="exclusivegateway2" targetRef="validationMedecin">
<conditionExpression xsi:type="tFormalExpression"><![CDATA[${execution.getVariable("wfvd_reviewOutcomeMed") == 'DEMANDE'}]]></conditionExpression>
</sequenceFlow>
<sequenceFlow id="flow12" sourceRef="exclusivegateway2" targetRef="end"></sequenceFlow>
<sequenceFlow id="flow13" sourceRef="reviewDecision" targetRef="validationSecretaire">
<conditionExpression xsi:type="tFormalExpression"><![CDATA[${execution.getVariable('wfvd_reviewOutcomeMed') == 'EA'}]]></conditionExpression>
</sequenceFlow>
</process>
<bpmndi:BPMNDiagram id="BPMNDiagram_activitiValidationDocumed">
<bpmndi:BPMNPlane bpmnElement="activitiValidationDocumed" id="BPMNPlane_activitiValidationDocumed">
<bpmndi:BPMNShape bpmnElement="start" id="BPMNShape_start">
<omgdc:Bounds height="35.0" width="35.0" x="255.0" y="210.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="validationSecretaire" id="BPMNShape_validationSecretaire">
<omgdc:Bounds height="55.0" width="105.0" x="330.0" y="200.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="reviewDecision" id="BPMNShape_reviewDecision">
<omgdc:Bounds height="40.0" width="40.0" x="475.0" y="207.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="validationMedecin" id="BPMNShape_validationMedecin">
<omgdc:Bounds height="55.0" width="105.0" x="645.0" y="200.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="end" id="BPMNShape_end">
<omgdc:Bounds height="35.0" width="35.0" x="965.0" y="210.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="exclusivegateway1" id="BPMNShape_exclusivegateway1">
<omgdc:Bounds height="40.0" width="40.0" x="849.0" y="207.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="validationRefusSecretaire" id="BPMNShape_validationRefusSecretaire">
<omgdc:Bounds height="61.0" width="105.0" x="817.0" y="112.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="exclusivegateway2" id="BPMNShape_exclusivegateway2">
<omgdc:Bounds height="40.0" width="40.0" x="849.0" y="49.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge bpmnElement="flow1" id="BPMNEdge_flow1">
<omgdi:waypoint x="290.0" y="227.0"></omgdi:waypoint>
<omgdi:waypoint x="330.0" y="227.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="flow2" id="BPMNEdge_flow2">
<omgdi:waypoint x="435.0" y="227.0"></omgdi:waypoint>
<omgdi:waypoint x="475.0" y="227.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="flow3" id="BPMNEdge_flow3">
<omgdi:waypoint x="515.0" y="227.0"></omgdi:waypoint>
<omgdi:waypoint x="645.0" y="227.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="flow6" id="BPMNEdge_flow6">
<omgdi:waypoint x="495.0" y="247.0"></omgdi:waypoint>
<omgdi:waypoint x="495.0" y="365.0"></omgdi:waypoint>
<omgdi:waypoint x="730.0" y="365.0"></omgdi:waypoint>
<omgdi:waypoint x="982.0" y="365.0"></omgdi:waypoint>
<omgdi:waypoint x="982.0" y="245.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="flow7" id="BPMNEdge_flow7">
<omgdi:waypoint x="750.0" y="227.0"></omgdi:waypoint>
<omgdi:waypoint x="849.0" y="227.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="flow8" id="BPMNEdge_flow8">
<omgdi:waypoint x="889.0" y="227.0"></omgdi:waypoint>
<omgdi:waypoint x="965.0" y="227.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="flow9" id="BPMNEdge_flow9">
<omgdi:waypoint x="869.0" y="207.0"></omgdi:waypoint>
<omgdi:waypoint x="869.0" y="173.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="flow10" id="BPMNEdge_flow10">
<omgdi:waypoint x="869.0" y="112.0"></omgdi:waypoint>
<omgdi:waypoint x="869.0" y="89.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="flow11" id="BPMNEdge_flow11">
<omgdi:waypoint x="849.0" y="69.0"></omgdi:waypoint>
<omgdi:waypoint x="697.0" y="69.0"></omgdi:waypoint>
<omgdi:waypoint x="697.0" y="200.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="flow12" id="BPMNEdge_flow12">
<omgdi:waypoint x="889.0" y="69.0"></omgdi:waypoint>
<omgdi:waypoint x="982.0" y="69.0"></omgdi:waypoint>
<omgdi:waypoint x="982.0" y="210.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="flow13" id="BPMNEdge_flow13">
<omgdi:waypoint x="495.0" y="207.0"></omgdi:waypoint>
<omgdi:waypoint x="494.0" y="136.0"></omgdi:waypoint>
<omgdi:waypoint x="439.0" y="136.0"></omgdi:waypoint>
<omgdi:waypoint x="382.0" y="136.0"></omgdi:waypoint>
<omgdi:waypoint x="382.0" y="200.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</definitions>
I have just added sequenceFlow id="flow13"
This is associate JS => mainValidationSecretaire() function is called:
function getDocument(){
var document;
if (bpm_package != null) {
document = bpm_package.children[0];
}
return document;
}
function mainValidationSecretaire()
{
var document = getDocument();
execution.setVariable('wfvd_medecin', task.getVariable('wfvd_medecin'));
logger.log("validation-documed.js : wfvd_medecin: "+task.getVariable('wfvd_medecin'));
var reviewOutcomeEnreg = task.getVariable('wfvd_reviewOutcomeEnreg');
execution.setVariable('wfvd_reviewOutcomeEnreg', reviewOutcomeEnreg);
//logger.log("validation-documed.js : wfvd_reviewOutcomeEnreg: "+task.getVariable('wfvd_reviewOutcomeEnreg'));
var reviewOutcomeMed = task.getVariable('wfvd_reviewOutcomeMed');
execution.setVariable('wfvd_reviewOutcomeMed', reviewOutcomeMed);
//logger.log("validation-documed.js : wfvd_reviewOutcomeMed: "+task.getVariable('wfvd_reviewOutcomeMed'));
var reviewOutcomeDpe = task.getVariable('wfvd_reviewOutcomeDpe');
execution.setVariable('wfvd_reviewOutcomeDpe', reviewOutcomeDpe);
//logger.log("validation-documed.js : wfvd_reviewOutcomeDpe: "+task.getVariable('wfvd_reviewOutcomeDpe'));
var reviewOutcomeDel = task.getVariable('wfvd_reviewOutcomeDel');
execution.setVariable('wfvd_reviewOutcomeDel', reviewOutcomeDel);
//logger.log("validation-documed.js : wfvd_reviewOutcomeDel: "+task.getVariable('wfvd_reviewOutcomeDel'));
execution.setVariable('wfvd_reviewAssignee', task.getVariable("reviewAssignee"));
logger.log("validation-documed.js : reviewAssignee: "+task.getVariable('reviewAssignee'));
if(task.getVariable("wfvd_reviewAssignee") != null){
logger.log("validation-documed.js - wfvd_reviewAssignee userName = "+task.getVariable("wfvd_reviewAssignee").properties.userName);
}
execution.setVariable('bpm_assignee', task.getVariable("bpm_assignee"));
logger.log("validation-documed.js : bpm_assignee: "+task.getVariable('bpm_assignee'));
if(task.getVariable('bpm_assignee') != null){
logger.log("validation-documed.js - bpm_assignee userName= "+task.getVariable("bpm_assignee").properties.userName);
}
task.setVariable("wfvd_nomService",execution.getVariable("wfvd_nomService"));
logger.log("validation-documed.js : wfvd_nomService: "+task.getVariable('wfvd_nomService'));
task.setVariable("wfvd_retourMedecin",execution.getVariable("wfvd_retourMedecin"));
logger.log("validation-documed.js : wfvd_retourMedecin: "+task.getVariable('wfvd_retourMedecin'));
task.setVariable("wfvd_standBy",execution.getVariable("wfvd_standBy"));
logger.log("validation-documed.js : wfvd_standBy: "+task.getVariable('wfvd_standBy'));
var workflowDescription=execution.getVariable("bpm_workflowDescription");
var taskDescription=task.getVariable("bpm_workflowDescription");
logger.log("validation-documed.js : bpm_workflowDescription: "+taskDescription);
var idPatient,nomPatient,PrenomPatient,dateNaissance;
var patientSelectione = task.getVariable('wfvd_patients');
logger.log("validation-documed.js : wfvd_patients: "+task.getVariable('wfvd_patients'));
if(task.getVariable('wfvd_newPatient') == true)
{
idPatient = task.getVariable("wfvd_idPatient");
nomPatient = task.getVariable("wfvd_nomPatient");
PrenomPatient = task.getVariable("wfvd_prenomPatient");
dateNaissance = task.getVariable("wfvd_dateNaissance");
var nodePat = createPatient(idPatient,PrenomPatient,nomPatient,dateNaissance);
execution.setVariable("wfvd_patients" ,nodePat);
}
else
{
logger.log("validation-documed.js mainValidationSecretaire - patientSelectione not null");
idPatient = patientSelectione.properties["os:idPatient"];
logger.log("validation-documed.js mainValidationSecretaire - os:idPatient" +patientSelectione.properties["os:idPatient"]);
nomPatient = patientSelectione.properties["cm:lastName"];
logger.log("validation-documed.js mainValidationSecretaire - cm:lastName" +patientSelectione.properties["cm:lastName"]);
PrenomPatient = patientSelectione.properties["cm:firstName"];
logger.log("validation-documed.js mainValidationSecretaire - cm:firstName" +patientSelectione.properties["cm:firstName"]);
dateNaissance = patientSelectione.properties["os:dateNaissance"];
logger.log("validation-documed.js mainValidationSecretaire - os:dateNaissance" +patientSelectione.properties["os:dateNaissance"]);
execution.setVariable("wfvd_patients" ,task.getVariable("wfvd_patients"));
logger.log("validation-documed.js mainValidationSecretaire - wfvd_patients" +task.getVariable("wfvd_patients"));
}
execution.setVariable("wfvd_idPatient" ,idPatient);
execution.setVariable("wfvd_nomPatient" ,nomPatient);
execution.setVariable("wfvd_prenomPatient",PrenomPatient);
execution.setVariable("wfvd_dateNaissance",dateNaissance);
execution.setVariable("wfvd_dateDocument",task.getVariable("wfvd_dateDocument"));
execution.setVariable("wfvd_typologie",task.getVariable("wfvd_typologie"));
//logger.log("validation-documed.js mainValidationSecretaire - task.priority : " + task.priority);
execution.setVariable("bpm_priority", task.priority);
// logger.log("validation-documed.js mainValidationSecretaire - bpm_priority global : " + execution.getVariable("bpm_priority"));
if(reviewOutcomeEnreg == "EA")
{
logger.log("validation-documed.js mainValidationSecretaire - mise en attente EA ");
// anciennement VALIDER (=ARCHIVER)
// onValidationDocumed();
//var patient = people.getPerson(idPatient).nodeRef;
execution.setVariable("wfvd_standBy","en attente");
// initialisation des variables de la tâche avec les valeurs saisies dans le formulaire
OncreateValidationMedecin();
logger.log("comm secrétaire = " + task.getVariable('wfvd_commentaireSecretaire'));
actionUtilsWorkflow.setCommentaire(document.nodeRef,"secretaire",task.getVariable('wfvd_commentaireSecretaire'));
var taskDescription=execution.getVariable("bpm_workflowDescription");
if(taskDescription.indexOf("En attente")===-1)
execution.setVariable('bpm_workflowDescription',"En attente -"+execution.getVariable("bpm_workflowDescription"));
// get variables
var variables = task.getVariables();
logger.log("recup variables : " +variables);
for each(var itemKey in variables) {
if (typeof variables[itemKey] !== 'function') {
logger.log("Key is: " + itemKey + ", value is: " + variables[itemKey]);
}
}
}
if(reviewOutcomeMed == "DEMANDE"){
logger.log("validation-documed.js mainValidationSecretaire - DEMANDE");
actionUtilsWorkflow.setCommentaire(document.nodeRef,"secretaire",task.getVariable('wfvd_commentaireSecretaire'));
execution.setVariable("wfvd_retourMedecin","");
execution.setVariable("wfvd_standBy","");
}
if(reviewOutcomeDpe == "DPE")
{
logger.log("validation-documed.js DPE par secrétaire - Publication HL7 vers ARIA");
onValidationDocumed();
var patient = people.getPerson(idPatient).nodeRef;
actionUtilsWorkflow.updateDocumed(document.nodeRef,patient,task.getVariable('wfvd_medecin').nodeRef,task.getVariable('wfvd_typologie'),true,task.getVariable("wfvd_dateDocument"));
actionUtilsWorkflow.setCommentaire(document.nodeRef,"secretaire",task.getVariable('wfvd_commentaireSecretaire'));
setInformationsToHl7(document.nodeRef,task.getVariable('wfvd_typologie'),task.getVariable("wfvd_dateDocument"));
}
if(reviewOutcomeDel == "SUPPRIMER"){
//execution.setVariable("wfvd_retourMedecin","");
//execution.setVariable("wfvd_standBy","");
logger.log("validation-documed.js : Bouton supprimer, cliqué !");
}
if(reviewOutcomeEnreg != "EA"){
// gestion des droits d'accèss sur le document.
// Use Case : Si le médecin n'a pas les droits d'accès sur la dashlet "Courriers Entrants" dans laquelle est déposé le document
// alors une exception sera mise en place , uniquement pour ce document.
actionUtilsWorkflow.setContributor(document.nodeRef, task.getVariable('wfvd_medecin').properties.userName);
}
}
function mainValidationMedecin()
{
var document = getDocument();
var idPatient,nomPatient,PrenomPatient,dateNaissance;
var patientSelectione = task.getVariable('wfvd_patients');
logger.log("validation-documed.js : reviewAssignee: "+task.getVariable('reviewAssignee'));
if(task.getVariable("wfvd_reviewAssignee") != null){
logger.log("validation-documed.js - wfvd_reviewAssignee userName = "+task.getVariable("wfvd_reviewAssignee").properties.userName);
}
logger.log("validation-documed.js : bpm_assignee: "+task.getVariable('bpm_assignee'));
if(task.getVariable('bpm_assignee') != null){
logger.log("validation-documed.js - bpm_assignee userName= "+task.getVariable("bpm_assignee").properties.userName);
}
if(task.getVariable('wfvd_newPatient') == true)
{
idPatient = task.getVariable("wfvd_idPatient");
nomPatient = task.getVariable("wfvd_nomPatient");
PrenomPatient = task.getVariable("wfvd_prenomPatient");
dateNaissance = task.getVariable("wfvd_dateNaissance");
var nodePat = createPatient(idPatient,PrenomPatient,nomPatient,dateNaissance);
execution.setVariable("wfvd_patients" ,nodePat);
}
else
{
idPatient = patientSelectione.properties["os:idPatient"];
nomPatient = patientSelectione.properties["cm:lastName"];
PrenomPatient = patientSelectione.properties["cm:firstName"];
dateNaissance = patientSelectione.properties["os:dateNaissance"];
execution.setVariable("wfvd_patients" ,task.getVariable("wfvd_patients"));
}
execution.setVariable("wfvd_idPatient" ,idPatient);
execution.setVariable("wfvd_nomPatient" ,nomPatient);
execution.setVariable("wfvd_prenomPatient",PrenomPatient);
execution.setVariable("wfvd_dateNaissance",dateNaissance);
execution.setVariable("wfvd_dateDocument",task.getVariable("wfvd_dateDocument"));
execution.setVariable("wfvd_typologie",task.getVariable("wfvd_typologie"));
execution.setVariable("bpm_priority", task.priority);
var reviewOutcomeMedecinReturn = task.getVariable('wfvd_reviewOutcomeMedecinReturn');
execution.setVariable('wfvd_reviewOutcomeMedecinReturn', reviewOutcomeMedecinReturn);
var reviewOutcomeMedecinDpe = task.getVariable('wfvd_reviewOutcomeMedecinDpe');
execution.setVariable('wfvd_reviewOutcomeMedecinDpe', reviewOutcomeMedecinDpe);
// var reviewMedecin=execution.getVariable("wfvd_reviewOutcomeMedecin");
// logger.log("Medecin Review Outcome: "+reviewMedecin);
/*if(reviewOutcomeMedecin == "VALIDATION")
{
onValidationDocumed();
var patient = people.getPerson(idPatient).nodeRef;
logger.log("update Doc begin");
actionUtilsWorkflow.updateDocumed(document.nodeRef,patient,task.getVariable('wfvd_medecin').nodeRef,task.getVariable('wfvd_typologie'),false,task.getVariable("wfvd_dateDocument"));
logger.log("set Comm Dr");
actionUtilsWorkflow.setCommentaire(document.nodeRef,"Medecin",task.getVariable('wfvd_commentaireMedecin'));
execution.setVariable('wfvd_reviewOutcomeMedecin','Valider');
}
*/
if(reviewOutcomeMedecinDpe == "DPE")
{
logger.log("validation-documed.js : DPE par le médecin Publication HL7 vers ARIA");
//
onValidationDocumed();
var patient = people.getPerson(idPatient).nodeRef;
actionUtilsWorkflow.updateDocumed(document.nodeRef,patient,task.getVariable('wfvd_medecin').nodeRef,task.getVariable('wfvd_typologie'),true,task.getVariable("wfvd_dateDocument"));
actionUtilsWorkflow.setCommentaire(document.nodeRef,"Medecin",task.getVariable('wfvd_commentaireMedecin'));
setInformationsToHl7(document.nodeRef,task.getVariable('wfvd_typologie'),task.getVariable("wfvd_dateDocument"));
execution.setVariable('wfvd_reviewOutcomeMedecinDpe','DPE');
}
if(reviewOutcomeMedecinReturn == "RETOUR")
{
logger.log("validation-documed.js - wfvd_reviewAssignee = "+task.getVariable("wfvd_reviewAssignee"));
logger.log("validation-documed.js - bpm_assignee = "+task.getVariable("bpm_assignee"));
if(task.getVariable("wfvd_reviewAssignee") != null)
{
execution.setVariable('bpm_assignee',task.getVariable("wfvd_reviewAssignee"));
}
else
{
execution.setVariable('bpm_assignee',task.getVariable("bpm_assignee"));
}
// sauvegarde commentaires medecin
actionUtilsWorkflow.setCommentaire(document.nodeRef,"Medecin",task.getVariable('wfvd_commentaireMedecin'));
execution.setVariable("wfvd_retourMedecin","retour medecins");
// initialisation des variables de la tâche avec les valeurs saisies dans le formulaire
OncreateValidationMedecin();
// gestion du libellé
var taskDescription=execution.getVariable("bpm_workflowDescription");
logger.log("validation-documed.js : taskDescription: "+taskDescription);
if(taskDescription.indexOf("Rejet médecin")===-1)
execution.setVariable('bpm_workflowDescription',"Rejet médecin-"+execution.getVariable("bpm_workflowDescription"));
}
}
function OncreateValidationMedecin()
{
task.setVariable("wfvd_patients" ,execution.getVariable("wfvd_patients"));
task.setVariable("wfvd_idPatient" ,execution.getVariable("wfvd_idPatient"));
task.setVariable("wfvd_nomPatient" ,execution.getVariable("wfvd_nomPatient"));
task.setVariable("wfvd_prenomPatient",execution.getVariable("wfvd_prenomPatient"));
task.setVariable("wfvd_dateNaissance",execution.getVariable("wfvd_dateNaissance"));
task.setVariable("wfvd_dateDocument",execution.getVariable("wfvd_dateDocument"));
task.setVariable("wfvd_typologie",execution.getVariable("wfvd_typologie"));
task.priority = execution.getVariable("bpm_priority");
// logger.log("task.priority DOC " + task.priority);
}
The action associated to option 1 is the if(reviewOutcomeEnreg == "EA") test.
I have copied and updated the if(reviewOutcomeMedecinReturn == "RETOUR") test from mainValidationMedecin that moves a document from a dashlet to another one.
Is it possible to manage document like this? If so, what is missing? I can't find a diagram of a workflow like this on the web.

you can find that which button is clicked your outcome button properties will be of like this
<property name="tm:taskOutComeA4R">
<type>d:text</type>
<default>Disbursement Continue</default>
<constraints>
<constraint type="LIST">
<parameter name="allowedValues">
<list>
<value>Option1</value>
<value>Option2</value>
</list>
</parameter>
</constraint>
</constraints>
</property>
In complete task event get button property like this tm:taskOutComeA4R so get this property and check
if(task.getVariableLocal('tm_taskOutComeA4R') == 'Option1')
{
logger.log('Code X');
}else{
logger.log('Code Y');
}
Using this you can find that which button is clicked and which code you wants to execute.

Related

Check if cookie has specific value to prevent duplicates

I'm writing a code for a shopping cart. I need to check if the cookie already has de id of a selected item so that it won't duplicate it.
Code:
Dim cookie_carrito As HttpCookie = Request.Cookies("CkEntregas")
Dim i_docid As Integer = iddoc_print.Text
If cookie_carrito IsNot Nothing Then
Dim valor_galleta As String = cookie_carrito.Value
Dim galleticas As String() = valor_galleta.Split(","c)
For Each item In galleticas
Dim id_documento = item
If id_documento = i_docid Then
l_resultados_carrito.Text = "<div class='Col100'><div class='notificacionesCT'><i class='fa fa-bell fa-fw'></i> Este documento ya se encuentra en tu carrito de entregas.<a href='encriptar-documento.aspx?actid=2&docid=" & i_docid & "'><i class='fa fa-window-close fa-fw'></i></a></div></div>"
Else
Dim hoy As DateTime = DateTime.Now.Date.ToUniversalTime.AddHours(-5)
Dim cookie_actual As HttpCookie = Request.Cookies("CkEntregas")
Dim cookie_carrito_u As HttpCookie = New HttpCookie("CkEntregas")
cookie_carrito_u.Value = i_docid & "," & cookie_actual.Value
cookie_carrito_u.Expires = hoy.AddHours(72)
Response.Cookies.Add(cookie_carrito_u)
'resultados.Text = "Cookie actualizada: " & cookie_carrito_u.Value
l_resultados_carrito.Text = "<div class='Col100'><div class='notificacionesOK'><i class='fa fa-check fa-fw'></i> ¡Listo! El documento fue agregado con éxito al carrito de entregas.<a href='encriptar-documento.aspx?actid=2&docid=" & i_docid & "'><i class='fa fa-window-close fa-fw'></i></a></div></div>"
Exit For
End If
Next
Else
Dim hoy As DateTime = DateTime.Now.Date.ToUniversalTime.AddHours(-5)
Dim cookie_carrito_n As HttpCookie = New HttpCookie("CkEntregas")
cookie_carrito_n.Value = i_docid
cookie_carrito_n.Expires = hoy.AddHours(72)
Response.Cookies.Add(cookie_carrito_n)
'resultados.Text = "Cookie creada: " & cookie_carrito_n.Value
l_resultados_carrito.Text = "<div class='Col100'><div class='notificacionesOK'><i class='fa fa-check fa-fw'></i> ¡Listo! El documento fue agregado con éxito al carrito de entregas.<a href='encriptar-documento.aspx?actid=2&docid=" & i_docid & "'><i class='fa fa-window-close fa-fw'></i></a></div></div>"
End If
The logic that I'm using is to check each comma splitted value, so if that value is contained in the cookie items (list) it won't add it, but if the value is not there it will add it and break the loop.
It's not working, because if the first value in the cookie is different than the selected item, it will add it, but it may be in the second position of the list.
How can I check if a determined value is already in the cookie?
The cookie stores values in this format: 1,5,3,9,
I solved it checking the value of the cookie as a String, using the string.Contains() method:
Dim cookie_carrito As HttpCookie = Request.Cookies("CkEntregas")
Dim i_docid As Integer = iddoc_print.Text
If cookie_carrito IsNot Nothing Then
Dim valor_galleta As String = cookie_carrito.Value
Dim galleticas As String() = valor_galleta.Split(","c)
If valor_galleta.Contains(i_docid) Then
l_resultados_carrito.Text = "<div class='Col100'><div class='notificacionesCT'><i class='fa fa-bell fa-fw'></i> Este documento ya se encuentra en tu carrito de entregas.<a href='encriptar-documento.aspx?actid=2&docid=" & i_docid & "'><i class='fa fa-window-close fa-fw'></i></a></div></div>"
Else
Dim hoy As DateTime = DateTime.Now.Date.ToUniversalTime.AddHours(-5)
Dim cookie_actual As HttpCookie = Request.Cookies("CkEntregas")
Dim cookie_carrito_u As HttpCookie = New HttpCookie("CkEntregas")
cookie_carrito_u.Value = i_docid & "," & cookie_actual.Value
cookie_carrito_u.Expires = hoy.AddHours(72)
Response.Cookies.Add(cookie_carrito_u)
l_resultados_carrito.Text = "<div class='Col100'><div class='notificacionesOK'><i class='fa fa-check fa-fw'></i> ¡Listo! El documento fue agregado con éxito al carrito de entregas.<a href='encriptar-documento.aspx?actid=2&docid=" & i_docid & "'><i class='fa fa-window-close fa-fw'></i></a></div></div>"
End If
Else
Dim hoy As DateTime = DateTime.Now.Date.ToUniversalTime.AddHours(-5)
Dim cookie_carrito_n As HttpCookie = New HttpCookie("CkEntregas")
cookie_carrito_n.Value = i_docid
cookie_carrito_n.Expires = hoy.AddHours(72)
Response.Cookies.Add(cookie_carrito_n)
l_resultados_carrito.Text = "<div class='Col100'><div class='notificacionesOK'><i class='fa fa-check fa-fw'></i> ¡Listo! El documento fue agregado con éxito al carrito de entregas.<a href='encriptar-documento.aspx?actid=2&docid=" & i_docid & "'><i class='fa fa-window-close fa-fw'></i></a></div></div>"
End If

How to handle 'The source contains no DataRows. ' error

please find below code.It will through an error 'The source contains no DataRow' if ithe row is empty..How to handle this ??
if (dtTemSec.Rows.Count > 0)
{
grdStepDetails.DataSource = dtTemSec.AsEnumerable()
.Where(x => x.Field<string>("Status") != "D" && x.Field<string>("ID") == "ST" && x.Field<int>("Folder") == folder)
.CopyToDataTable();
grdStepDetails.DataBind();
ClientScript.RegisterStartupScript(GetType(), "Val", "ShowStepPopup();", true);
}
else
{
grdStepDetails.DataSource = null;
grdStepDetails.DataBind();
ClientScript.RegisterStartupScript(GetType(), "Val", "ShowStepPopup();", true);
}
Use like this :-
if (dtTemSec.Rows.Count > 0)
{
var table = dtTemSec;
var rows = table.AsEnumerable().Where(x => x.Field<string>("Status") != "D" && x.Field<string>("ID") == "ST" && x.Field<int>("Folder") == folder);
var dt = rows.Any() ? rows.CopyToDataTable() : table.Clone();
grdStepDetails.DataSource = dt;
grdStepDetails.DataBind();
ClientScript.RegisterStartupScript(GetType(), "Val", "ShowStepPopup();", true);
}
else
{
grdStepDetails.DataSource = null;
grdStepDetails.DataBind();
ClientScript.RegisterStartupScript(GetType(), "Val", "ShowStepPopup();", true);
}
Use a If condition as below.
if(dtTemSec != null)
{
if(dtTemSec.Rows.Count > 0)
{
}
}
EDIT:
If that is the case, then put the condition after the Filter
if(dtTemSec != null)
{
if(dtTemSec.Rows.Count > 0)
{
DataTable Temp = new DataTable();
Temp = dtTemSec.AsEnumerable()
.Where(x => x.Field<string>("Status") != "D" && x.Field<string>("ID") == "ST" && x.Field<int>("Folder") == folder)
.CopyToDataTable();
if(Temp != null)
{
if(Temp.Rows.Count > 0)
{
grdStepDetails.DataSource=Temp;
grdStepDetails.DataBind();
ClientScript.RegisterStartupScript(GetType(), "Val", "ShowStepPopup();", true);
}
}
}
}

Error in getFinancials

i'm trying to retrieve AAPL financials and i'm getting the following error
> library(quantmod)
> f <- get(getFinancials('APPL'))
Error in thead[x]:thead[x + 1] : NA/NaN argument
In addition: Warning message:
In readLines(tmp) :
incomplete final line found on 'C:\Users\myuser\AppData\Local\Temp\Rtmpgrg0Uq\fileafc7f52710a'
i've tried to load the entire NQ100 and got the same error message for these stocks as well
> symbols
[1] "ADBE" "APOL" "AAPL" "AMAT" "ADSK" "ADP" "BBBY" "BMC" "CA" "CERN" "CSCO" "COST" "DELL" "DTV" "DLTR" "ERTS" "ESRX" "FFIV" "FLEX" "GRMN" "GMCR" "HSIC" "ILMN"
[24] "INFY" "INTC" "INTU" "JOYG" "KLAC" "LRCX" "LLTC" "MRVL" "MXIM" "MCHP" "MU" "MSFT" "NTAP" "NWSA" "NVDA" "ORCL" "PAYX" "QCOM" "RIMM" "ROST" "SNDK" "STX" "SHLD"
[47] "SPLS" "SBUX" "SYMC" "URBN" "VOD" "WFM" "XLNX"
all other stocks work fine
this is the text from the file fileafc7f52710a specified in the error message
<!DOCTYPE html><html><head><script>(function(){(function(){function d(a){this.t={};this.tick=function(a,c,b){b=void 0!=b?b:(new Date).getTime();this.t[a]=[b,c]};this.tick("start",null,a)}var a=new d;window.jstiming={Timer:d,load:a};if(window.performance&&window.performance.timing){var a=window.performance.timing,c=window.jstiming.load,b=a.navigationStart,a=a.responseStart;0<b&&a>=b&&(c.tick("_wtsrt",void 0,b),c.tick("wtsrt_","_wtsrt",a),c.tick("tbsd_","wtsrt_"))}try{a=null,window.chrome&&window.chrome.csi&&(a=Math.floor(window.chrome.csi().pageT),
c&&0<b&&(c.tick("_tbnd",void 0,window.chrome.csi().startE),c.tick("tbnd_","_tbnd",b))),null==a&&window.gtbExternal&&(a=window.gtbExternal.pageT()),null==a&&window.external&&(a=window.external.pageT,c&&0<b&&(c.tick("_tbnd",void 0,window.external.startE),c.tick("tbnd_","_tbnd",b))),a&&(window.jstiming.pt=a)}catch(e){}})();})();
</script><title>Financial Statements for APPELL PETE CORP - Google Finance</title><meta name="Description" content="Get the detailed quarterly/annual income statement, cashflow statement, and balance sheet for APPELL PETE CORP (PINK:APPL). See revenue, expenses, profit, cash, assets, liabilities, shareholder’s equity and more for the lastest fiscal quarter/year for APPELL PETE CORP (PINK:APPL) on Google Finance."><meta http-equiv="X-UA-Compatible" content="IE=10"><link rel="stylesheet" type="text/css" href="/finance/f/finance_us-3578168175.css"><link rel="stylesheet" type="text/css" href="/finance/_/ss/a/ver=1b0b1eb0rwwhe/am=!xiAxGGlQxoffym1L/bf=/r=O"><link rel="icon" type="image/vnd.microsoft.icon" href="/finance/favicon.ico"><style>#gbar,#guser{font-size:13px;padding-right:8px;padding-top:4px !important;}#gbar{padding-left:8px;height:22px}#guser{padding-bottom:7px !important;text-align:right}.gbh,.gbd{border-top:1px solid #c9d7f1;font-size:1px}.gbh{height:0;position:absolute;top:24px;width:100%}#media all{.gb1{height:22;margin-right:.5em;vertical-align:top}#gbar{float:left}}a.gb1,a.gb4{text-decoration:underline !important}a.gb1,a.gb4{color:#00c !important}.gbi .gb4{color:#dd8e27 !important}.gbf .gb4{color:#900 !important}</style><script></script><script>
function _rpt() {}
function _tck() {}
</script></head><body><div class=fjfe-bodywrapper><div id=fjfe-real-body class=g-doc><input type="text" name="hist_state" id="hist_state" style="display:none;"><iframe id="hist_frame" name="hist_frame" class=invfr tabindex="-1"></iframe><iframe src="/finance/_/js/a/b/rt=h/ver=t5fUYABu0to.en_US./sv=1/am=!xiAxGGlQxoffym1L/d=0" class=invfr tabindex="-1"></iframe><div id=gbar><nobr><a class=gb1 href="http://www.google.com/webhp?hl=en&tab=ew">Search</a> <a class=gb1 href="http://www.google.com/imghp?hl=en&tab=ei">Images</a> <a class=gb1 href="http://maps.google.com/maps?hl=en&tab=el">Maps</a> <a class=gb1 href="https://play.google.com/?hl=en&tab=e8">Play</a> <a class=gb1 href="http://www.youtube.com/?tab=e1">YouTube</a> <a class=gb1 href="http://news.google.com/nwshp?hl=en&tab=en">News</a> <a class=gb1 href="https://mail.google.com/mail/?tab=em">Gmail</a> <a class=gb1 href="https://drive.google.com/?tab=eo">Drive</a> <a class=gb1 style="text-decoration:none" href="http://www.google.com/intl/en/options/"><u>More</u> »</a></nobr></div><div id=guser width=100%><nobr><span id=gbn class=gbi></span><span id=gbf class=gbf></span><span id=gbe></span><a href="http://www.google.com/support/finance?hl=en" class=gb4>Help</a> | <a target=_top id=gb_70 href="https://www.google.com/accounts/ServiceLogin?service=finance&passive=1209600&continue=http://www.google.com/finance?fstype%3Dii%26q%3DAPPL&followup=http://www.google.com/finance?fstype%3Dii%26q%3DAPPL" class=gb4>Sign in</a></nobr></div><div class=gbh style=left:0></div><div class=gbh style=right:0></div><div id=fjfe-click-wrapper><script>
(function() {
var l = window.location;
var q = l.search ? l.search.substr(1) : '';
var h = l.hash ? l.hash.substr(1) : '';
var p = '/finance';
var ss = 'stockscreener';
var conn = window.history && window.history.pushState ? '/' : '#';
if (l.pathname == p + '/' + ss) {
if (h) l.href = p + conn + ss + '?' + q + '&' + h;
} else if (l.pathname != p && h) {
l.href = p + l.hash;
}
if (h) {
document.getElementById('fjfe-click-wrapper').style.display = 'none';
}
})();
</script><div id=gf-head class="g-section g-tpl-75-25 g-split"><div class="g-unit g-first"><div class=fjfe-logo><img src="/finance/f/logo_us-115376669.gif" alt="Google Finance"></div><div id=gf-search class=fjfe-search><form method="get" action="/finance" autocomplete="off"><input class=fjfe-searchbox-input name=q type=text tabindex=1 value="PINK:APPL"></input><span class=fjfe-searchbox-button-wrapper><span class=fjfe-searchbox-button-wrapper2><input class=fjfe-searchbox-button type=submit tabindex=2 value="Get quotes"></input></span></span><input type=hidden name="ei" value="OudPUfCPNIeowAPQtQE"></input></form></div></div><div class="g-unit fjfe-promo"><div id="ad2-target" class="id-ad2-target"></div></div></div><div class=elastic><div id=app class="g-section g-tpl-left-11p4em"><div class="g-unit g-first"><div id=gf-nav><div class=fjfe-nav-nav><ul class=fjfe-nav id=navmenu><li class=fjfe-nav-item><div>Markets</div><li class=fjfe-nav-item><div>News</div><li class=fjfe-nav-item><div>Portfolios</div></ul></div><div class="fjfe-recentquotes fjfe-recentquotes-noquote"><h4>Recent Quotes <span class="fjfe-recentquotes-duration">(2 hours)</span></h4><div class=fjfe-recentquotes-noquote-notification>You have no recent quotes</div><div class=fjfe-recentquotes-quotes><div class="fjfe-toggle fjfe-toggle-button"><span class=fjfe-chg-toggle>chg</span> | <span class=fjfe-perc-toggle>%</span></div><div class=fjfe-table-div><table class=fjfe-recentquotes-table id=rq width=100%></table></div></div></div></div><script>var _cleardot = 'data:image/gif;base64,R0lGODlhAQABAIAAAP///////yH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==';
var google = google || {};
google.finance = google.finance || {};
google.finance.gce =false;</script><script src="/finance/f/sfe-opt-2862241303.js"></script><script>
_regOnLoad = function(f) {
if (document.readyState == 'complete') {
f && f();
} else {
// Window.attachEvent() for IE8 and below compatability.
var addEventFunction = window.attachEvent ||
window.addEventListener || function(ignored, f) { f(); };
var event = window.attachEvent ? 'onload' : 'load';
f && addEventFunction(event, f);
}
};
google.finance.renderRecentQuotes = function() {};
</script></div><div class=g-unit id=gf-viewc><div class=fjfe-content></div></div></div></div></div><div id=gf-foot><div class=fjfe-footer-links>Google Finance Beta available in: Hong Kong - Canada - U.S. - China - U.K.</div><p class=fjfe-footer-disclaimer>Information is provided "as is" and solely for informational purposes, not for trading purposes or advice, and may be delayed.<br>To see all exchange delays, please see disclaimer.</p><div class=fjfe-footer-links>©2013 Google - Google Home - Blog - Help - Report a Problem - Privacy Policy - Terms of Service</div></div></div></div><script>var googlefinance = {i: ["f.b.id","",,500,"",0,,["f.b.cf","t5fUYABu0to.en_US.",0]
,[]
,0,[["c388b5b8","true",2]
]
,"OudPUfCPNIeowAPQtQE","www.google.com"]
}; GF_domReady = 1;</script></body></html>

local objective vs. shared global objective

Please see the following manifest. The Activity_1's primary objective has mapInfo refers to
a Shared Global Objective with objective id = gObj-OB01a, but there is not any objective with objective id = gObj-OB01a. Is this manifest correct or not?
<organization identifier = "Course_1">
<title>Course 1 </title>
<item identifier = "activity_1" identifierref = "SEQ01">
<title>Activity 1</title>
<imsss:sequencing>
<imsss:objectives>
<imsss:primaryObjective objectiveID = "PRIMARYOBJ_1" >
<imsss:mapInfo targetObjectiveID = "gObj-OB01a" writeSatisfiedStatus = "true" />
</imsss:primaryObjective>
</imsss:objectives>
</imsss:sequencing>
</item>
<item identifier = "activity_2" identifierref = "SEQ01">
<title>Activity 2</title>
<imsss:sequencing>
<imsss:sequencingRules>
<imsss:preConditionRule>
<imsss:ruleConditions>
<imsss:ruleCondition condition = "satisfied"/>
</imsss:ruleConditions>
<imsss:ruleAction action = "skip"/>
</imsss:preConditionRule>
</imsss:sequencingRules>
<imsss:objectives>
<imsss:primaryObjective objectiveID = "PRIMARYOBJ_2" >
<imsss:mapInfo targetObjectiveID = "gObj-OB01a" />
</imsss:primaryObjective>
</imsss:objectives>
</imsss:sequencing>
</item>
<item identifier = "activity_3" identifierref = "SEQ01">
<title>Activity 3</title>
</item>
<imsss:sequencing>
<imsss:controlMode choice = "false" flow = "true"/>
</imsss:sequencing>
</organization>
Yes, it's correct. Notice that the primary objective "PRIMARYOBJ_2" is mapped to the global objective "gObj-OB01a" which means "PRIMARYOBJ_1" and ""PRIMARYOBJ_2" have the same tracking data in terms of Satisfied Status.

Loader Event Complete function only being called once

So, I'm trying to load resources, add them to a dictionary, and have a drawing method search through that dictionary and draw based on certain predicates. I have a function that iterates through an Vector of Strings, calling on an instance of Loader to load them instantiated as a URLRequest.
private function loadImages(urls:Vector.<String>):void
{
var loader:Loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE,completeHandler);
loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR,ioErrorHandler);
var loadResource:Function = function(item:String,index:int,vector:Vector.<String>):void
{
loader.load(new URLRequest(item));
}
urls.forEach(loadResource);
}
I then have an event handler that's handling the load completion, calling a drawing method that finds the Loaded bitmap in a Dictionary.
public function completeHandler(event:Event):void
{
var loader:Loader = Loader(event.target.loader);
var bm:BitmapData = new BitmapData(loader.width,loader.height,false);
bm.draw(loader,new Matrix());
this.bmDict[loader.contentLoaderInfo.url] = bm;
trace("complete handler" + loader.contentLoaderInfo.url);
trace(this.bmDict[loader.contentLoaderInfo.url]);
this.drawSprite(loader.contentLoaderInfo.url);
}
My drawsprite function
public function drawSprite(resourceUrl:String):void
{
var drawFunct:Function = function(spr:Dictionary,index:int,vector:Vector.):void
{
var sprRen:SpriteRenderer = new SpriteRenderer();
trace(resourceUrl.search("blue"));
trace(resourceUrl.search("drkOrange"));
trace(resourceUrl.search("green"));
trace(resourceUrl.search("ltblue"));
trace(resourceUrl.search("orange"));
trace(resourceUrl.search("pink"));
trace(resourceUrl.search("purple"));
trace(resourceUrl.search("red"));
trace(resourceUrl.search("yellow"));
trace(spr.color);
if((resourceUrl.search("blue") != -1) && (spr["color"] == 1)) {
var bigBm:BitmapData = sprRen.renderType(spr["type"],bmDict[resourceUrl]);
spr["sprite"].graphics.beginBitmapFill(bigBm,null,true,false);
spr["sprite"].graphics.drawRect(0,0,BIG_SPRITE_SCALE,BIG_SPRITE_SCALE);
spr["sprite"].graphics.endFill();
} else if ((resourceUrl.search("drkOrange") != -1) && (spr["color"] == 2)){
var bigBm:BitmapData = sprRen.renderType(spr["type"],bmDict[resourceUrl]);
spr["sprite"].graphics.beginBitmapFill(bigBm,null,true,false);
spr["sprite"].graphics.drawRect(0,0,BIG_SPRITE_SCALE,BIG_SPRITE_SCALE);
spr["sprite"].graphics.endFill();
} else if ((resourceUrl.search("green") != -1) && (spr["color"] == 3)){
var bigBm:BitmapData = sprRen.renderType(spr["type"],bmDict[resourceUrl]);
spr["sprite"].graphics.beginBitmapFill(bigBm,null,true,false);
spr["sprite"].graphics.drawRect(0,0,BIG_SPRITE_SCALE,BIG_SPRITE_SCALE);
spr["sprite"].graphics.endFill();
} else if ((resourceUrl.search("ltblue") != -1) && (spr["color"] == 4)){
var bigBm:BitmapData = sprRen.renderType(spr["type"],bmDict[resourceUrl]);
spr["sprite"].graphics.beginBitmapFill(bigBm,null,true,false);
spr["sprite"].graphics.drawRect(0,0,BIG_SPRITE_SCALE,BIG_SPRITE_SCALE);
spr["sprite"].graphics.endFill();
} else if ((resourceUrl.search("orange") != -1) && (spr["color"] == 5)){
var bigBm:BitmapData = sprRen.renderType(spr["type"],bmDict[resourceUrl]);
spr["sprite"].graphics.beginBitmapFill(bigBm,null,true,false);
spr["sprite"].graphics.drawRect(0,0,BIG_SPRITE_SCALE,BIG_SPRITE_SCALE);
spr["sprite"].graphics.endFill();
} else if ((resourceUrl.search("pink") != -1) && (spr["color"] == 6)){
var bigBm:BitmapData = sprRen.renderType(spr["type"],bmDict[resourceUrl]);
spr["sprite"].graphics.beginBitmapFill(bigBm,null,true,false);
spr["sprite"].graphics.drawRect(0,0,BIG_SPRITE_SCALE,BIG_SPRITE_SCALE);
spr["sprite"].graphics.endFill();
} else if ((resourceUrl.search("purple") != -1) && (spr["color"] == 7)){
var bigBm:BitmapData = sprRen.renderType(spr["type"],bmDict[resourceUrl]);
spr["sprite"].graphics.beginBitmapFill(bigBm,null,true,false);
spr["sprite"].graphics.drawRect(0,0,BIG_SPRITE_SCALE,BIG_SPRITE_SCALE);
spr["sprite"].graphics.endFill();
} else if ((resourceUrl.search("red") != -1) && (spr["color"] == 8)){
var bigBm:BitmapData = sprRen.renderType(spr["type"],bmDict[resourceUrl]);
spr["sprite"].graphics.beginBitmapFill(bigBm,null,true,false);
spr["sprite"].graphics.drawRect(0,0,BIG_SPRITE_SCALE,BIG_SPRITE_SCALE);
spr["sprite"].graphics.endFill();
} else if ((resourceUrl.search("yellow") != -1) && (spr["color"] == 9)){
var bigBm:BitmapData = sprRen.renderType(spr["type"],bmDict[resourceUrl]);
spr["sprite"].graphics.beginBitmapFill(bigBm,null,true,false);
spr["sprite"].graphics.drawRect(0,0,BIG_SPRITE_SCALE,BIG_SPRITE_SCALE);
spr["sprite"].graphics.endFill();
}
}
sprites.forEach(drawFunct);
}
So the issue is: Only the first images in my Vector are drawing. Upon further inspection, I found that the completeHandler was only being called once (I put a trace in the complete handler to check). However, the Loader is invoking load everytime the loop iterates. I tried instantiating separate loaders for each resource, just to see if it would work, but I had no luck with that. Do I need to make separate loaders and event handlers? Or am I just not using Loader correctly?
You are using only one loader to load multiple files in the same time, it can't work, a Loader can handle only one file at the same time.
So you need one loader by resource or load resources one by one if you want to use only one loader.

Resources