Tuesday, February 8, 2011

Retrieving an Record Problem

Okay, that may not be the best subject...

I am setting up an approval workflow within an application. I pass the username and the dollar amount to the subprocedure and figure out what workflow I need to use for the approval process. I thought I had this working until I try to handle the condition when the user hasn't been setup.

So in my table I have:

wfid    wfuser    wfamt
1         user1      0
2         user2      0
2         user2      10000.00

Now if user3 tries to send something to the workflow, it shouldn't go becuase they are not setup. (Please note I have another table that contains the actual flow definition)

I had this code to retrieve the correct workflow:

     setgt (userId:amount) ARWFR1;
     readp ARWFR1;
     return wfid;

Obviously this works if the user is properly setup. However, throw our user3 sinareo back in and it won't work right. So then I tried:

     setgt (userId:amount) ARWFR1;
     readpe (userId) ARWFR1;
     if (%eof());
       return 0;
     endif;
     return wfid;

This is not working as I had expected. I am sure I am missing obvious, can you see it? I hope my current logic is clear enough.

0 comments:

Post a Comment