Thursday, December 30, 2010

Activate all workflows

1. in simulator create new script with method Service_PreInvoke
2. in methods create new one "ActivateAll"
3. in simulator run new script with method ActivateAll by button Run
function Service_PreInvokeMethod (MethodName, Inputs, Outputs) {
 if (MethodName=="ActivateAll")
 {
  var sErr=""
  var bo=TheApplication().GetBusObject("Front Office Workflow");
  var bc=bo.GetBusComp("Repository Workflow Process Read Only");
  var sId;
  bc.ClearToQuery();
  bc.SetViewMode(AllView);
  bc.ActivateField("Status");
  bc.SetSearchExpr("[Status] = LookupValue ('WFR_DSGN_STAT_CD','COMPLETED')");
  bc.ExecuteQuery(ForwardOnly);
  var irec=bc.FirstRecord();
  while (irec) {
   sId=bc.GetFieldValue("Id");
   try {
    bc.InvokeMethod("Activate");
   }
   catch (e) {
    sErr+="|Id: " + sId + " >> " + e.toString();
   }
   irec=bc.NextRecord();

  }
  Outputs.SetProperty("SErrors", sErr);
  return (CancelOperation);

 }

 return (ContinueOperation);
}

No comments :

Post a Comment