Clarity Service Management

Expand all | Collapse all

Check condition macro via spel

Jump to Best Answer
  • 1.  Check condition macro via spel

    Posted 08-31-2015 06:01 AM

    Hi team!

    I'm looking a way to extend objects that have possibility to perform condition check like events, notifications and status transitions have.

     

    Directly I have chg workflows which are added on some conditions,

    currently these conditions are predefined and very limited,

    so I wish to extend that limitations via site-defined conditions.

     

    I have found that macros are executed by method called execute.

    Here is a place where I have stuck, no more ideas.

    object new_obj;
    send_wait(0, top_object(), "call_attr", "macro", "dob_by_persid", 0, "macro:403912");
    new_obj = msg[0];
    send_wait(0, new_obj, "execute", this);
    int j;
    if (msg_error()) {
      for (j=0;j<msg_length();j++) {
      logf(ERROR, "msg[%d]: '%s'", j, msg[j]);
      }
    }
    
    
    
    

     

    Log:

    Spell interp failed at macro.spl:357:macro::execute: Arg message [1]: bad index - size is 1

    msg[0]: 'macro.spl:357:macro::execute'

    msg[1]: 'Arg message [1]: bad index - size is 1'

     

    Here is another method to execute macros : execute_macro_object(object);

    But it returns error state and cannot be used for my purposes.

     

    upd: got totally stuck and switched to workaround soltution:

    1. created string attribute called z_condition;

    2. used sync_fetch with where_clause from z_condition to get amount of matches if more than 1 means condition validated.

     

    Regards

    cdtj



  • 2.  Re: Check condition macro via spel

    Posted 08-31-2015 03:38 PM

    This method is defined on macro object, so you can execute it in the following way:

    macro::execute(object,....);

     

    I would guess that for the first parameter you should define some particular incident, change, workflow or other attribute as the object, second parameter may be one of the following attributes of the macro - code, id or persid.

    This is some pseudocode that may work

     

    int result //have no clue what type of output we may expect

    result = macro::execute(this,"macro:403912");



  • 3.  Re: Check condition macro via spel

    Posted 08-31-2015 03:43 PM

    I may also try to change your code in following way:

     

    send_wait(0, top_object(), "execute", this, "macro:403912"); 

    if (msg_error()) { 

    for (j=0;j<msg_length();j++) { 

      logf(ERROR, "msg[%d]: '%s'", j, msg[j]); 

      }

    }



  • 4.  Re: Check condition macro via spel

    Posted 08-31-2015 03:50 PM

    Thank you for reply Gutis,

    as I found object (top object) should be the macro. So I get it via dob by persid. Logs make me sure that I'm started correct :)

    But all of attributes (have tried to pass up to 5 attributes) also should be objects I tried to place group leader, affected object, empty object or other random object but have no luck.

    Regards.



  • 5.  Re: Check condition macro via spel
    Best Answer

    Posted 08-31-2015 05:18 PM

    I have site-defined condition that is checking if cr priority is 1. The following code returned 0 if priority was not equal 1, and 1 when priority was 1

     

     

    string test(...)
    {
    object crobj, macroobj;
    send_wait(0, top_object(), "call_attr", "cr", "dob_by_persid", 0, "cr:400767"); 
    crobj = msg[0];
    send_wait(0, top_object(), "call_attr", "macro", "dob_by_persid", 0, "macro:20216"); 
    macroobj = msg[0];
    send_wait(0, macroobj,"execute", crobj,NULL,NULL,NULL,NULL,NULL,NULL); 
    int j; 
    for (j=0;j<msg_length();j++) { 
    printf("msg[%d]: '%s'", j, msg[j]); 
    }
    }
    


  • 6.  Re: Check condition macro via spel

    Posted 09-01-2015 02:15 AM

    you're genius! I lost my hope to achieve that.



  • 7.  Re: Check condition macro via spel

    Posted 09-01-2015 04:31 AM

    This time I was more lucky than you