CA Service Management

  • 1.  Action Macro that will change the change order type

    Posted Oct 18, 2017 12:53 PM

    I wrote an Action Macro that will change the change order type from Standard to Normal under certain conditions.  The spellcode is chg.chgtype = '200';  I am not getting an error message but the macro doesn't seem to be working.  I am not getting anything in the log.  



  • 2.  Re: Action Macro that will change the change order type
    Best Answer

    Posted Oct 18, 2017 01:03 PM

    if it is from wf task the try the following code

      uuid who;  

     send_wait(0,top_object(), "call_attr""cnt""current_user_id"); 

      who=msg[0];  

      send_wait(0, top_object(), "call_attr""api""update_object_super", who, chg.persistent_id, 0"chgtype ", 200);  

     

    if from change chg  

     

     uuid who;  

     send_wait(0,top_object(), "call_attr""cnt""current_user_id"); 

      who=msg[0];  

      send_wait(0, top_object(), "call_attr""api""update_object_super", who, persistent_id, 0"chgtype ", 200);  



  • 3.  Re: Action Macro that will change the change order type

    Posted Oct 21, 2017 05:07 PM

    Hi Patsy-VA  - did Giedrius' post help you out on this one?  As you know its not something within my scope that I can assist with, but Giedrius is great!  He is super helpful and know a lot of tricks with code to help folks out.

    Jon I.



  • 4.  Re: Action Macro that will change the change order type

    Posted Oct 23, 2017 05:10 AM

    HI,

    You are passing a string when the chgtype is an SREL to chgtype.id and be an integer so just use like below and this will already work assuming nothing is already locking your object:

    chg.chgtype=200;

    Also It's look like you do it from a WF task so make sure your macro have the lock object flag set to Yes.

    Another code below, just to add to the discussion as the one from Giedrius Bekintis must work already.

    object chg_dob;
    send_wait(0, this, "call_attr", "chg", "get_dob");
    if (msg_error())
    {
    logf(ERROR, format("unable to retrieve change order associated to wf"));
    return;
    }
    chg_dob= msg[0];
    if(!is_null(chg_dob))
    {
    send_wait(0, top_object(), "get_co_group");
    if (msg_error())
    {
    logf(ERROR, "get_group_leader () failed: %s", msg[0]);
    return;
    }
    object gl;
    gl = msg[0];
    send_wait(0, gl, "checkout", chg_dob);
    if (msg_error())
    {
    logf(ERROR, "Error checking out dob, error: %s", msg[0]);
    return;
    }
    chg_dob.chgtype=200;
    send_wait(0, gl, "checkin");
    }

    My 2 cents

    /J