Hey Jakub.
Very nice, thanks for letting us know :)
As so often, once you figured out a certain solution, you can adopt it to other similar challenges as well.
In fact, this is the result and profit of experience !
Regarding your concern about the chg method.
In this case , you are calling a so called factory method, which is declared within a METHODS block within the chg FACTORY block in majic.
These kind of methods can be understood as global available methods, as you are specifying the "Full path" when calling them:
send_wait(0,
top_object(), "call_attr" , "
chg", "
start_itpam_workflow", ... );
Such a method could be declared in any factory in principal.
When calling/executing, you are specifying the concrete factory in which it is actually declared/available.
A second kind of methods are object methods. These are declared within a METHODS block within the OBJECT block in majic
Those can only be called for a specific instance of an OBJECT
In fact, in the example above, the "call_attr" method is an instance method of the TOP object.
Again, thanks for sharing.
Best Regards
....Michael
------------------------------
Principal Services Consultant
HCL Enterprise Studio
Germany
------------------------------
Original Message:
Sent: 04-26-2021 09:10 AM
From: Jakub Kolacny
Subject: Re: spel - save text to file
Hi Michael,
... and another project two years later ... :)
Below is the working spel example that triggers a PAM process on a request log comment. I found that even if I trigger a PAM process on a request action I still need to call a chg method start_itpam_workflow (I haven't found a corresponding method for the cr object).
OBJECT alg {
TRIGGERS {
POST_CI z_run_pam(persistent_id) 400001 FILTER(EVENT("INSERT") && (type == "LOG"));
};
};
alg::z_run_pam(...) {
logf(SIGNIFICANT, "SPEL STARTED: alg::z_run_pam for alg %s", argv[3]);
string process_path, process_name, text;
object alg_dob, cr_dob;
uuid who;
//get the current user uuid
send_wait(0,top_object(), "call_attr", "cnt", "current_user_id");
who=msg[0];
//get the alg object
send_wait(0, top_object(), "call_attr", "alg", "dob_by_persid", 0, argv[3], NULL, NULL);
alg_dob = msg[0];
//get the cr object
send_wait(0, top_object(), "call_attr", "cr", "dob_by_persid", 0, alg_dob.call_req_id, NULL, NULL);
cr_dob = msg[0];
logf(SIGNIFICANT, " ... alg::z_run_pam - corresponding request found: %s", cr_dob.ref_num);
process_path = "/TMP/Test/";
process_name = "simple_test";
text = "something clever";
send_wait(0, top_object(), "call_attr", "chg", "start_itpam_workflow", process_path, process_name, alg_dob.persistent_id, cr_dob, who, text);
logf(SIGNIFICANT, "SPEL ENDED: alg::z_run_pam for alg %s", argv[3]);
}

Original Message:
Sent: 03-28-2019 08:20 AM
From: Michael Müller
Subject: Re: spel - save text to file
Hi Jakub.
here is the example you might want to play with. I dont have a PA test System available, so I wasnt able to do any pre tests.
send_wait(0, top_object(), "call_attr", "chg", "start_itpam_workflow", (string)path, (string)name, (string)persid, (object)ticket_obj, (uuid)creator, (string)some_text);
path - seems to be related to the PA Hierarchie of start foms- corresponding to chgcat.caextwf_start_id.caextwf_path
name - seems to be a process Name or start form Name - corresponding to chgcat.caextwf_start_id.caextwf_form
persid - the persid - the alg persid in your case
ticket_obj - an object referencec of the actual ticket, I suggest to pass in the corresponding chg object
creator - the uuid of the contact which is doing this Action
some_text - the text which gets wriite to an activity log
Let us know, how you proceed.
Thanks
...........Michael