CA Service Management

 View Only
  • 1.  is there any way insert workflow tasks using a spel

    Posted Oct 07, 2016 06:36 AM

    Hello,

     

    is there any way insert workflow tasks using a spel?

     

    Thanks



  • 2.  Re: is there any way insert workflow tasks using a spel

    Posted Oct 07, 2016 07:01 AM

    There is add_workfow method defined on api object. I never used it so You need to find out how it is working. It contaimc the following definition:

    add_workflow (uuid, string, string, string, int, ... );

    and

    add_workflow (userid, objid, wf, task, param_start_idx)

     

    Most probably those params means the following:

     

    userid - user that performs action

     

    objid - change id

     

    wf - persisten id of workflow task template (should not be used in conjunction with task parameter)

     

    task - task code (should not be used in conjunction with wf parameter)

     

    param_start_idx - most probably Identifies the object handle of an existing workflow task after which the new workflow task is to be inserted (but it may also be sequence or place in the array of workflow tasks)

     

    So this may be example of the call when you need simply to insert task without behaviour template"

     

    send_wait(0,top_object(), "call_attr", "cnt", "current_user_id"); 
    who=msg[0]; 
    send_wait(0, top_object(), "call_attr", "api", "add_workflow", who, "chg:156514", NULL,  "APP", "wftmpl:40001"); 



  • 3.  Re: is there any way insert workflow tasks using a spel

    Posted Nov 01, 2016 06:12 AM

    Sorry for necroposing  

    I have figured how to insert workflow task using general method, here is the code:

     

    void grpWf(...) {
         logf(SIGNIFICANT, ">> insert wf start");

         object gl, wfobj, chg, prevwf, wftpl, new1, new2;
         int i, msg_i;

         send_wait(0, top_object(), "call_attr", "wf", "dob_by_persid", 0, "wf:1174756");
         prevwf = msg[0];

         send_wait(0, top_object(), "call_attr", "wftpl", "dob_by_persid", 0, "wftpl:427324");
         wftpl = msg[0];

         send_wait(0, top_object(), "call_attr", "chg", "dob_by_persid", 0, "chg:496215");
         chg = msg[0];
         
         send_wait(0, top_object(), "get_co_group");
         if (msg_error()) {
              for (i=0;i<msg_length();i++) {
                   logf(ERROR, "msg[%d]: %s", i, msg[i]);
              }
         }
         gl = msg[0];
         
         send_wait(0, top_object(), "call_attr", "wf", "add_workflow_task",
                                       gl,                                        // group leader
                                       chg,                                   // parent (change, issue)
                                       "PEND",                                   // new status
                                       (uuid)NULL,                              // asset
                                       (uuid)prevwf.creator,               // creator
                                       (string)"TST_EXTR_APP",               // code
                                       (object)wftpl,                         // wf template
                                       (uuid)prevwf.assignee,               // assignee
                                       (duration)NULL,                         // est_duration
                                       (int)NULL,                              // est_cost
                                       (date)NULL,                              // est_completion_date
                                       (int)0,                                   // unknown int, not DB attr
                                       (int)0,                                   // another unknown int, not DB attr
                                       (int)(prevwf.sequence + 10)          // sequence
                                  );
         if (msg_error()) {
              for (i=0;i<msg_length();i++) {
                   logf(ERROR, "msg[%d]: %s", i, (string)msg[i]);
              }
              return;
         } else {
              for (i=0;i<msg_length();i++) {
                   logf(SIGNIFICANT, "msg[%d]: %s", i, (string)msg[i]);
              }     
         }
         new1 = msg[0];     // new wf object
         new2 = msg[1];     // new chgalg object
         
         send_wait(0, new1, "call_attr", "comments", "set_val", "Created via SPL", "SURE_SET");
         send_wait(0, new1, "call_attr", "group", "set_val", prevwf.group, "SURE_SET");
         
         send_wait(0, new2, "call_attr", "description", "set_val", format("%s\nCreated via SPL", new2.description), "SURE_SET");
         
         send_wait(0, gl, "checkin");
         if (msg_error()) {
              for (i=0;i<msg_length();i++) {
                   logf(ERROR, "msg[%d]: %s", i, msg[i]);
              }
              send_wait(0, gl, "uncheck");
         }
         logf(SIGNIFICANT, "<< insert wf end");
    }

     

    The only way you need to use it, is possibility to create multiple workflows in a single iteration (checkin) and possibility to control Change Activity Log.

     

    Regards,

    cdtj