A different way of creating workflow items within an Application Engine program.
When you want to create workflow items in an Application Engine program, you have to build a component, that will generate the workflow items. In the Application Engine program you will use a component interface to make use of the component.
Often when you have to loop through data and update data using a component interface in an Application Engine program, you will create a loop and within the loop you will perform a component interface “get” for every item you want to update or you want create a workflow item for.
We tried out a different approach, where we created a component with a grid, in which we loaded all the items where we wanted to create a workflow item for. So we needed to open the component interface only once. In the Application Engine we looped through the buffer and performed a save for every record in the grid:
&oKpBotsWfCi = &oSession.GetCompIntfc(CompIntfc.KP_BOTS_WF_CI);
If &oKpBotsWfCi = Null Then
Error MsgGet(30520, 2, “Bericht niet gevonden”);
End-If;
If Not &oKpBotsWfCi.Get() Then
Error MsgGet(30520, 3, “Bericht niet gevonden”);
End-If;
&oKpBotsWfVwCollection = &oKpBotsWfCi.KP_BOTS_WF_VW;
For &i = 1 To &oKpBotsWfVwCollection.Count;
If Not &oKpBotsWfCi.Save() Then;
Error MsgGet(30520, 5, “Bericht niet gevonden”, &oKpBotsWfCi.EMPLID);
End-If;
End-For;
In the component code we put PeopleCode so that at every save action, a workflow item was created for next record in the grid. To be a able to do that, we defined a component integer variable, a counter, where we kept track of the recordnumber in the grid.
In the SavePreChange PeopleCode we copied the data needed for the workflowitem to a work record on level 0 of the component buffer. Also there we incremented the counter.
In the component workflow event we put the code to generate the workflow, which was based on the values of the fields from the work record on level 0 of the component.
A different way of creating workflow items within an Application Engine program.
When you want to create workflow items in an Application Engine program, you have to build a component, that will generate the workflow items. In the Application Engine program you will use a component interface to make use of the component.
Often when you have to loop through data and update data using a component interface in an Application Engine program, you will create a loop and within the loop you will perform a component interface “get” for every item you want to update or you want create a workflow item for.
We tried out a different approach, where we created a component with a grid, in which we loaded all the items where we wanted to create a workflow item for. So we needed to open the component interface only once. In the Application Engine we looped through the buffer and performed a save for every record in the grid:
&oSession = GetSession();
&oSession.Connect(1, “EXISTING”, “”, “”, 0);
&oKpBotsWfCi = &oSession.GetCompIntfc(CompIntfc.KP_BOTS_WF_CI);
If &oKpBotsWfCi = Null Then
Error MsgGet(30520, 2, “Bericht niet gevonden”);
End-If;
If Not &oKpBotsWfCi.Get() Then
Error MsgGet(30520, 3, “Bericht niet gevonden”);
End-If;
&oKpBotsWfVwCollection = &oKpBotsWfCi.KP_BOTS_WF_VW;
For &i = 1 To &oKpBotsWfVwCollection.Count;
If Not &oKpBotsWfCi.Save() Then;
Error MsgGet(30520, 5, “Bericht niet gevonden”, &oKpBotsWfCi.EMPLID);
End-If;
End-For;
In the component code we put PeopleCode so that at every save action, a workflow item was created for next record in the grid. To be a able to do that, we defined a component integer variable, a counter, where we kept track of the recordnumber in the grid.
In the SavePreChange PeopleCode we copied the data needed for the workflowitem to a work record on level 0 of the component buffer. Also there we incremented the counter.
Component integer &iCount;
Local Rowset &rsBots;
Local Record &rcBots;
&rsBots = GetLevel0()(1).GetRowset(Scroll.KP_BOTS_WF_VW);
&rcBots = &rsBots(&iCount).GetRecord(Record.KP_BOTS_WF_VW);
/* Fields containing input for creating workflowitems */
KP_BOTS_DERIVED.EMPLID.Value = &rcBots.EMPLID.Value;
KP_BOTS_DERIVED.KP_BOTS_ID_NBR.Value = &rcBots.KP_BOTS_ID_NBR.Value;
&iCount = &iCount + 1;
In the component workflow event we put the code to generate the workflow, which was based on the values of the fields from the work record on level 0 of the component.
Viewed 3922 times by 980 visitors
Related posts: