Performing Post-Processing for Action Items
You can define a PeopleCode application class and method to perform post-processing on an action item after the user has completed the transaction—for example, to update the status of the action item to complete. For post-processing, the method name must be called ItemPostProcess. Post-processing can occur on the local system or the remote system if that’s where the transaction is hosted.
Important:
Post-processing can occur on the local system or the remote system if that’s where the transaction is hosted. Post-processing is executed through component save processing only. If you have implemented a custom save button on the page to save the component, the button’s page field properties must be configured to invoke the toolbar save action or the PeopleCode executed by these buttons must include either the DoSave or DoSaveNow built-in functions to trigger the component save events; otherwise, the post-processing specified here will not be executed.
Example 1
In the first example, the class has been developed by implementing and extending the PTAI_ACTION_ITEMS:AGInterface interface class. The ItemPostProcess method defines the post-processing that will occur for this action item.
import PTAI_ACTION_ITEMS:AGInterface;
import PTAI_ACTION_ITEMS:ActionItem;
import PTAI_ACTION_ITEMS:Constants;
class IB_GATEWAY implements PTAI_ACTION_ITEMS:AGInterface
method IB_GATEWAY();
rem method InstanceCreation(&list As PTAI_ACTION_ITEMS:List);
rem method PageletPreProcess(&list As PTAI_ACTION_ITEMS:List);
rem method ItemPreProcess(&item As PTAI_ACTION_ITEMS:ActionItem);
method ItemPostProcess(&list_id As string, &item_id As string, &Nodename As string);
end-class;
/* constructor */
method IB_GATEWAY
end-method;
method ItemPostProcess
/+ &list_id as String, +/
/+ &item_id as String, +/
/+ &Nodename as String +/
/+ Extends/implements PTAI_ACTION_ITEMS:AGInterface.ItemPostProcess +/
Local PTAI_ACTION_ITEMS:Constants &PTAI_CONSTANTS = create PTAI_ACTION_ITEMS:Constants();
Local PTAI_ACTION_ITEMS:ActionItem &item = create PTAI_ACTION_ITEMS:ActionItem();
Local boolean &ret;
Local string &connurl;
Local string &defaulturl = "http://machinename:port/PSIGW/PeopleSoftListeningConnector";
Local number &count;
/*** Debug Test ***/
rem MessageBox(0, "", 0, 0, "I'm being triggered");
&item.open(&item_id);
/*** Add logic to check for step completion ***/
SQLExec("select connurl from psgateway where local_flag='Y'", &connurl);
SQLExec("select count(*) from psconn", &count);
If All(&connurl) And
(&connurl <> &defaulturl) And
&count > 0 Then
&item.Status = &PTAI_CONSTANTS.STATUS_COMPLETED;
Else
&item.Status = &PTAI_CONSTANTS.STATUS_IN_PROGRESS;
End-If;
/*** Save the Action Item State ***/
&ret = &item.save();
end-method;
Example 2
In this second example, the ItemPostProcess method includes conditional logic that handles execution differently depending on whether the transaction is on the local node or a remote node. If the ItemPostProcess method is executing on the remote node for the remote transaction, then it uses the PTAI_UPDATEITEM service operation to update status on the local node.
import PTAI_ACTION_ITEMS:*;
Declare Function SecuritySyncMessage PeopleCode PTUN_NODECFGDVW.PTUN_BTN FieldFormula;
Declare Function IsLocalNode PeopleCode PSPTCSSRVDEFN.PTCS_SERVICEURLTYP FieldFormula;
method ItemPostProcess
/+ &list_id as String, +/
/+ &item_id as String, +/
/+ &Nodename as String +/
Local boolean &boolSaved;
Local PTAI_ACTION_ITEMS:ActionItem &ObjAItem;
Local PTAI_ACTION_ITEMS:Constants &AIConstants;
Local string &Status, &Priority;
Local string &Required;
Local number &PercCompl, &Seqno;
&AIConstants = create PTAI_ACTION_ITEMS:Constants();
/* Test values */
&Status = &AIConstants.STATUS_COMPLETED;
&Priority = "1";
&Required = "Y";
&PercCompl = 100;
rem &Seqno = 35;
If Not IsLocalNode(&Nodename) Then
Local Message &Req_Msg, &Response;
Local XmlDoc &requestDoc;
Local number &i1;
Local XmlNode ¤tParamsNode;
Local array of XmlNode &SuccessNode, &errorNode;
Local string &ResponseXml;
Local SOAPDoc &TransformedDoc;
&Req_Msg = CreateMessage(@("Operation." | "PTAI_UPDATEITEM"), %IntBroker_Request);
&requestDoc = CreateXmlDoc(GetHTMLText(HTML.PTAI_UPDATEITEM_REQ, %UserId, GetHTMLText(HTML.PTAI_UPDATEITEM_REQ_PARAMS, &item_id, &list_id, &Nodename, &Priority, &Status, &Required, &PercCompl, &Seqno)));
&Req_Msg.SetXmlDoc(&requestDoc);
&Response = SecuritySyncMessage(&Req_Msg, &Nodename, "PTAI_UPDATEITEM");
If &Response <> Null Then
&ResponseXml = &Response.GenXMLString();
&TransformedDoc = CreateSOAPDoc(&ResponseXml);
&SuccessNode = &TransformedDoc.DocumentElement.GetElementsByTagName("SAVESUCCESS");
&errorNode = &TransformedDoc.DocumentElement.GetElementsByTagName("ERRORMSG");
If &SuccessNode <> Null And
&SuccessNode.Len = 1 Then
rem do nothing;
End-If;
If &errorNode <> Null And
&errorNode.Len = 1 Then
Error "Error from Application hosting Activity Guide : " | &errorNode [1].NodeValue;
End-If;
Else
Error "No Response from IB";
End-If;
Else
&ObjAItem = create PTAI_ACTION_ITEMS:ActionItem();
&ObjAItem.open(&item_id);
&ObjAItem.Status = &Status;
&ObjAItem.Priority = &Priority;
If &Required = "Y" Then
&ObjAItem.Required = True;
Else
&ObjAItem.Required = False;
End-If;
&ObjAItem.PercCompl = &PercCompl;
If All(&Seqno) Then
&ObjAItem.Sequence = &Seqno;
End-If;
&boolSaved = &ObjAItem.save();
End-If;
end-method;