CA Service Management

Expand all | Collapse all

Declaring objects SPEL

  • 1.  Declaring objects SPEL

    Posted Sep 14, 2015 01:13 PM

    hi ALL,


    Does anyone know how I can assign values to an object variable constructed manually in SPEL?
    Declaring the object is easy.
    zo_object object ;
    I want to assign attributes and values for this new object :
    zo_object.name = 'Daniel' ;
    zo_object.age = 39 ;
    Does anyone have any tips ?



  • 2.  Re: Declaring objects SPEL

    Posted Sep 14, 2015 03:32 PM

    Hi here is example for attached event object

     

    send_wait(0, top_object(), "get_co_group");

      if (msg_error()) {

       logf(ERROR, "%s - %s", ref_num, msg[0]);

      }

     

      evt_group_leader1 = msg[0];

      send_wait( 0, top_object(), "call_attr", "atev", "get_new_dob", NULL, NULL, evt_group_leader1);

     

      if (msg_error()) {

       logf(ERROR, "%s - %s", ref_num, msg[0]);

      }

     

      attached_events_table_record1 = msg[0];

      attached_events_table_record1.obj_id = persistent_id;

      attached_events_table_record1.event_tmpl = "evt:400034";

      attached_events_table_record1.wait_time = dur;

      send_wait(0, evt_group_leader1, "checkin");

     

      if (msg_error()) { 

       logf(ERROR, "%s - %s", ref_num, msg[0]);

      }



  • 3.  Re: Declaring objects SPEL

    Posted Sep 15, 2015 07:47 AM

    Hi gutis ,
    It's not that I have difficulty.
    I know declare an object variable to store information of an incident object, change, problem, etc.
    What I need is to declare an object that is not in the data model. Imagine an object that would be only used for storing temporary information from one method to another .
    The SPEL methods can deliver in return an object containing information. Thing that is not possible with an array.
    I hope it was clear .
    Anyway, thanks for the help .



  • 4.  Re: Declaring objects SPEL

    Posted Sep 14, 2015 03:35 PM

    You may also check this doc SPEL API methods, look for insert_object method, i think is much simpler than described above.



  • 5.  Re: Declaring objects SPEL

    Posted Sep 15, 2015 08:05 AM

    Hi,

    I'm looking for the same functional,

    I have noticed that object generated by Webengine OP can handle any keys without predefinition.

    example:

    object obj;

    obj = argv[1];

    obj.TEST = "hello!";

    logf(SIGNIFICANT, "%s", obj.TEST); // Will display "hello!"



  • 6.  Re: Declaring objects SPEL

    Posted Sep 15, 2015 10:12 AM

    Me too... I'm looking the same functional,

    Thanks cdtj.



  • 7.  Re: Declaring objects SPEL

    Posted Feb 18, 2017 01:04 AM
    I found a way to declare and create a object in top_object.

    void z_myMethod()
    {
        object zo_obj;
        zo_obj = z_createObject();
        
        printf("Object: '%s'\n", (string) zo_obj);
        printf("# '%s'\n", zo_obj.attr1);
        printf("# '%s'\n", zo_obj.attr2);
    }

     

    object z_createObject(...)
    {
        send_wait(0, this, "call_attr", 'attr1', "set_val", 'test1');
        send_wait(0, this, "call_attr", 'attr2', "set_val", 'test2');
        return this;
    }

    Have fun.



  • 8.  Re: Declaring objects SPEL

    Posted Feb 18, 2017 01:18 AM

    Good one, really good  I have spent a lot of time but didn't find solution. Many thanks for sharing!



  • 9.  Re: Declaring objects SPEL

    Posted Feb 18, 2017 09:42 AM

    Me too. I spent much time with this. But fortunatelly yesterday i found a solution.



  • 10.  Re: Declaring objects SPEL

    Posted Feb 18, 2017 01:27 AM

    Good one!!! I also was looking for such possibility. Daniel i think you should write the separate document on this. I realy hate when i need to look for solutions inside discussions. Thank you for sharing this with us!



  • 11.  Re: Declaring objects SPEL

    Posted Feb 18, 2017 09:44 AM

    I Will do It. Thanks!



  • 12.  Re: Declaring objects SPEL

    Posted Feb 20, 2017 08:00 AM