CA Service Management

 View Only
Expand all | Collapse all

Action Macro to skip WF Task

  • 1.  Action Macro to skip WF Task

    Posted Apr 16, 2017 05:18 PM

    Hi All,

    Please provide the action macro that needs to upload to change the  WF task Status to SKIP if the Change Order Type is Standard.

    Meanwhile when I am using this condition Change Type= Standard, no action is triggering if I add some action macro on above screen.So just to verify whether this condition is fine(I have created an Activity Association for Change Type with activity type Field update)

     

    Scenario 2: I want to change the Change Order Status to Approved when a Particular Approval Task is in Approve state .

    For that I tried to add an action macro, but could not see dropdown for Change Order

     

     

    I was thinking to add the below Action Macro but I could not find dropdown to select Change Order Action Macro.

     

    So how can I achieve that.

     

    Please help.

     

    CarolPiccus camja06 tzadell jmayer dukecityrebecca

     

     

    Thanks

    Manirul



  • 2.  Re: Action Macro to skip WF Task

    Posted Apr 17, 2017 04:06 AM

    Hi,

    you can try to implement this in this way:

    - create action macro for wf with followed code:

    if (chg.chgtype == 100) {
         send_wait(0, this, "call_attr", "status", "set_val", "SKIP", "SURE_SET");
         if (msg_error()) {
              int msg_i;
              for (msg_i=0;msg_i<msg_length();msg_i++) {
                   logf(ERROR, "msg[%d]: %s", msg_i, msg[msg_i]);
              }
              return;
         }
    }

    - open Workflow Template > Behaviour list > status PEND: add this macro to Action on true list;

    PS: condition included to the action macro but you can separate them if needed.

     

    If status change fails, you'll get detailed error in stdlog.

     

    Regards,

    cdtj



  • 3.  Re: Action Macro to skip WF Task

    Posted Apr 17, 2017 05:49 AM

    Hi cdtj

    I am trying to upload the action macro like this, but its giving error.

    TABLE Spell_Macro
     del description fragment lock_object ob_type sym type
     { "0" ,"Sets the Workflow Task Status to SKIP","if (chg.chgtype == 100)\\0012{\\0012send_wait(0, this, "call_attr", "status", "set_val", "SKIP", "SURE_SET");\\0012if (msg_error())\\0012{\\0012int msg_i;\\0012for (msg_i=0;msg_i<msg_length();msg_i++) {\\0012logf(ERROR, "msg[%d]: %s", msg_i, msg[msg_i]);\\0012}\\0012return;\\0012}\\0012}","1","wf","Set Workflow Task Status to SKIP","ACT" }

     

    Can somebody please point out the error.

     

    Thanks

    Manirul



  • 4.  Re: Action Macro to skip WF Task

    Posted Apr 17, 2017 05:56 AM

    Double quotes in logf and send_wait are not escalated, you can use single quotes instead:

    TABLE Spell_Macro
    del description fragment lock_object ob_type sym type
    { "0" ,"Sets the Workflow Task Status to SKIP","if (chg.chgtype == 100)\\0012{\\0012send_wait(0, this, 'call_attr', 'status', 'set_val', 'SKIP', 'SURE_SET');\\0012if (msg_error())\\0012{\\0012int msg_i;\\0012for (msg_i=0;msg_i<msg_length();msg_i++) {\\0012logf(ERROR, 'msg[%d]: %s', msg_i, msg[msg_i]);\\0012}\\0012return;\\0012}\\0012}","1","wf","Set Workflow Task Status to SKIP","ACT" }

     

    btw: my suggestion is to modify detail_macro.htmpl to have possibility to create/update code without any limitations.



  • 5.  Re: Action Macro to skip WF Task

    Posted Apr 17, 2017 06:38 AM

    Thanks cdtj. I could upload the action macro now.

    But its not working as expected. I have created a change order with type Standard but wf task is still in Pending status. It can not change status to skip.

     

    Can you please test once.

     

    Thanks

    Manirul



  • 6.  Re: Action Macro to skip WF Task

    Posted Apr 17, 2017 06:43 AM

    Could you check stdlog for details?



  • 7.  Re: Action Macro to skip WF Task

    Posted Apr 17, 2017 06:56 AM

    Hi cdtj

    This is what I could see in the log:-

     

    04/17 15:45:47.83 test spelsrvr 14620 ERROR Set Workflow Task St 9 msg[0]: wf.status::status_condition(): AHD05724:Not a valid transition.

     

    Thanks

    Manirul



  • 8.  Re: Action Macro to skip WF Task

    Posted Apr 17, 2017 07:03 AM

    Seems like you haven't SKIP status in your workflow template's behaviour. That means you can't perform status change without valid behaviour.



  • 9.  Re: Action Macro to skip WF Task

    Posted Apr 17, 2017 07:22 AM

    I actually updated the skip transition in Approval but it did not updated in attached approval tasks. I would have to verify before testing. My mistake. Thanks a lot cdtj .

     

    Secondly, I want to change the Change Order Status to approved if a approval task is complete.How can I achieve that.

     

    Thanks

    Manirul



  • 10.  Re: Action Macro to skip WF Task

    Posted Apr 17, 2017 08:44 AM

    I recommend to don't change status directly from macro but attach an event instead.

     

    You need to have:

    - chg event with attached action macro, call it CHG2APP for example;

    - action macro that will change chg's status, some of them are presented out-of-the-box (name starts with Set CHG status);

     

    First recomendation - check this doc: SPEL EVENT methods 

    To reduce routine you can create SPL file with followed function and call it when you need to attach an event:

    // ------------------------------------------------------//
    //
    // FileName: z_new_evt.spl
    //
    // ------------------------------------------------------//
    //
    // Input arguments (* - required):
    //          evtkey*           - event name or event persistent_id
    //          obj_id*           - object persistent_id
    //          timeout           - timeout in seconds. Default: 15
    //          group_name           - group name. Default: EMPTY
    //          delayed_start     - delayed start flag. Default: 0 (false)
    //
    //     cdtj71@gmail.com
    //     2016-12-06
    //
    // ------------------------------------------------------//

    string evt::z_new_evt(string evtkey, string obj_id, ...) {
         string group_name;
         duration timeout;
         int i, delayed_start;
         object gl, new_atev;
         
         delayed_start = 0;

         timeout = 15;

         for (i=0;i<argc;i++) {
              logf(SIGNIFICANT, "argv[%d]: %s", i, argv[i]);
         }

         if (sindex(evtkey, 'evt:') == 0) {
              send_wait(0, top_object(), "call_attr", "evt", "val_by_key", "persistent_id", evtkey, 1, "sym");
              evtkey = msg[1];
         }
         if (argc > 2) {
              timeout = argv[2];
         }
         if (argc > 3) {
              if (!is_empty(argv[3])) {
                   group_name = argv[3];
              } else {
                   group_name = (string)NULL;
              }
         }
         if (argc > 4) {
              delayed_start = (int)argv[4];
         }

         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]);
              }
              return;
         }
         gl = msg[0];
         
         send_wait(0, top_object(), "call_attr", "evt", "new_attached_event", gl, obj_id, (string)evtkey, (duration)timeout, now(), group_name, 0, delayed_start, "");
         if (msg_error()) {
              for (i=0;i<msg_length();i++) {
                   logf(ERROR, "msg[%d]: %s", i, msg[i]);
              }
         } else {
              new_atev = msg[0];
              send_wait(0, gl, "checkin");
              if (msg_error()) {
                   logf(ERROR, "evt [%s] is not attached to [%s] with [%d] delay", evtkey, obj_id, timeout);
              } else {
                   logf(SIGNIFICANT, "evt [%s] is attached to [%s] with [%d] delay", evtkey, obj_id, timeout);
                   return new_atev.persistent_id;
              }
         }
    }

     

    Next step:

    - create action macro with followed code and execute it when you need to attach an event:

    evt::z_new_evt('CHG2APP', chg.persistent_id);

    this will attach event with name CHG2APP to your change orded with 15 sec delay.

     

    Regards,

    cdtj



  • 11.  Re: Action Macro to skip WF Task

    Posted Apr 17, 2017 12:15 PM

    Hi Manirul - to update a ticket's status based on a workflow status update, we did the following.  We just created an action macro, then attached that action macro to the workflow task (we do this for a couple of ticket statuses).

    1. create action macro

    Create Action Macro

    2. Go to Request Area > Workflow tab

    3. Select Task > Workflow Template Detail

    4. In Behavior section, select the status that will trigger your action (in our case, a request area's last task going to  "Complete" status is the trigger)

    5. Add macro to Update Actions on True

    Attach macro to task's behavior



  • 12.  Re: Action Macro to skip WF Task

    Posted Apr 25, 2017 02:09 AM

    Thanks cdtj and dukecityrebecca for your help . It worked. 

    The same way I am trying to send email to the wf task assignee when CO is in Approval Pending and wf task is in Pending state. I can send notification to wf task assignee whenever a Ticket is created. But that's not required.

     

    I tried the same procedure to attach event and send notification.

    Action Macro:- 

    if(chg.status == 'PNDAP' && status == 'PEND')
    {
    evt::z_notify_evt('NotifyPendingApp', chg.persistent_id);
    }

     

    Log:-

    But I dont see assignee is getting notification.Can you please look into this.

     

     

    Thanks

    Manirul



  • 13.  Re: Action Macro to skip WF Task

    Posted Apr 25, 2017 02:23 AM

    Hi,

    everything seems ok, but if your goal is to notify task's assignee why you're attaching event to chg not wf?

    if ( (chg.status == 'PNDAP') && (status == 'PEND') ) {
        evt::z_notify_evt('NotifyPendingApp', persistent_id);
    }

    Regards,

    cdtj



  • 14.  Re: Action Macro to skip WF Task

    Posted May 02, 2017 02:28 AM

    Hi cdtj,

    The sad part is, its not attaching the event since I modified the action macro.

     

    Thanks

    Manirul



  • 15.  Re: Action Macro to skip WF Task

    Posted May 02, 2017 02:41 AM

    you can add little logging info before conditions:

    logf(SIGNIFICANT, "%s > Change Status: %s", persistent_id, chg.status);
    logf(SIGNIFICANT, "%s > Workflow Status: %s", persistent_id, status);

    Maybe your inputs didn't match the condtions.

     

    Regards,

    cdtj



  • 16.  Re: Action Macro to skip WF Task

    Posted Apr 25, 2017 10:31 AM

    Hi Manirul - when you attach the macro to the task's Action Behavior, be sure to add an Object Contact for Group and/or Assignee (we send to both).

    1. Per task > per status > attach appropriate macro (we label these as message template macros since their purpose is to notify people)

    WF notify 1

    2. To notify, use macro type = Multiple Notification and add Object Contacts for group and/or assignee

    WF notify 2

    3. The multiple notification macro includes a Message Template which must have Auto Notification = Yes, and be Object Type = R/I/P Workflow Task (or Change Task)

    WF notify 3



  • 17.  Re: Action Macro to skip WF Task

    Posted Apr 27, 2017 03:36 AM

    Thanks a lot cdtj and dukecityrebecca



  • 18.  Re: Action Macro to skip WF Task

    Posted Feb 01, 2018 08:17 AM

    Hi guys,

     

    I have this scenario on my enviroment:

     

    On the task 1, if the status is APP then the two next tasks should be canceled.

    If the status on the 1st task is APP2 then the next task should be pending and the third one should be waiting.

     

    How can I create a action macro to this behavior?