Saturday, April 20, 2013

AWE Workflow Application Class Criteria

I had a little trouble creating my first App Class criteria so I thought I would share some tips on how to write an App Class for use as AWE criteria. Here are the primary secrets:

  • Your App Class must extend EOAW_CRITERIA:DEFINITION:CriteriaBase (PTAF_CRITERIA:DEFINITION:CriteriaBase for 9.0 apps).
  • Your constructor must take a Record definition as a parameter.
  • Your constructor must set %Super by passing the criteria's ID. The following example uses the criteria ID value specified in the parameter record.
  • Your App Class must implement the Check(&bindRec_ As Record) Returns boolean method.

Here is a sample template:

import EOAW_CRITERIA:DEFINITION:CriteriaBase;

class MyCriteria extends EOAW_CRITERIA:DEFINITION:CriteriaBase
   method MyCriteria(&REC_ As Record);
   method Check(&bindRec_ As Record) Returns boolean;
end-class;

method MyCriteria
   /+ &REC_ as Record +/
   %Super = create EOAW_CRITERIA:DEFINITION:CriteriaBase(&REC_.EOAWCRTA_ID.Value);
end-method;

method Check
   /+ &bindRec_ as Record +/
   /+ Returns Boolean +/
   /+ Extends/implements EOAW_CRITERIA:DEFINITION:CriteriaBase.Check +/
   REM ** TODO evaluate something here;
   Return True;
end-method;

30 comments:

Pavan said...

Hi Jim,

I have tried using your code in my Program as Criteria , but its not working .

Thanks

Jim Marion said...

@Pavan, can you elaborate? How do you know it isn't working? Are you getting an error message?

Chris said...

Jim - Thanks for your books and blog - solid stuff.

On a related note to this post, I have several step and path app package criteria working as expected. What I am struggling with is the 'definition criteria' for which i would expect a False return code to disable WF for the transaction assuming criteria is met. Now according to PBooks the definition criteria is 'used to determine which Definition ID is to be used to process the Approval'

So I am looking at either pointing to a definition that has no WF OR adding the criteria to every step...

Have you ever done something similar? Suggestion? Thanks in advance.

Chris said...

Jim - Following up on my own comment - Ii was able to continue researching and found oracle support ticket Is it Possible to Setup Approval Workflow to Work With Multiple Approval Definition IDs? [ID 1134294.1].

Essentially this boils down to the fact that you can have multiple definitions configured for each approval process - the logical path being active status, default definition and effective date. If you return a False code in the default it will continue to cycle through the the active definitions.

Thanks for letting me bounce the idea off of you, hopefully another reader finds this thread useful!

Jim Marion said...

@Chris, thank you for sharing both the problem and resolution.

A "Well" developed work flow will allow definition criteria to select the right definition. I have, however, seen work flows that hard code the definition ID. Obviously, in that case, it won't cycle through the list of definitions. And, like you said, it iterates over the collection of definitions until it finds one that returns true.It is my experience that if none return true, it will fall silently... basically the case where there is no work flow.

Chris said...

Jim -
My current expectation is that returning False in from the approval definition criteria would bypass approval for the transaction as you stated. But this is not the case for me - a false return code continues to process the default definition...unless another definition is configured. Currently i have configured another definition that will always self-approve (or i can setup the second definition to bogus criteria) but it seems odd to have to configure this separately. Once i can come up for air, i will trace to find out why. Thanks again.
Chris

Jim Marion said...

@Chris, what you are seeing is correct. If they all return false, then the default will be used. If there is no default, then there would be nothing to use.

Chris said...

Thanks again. What is your recommendation when in the following situation: IF the req has an origin of ONL then process WF else no workflow is required?

Jim Marion said...

@Chris, I'm sure there are a dozen ways to solve this. Here are a couple that came to mind:

* self approve by having the approver user list return the logged in user.

* Auto approve in the OnProcessLaunch event.

MattY said...

Hi Jim:

I have a question related to AWE notifications for a specific event. Here is what I am encountering:

For the "Final Approval" event, I have configured three separate notifications to be generated -- all with the Participant = User List (different User Lists for each).

However, I have noticed that only the FIRST of the three notifications is being generated upon Final Approval. Is this an issue with how the AWE notifications execute or is there something that can be done within configuration to ensure delivery of all notifications?

Thanks!

Jim Marion said...

@MattY, just to make sure I understand correctly... In the Transaction Configuration, do you have multiple rows with the same Event: "On Final Approval"? I can't say that I've tried that. I haven't looked into the code to see why it is behaving the way you described either. Perhaps there is an SQLExec in there to find rows by type rather than a loop? That would certainly behave the way you are describing. It would be nice if what you describe were supported. Perhaps an alternate method would be to create a query, app class, or SQL user list that combined all of three into a single user list? I'm sure you could make that work with an app class user list.

