Archive for the 'eScript' Category

Activate all workflows

1. in simulator create new script with method Service_PreInvoke
2. in methods create new one ActAll
3. in simulator run new script with method ActAll by button Run

function Service_PreInvokeMethod (MethodName, Inputs, Outputs) {
 if (MethodName=="ActAll")
 {
  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);
}

While cycle

		var boActSet		= TheApplication().GetBusObject("ABO Bulk Request");
		var bcActSet		= boActSet.GetBusComp("ABO Bulk Request Action Set");

		var IsRecord;

		with (bcActSet)
		{
			ClearToQuery();
			ActivateField("Due Date");
			SetSearchSpec("Bulk Request Id", '12345');
			ExecuteQuery(ForwardOnly);

			IsRecord = FirstRecord();
			while(IsRecord)
			{
				SetFieldValue("Due Date", 'xx');
				WriteRecord();

				IsRecord = NextRecord();
			}
		}