MattY said...

Thanks Jim. Yes - I have multiple rows in the Transaction Configuration for the same event.

The problem with combining the three different users into a single User List is that I have three different notifications that are being generated. Different content & different recipients for each.

We'll investigate to determine if we can incorporate a loop in the code so it will execute all the rows. Thx

Thor said...

Has anyone had success creating custom AWE Line Level Approval? I’m having trouble trying to get the OnLineApprove method to fire. I have header level working so I decided to dig deeper. I added the keys to the Xref table, Updated the Registry, Configured the Events, added the method to my event handler, and created a new Process Definition using line level (very simple “Always True”). I have seen OnProcessLaunch fire so my routing has begun. But when my approver hits the Approve button, it saves and nothing happens to the approval. Tracing it show that the method does not fire. How does the system know to fire the line level method vs the header level method? Any ideas are appreciated.

Thor

Jim Marion said...

@Thor, I have not worked on line level approvals. You may want to post your question on the PeopleSoft General OTN Forum.

Thor said...

Thanks Jim, I just posted the question.

Kunal Tyagi said...

Hi Jim ,
First of all, let me tell you that your posts have been immensely helpful to all the peoplesoft developers out there. They are precise, to the point and very accurate. Thank You.

Now coming to my query....

How do we get the reference to step number in the “Check” method of App Package class which is used for evaluating the Step Criteria in a AWE transaction.

I need to run this criteria for all steps in advance when the user initially clicks on submit button.So I need something which tells me what is the step “Check ” method is currently evaluating …


In UserList Class, I am able to find the reference to Step Number by using this
/*get the current step*/
&nStepnbr = %This.step.step_nbr

I need something similar in Step Criteria App Package, i have tried numerous things but no use, kindly help me out .

Jim Marion said...

@Kunal, a very good question. I do not know the answer off the top of my head. What I can't remember is the contents of the constructor &REC parameter and the check &bindRec parameter. You should print out the names of those records (log file or something). If the &bindRec has all of the header values, etc, then you could get a reference to the ApprovalManager which has an AppInst, stage and txn.

Please post back when you figure it out.

satish kumar said...

Jim,

Can we pass values to the class, like POI_ID. If yes, Can you please eloborate.

Thanks

satish kumar said...

Jim,

Can we pass parametes to the definition criteria or Can we capture the non keys from cross reference record. I need PO_ID, Is there any way, please elaborate.

Jim Marion said...

@Satish, short answer to both questions is "yes." You do this through one of the two records passed into the constructor or the check method. Unfortunately, I like I told @Kunal, I can't remember what those record variables contain. I wish I had documented that piece. I recommend printing the record names. From there, you can determine the SQL needed to investigate the transaction records or xref values.

Srini.B.Reddy said...

Hi Jim,
I used the code from your book 'webservice enabling approvals' to update the approval status using sync service. When there are multiple approval steps (this is Requisition process), only first step gets approved whereas the subsequent steps are updated to skipped and the Requisition status is updated to approved.
When approved from the online page, it is routed to the next step/ approver just fine.
Any pointers for me on what to look for?

Jim Marion said...

@Srini, Congratulations on getting the web service working! I have only done header level approvals and have not looked into the line level approvals API.

Srini.B.Reddy said...

Hi Jim,
I am doing header level approval too. But when there are multiple approval steps, first step is approved and the second one's status turns to skipped.
Whereas if I approve from the online page, it gets routed to second step just fine. I am not understanding what am I doing differently when I call doapprove?

Saurav Suman said...

Hello Jim,

First of all many thanks for the blog. Secondly, I'm working on Line level AWE. I need some help.

Suppose I've 5 lines for approval. 3 of them for level 1 approval and other two will undergo level 1 approval followed by level 2 approval.

On the second level approval page, I want to show only the 2 lines that need approval and the approval status of these two in monitor. Not for all the 5.

Please help me how it can be achieved.

Thanks,
Saurav

Jim Marion said...

@Saurav, I have no experience with line level approvals. I suggest you post your question on the PeopleSoft OTN Discussion Forum.

Pavan Chaitanya N said...

Hi JIM,

Auto-approve is not working in one of our client after upgrading the tools from 8.52 to 8.53.

My process has "Auto Approval" checkbox enabled and "self approval" for that particular step is enabled with "Always True" criteria.

It's a line level approval.

Can you please help me??


Jim Marion said...

@Pavan, I suggest you log a support case with Oracle support for something like this.

Pavan Chaitanya N said...

Thanks for the reply Jim.. Few days back i was facing problem in Self-approval.. the code you shared in this blog was very helpful...Thanks a lot for that..

Pavan Chaitanya N said...

JIM,

Gone through Chapter 3 i.e Workflow configuration.. it is very informative :)

Jim Marion said...

@pavan, I am very glad that you find this information and the book content useful.