Hi,I am trying to solve a problem regarding approval levels for purchases.
we have a purchase order request system where a user will request something to be bought and this then gets approved and sent to purchasing.
The approver has a monetary level to which they are allowed approve e.g. £100, £500 etc.
I want the requestor to be able to select an approver from the list based on the amount of the request.
e.g.: Requestor wants something that costs £350, they should only be able to choose from approvers who can approve £350 or more.
The problem I am facing is that the approval level can be anything and the request amount can be anything, so the picklist would have to be created on the fly.
x > 0;
@Prompt([Ok]; "OK"; "Approval required from " + @Subset(@Subset(approversByThreshold; x); -1));
@Prompt([Ok]; "Holy sh.."; "You have asked for way too much money and nobody can approve that amount")
That is my last resort.I am trying to cut down on the list that is presented to the user in the first place by only showing approvers that can approve the document
Yes, they would need to be able to choose the one they want.e.g. they would need to be able to choose their own line manager from several that may be in the dept.
OK, I can’t help you with determining who their managers are - like I said, those you would have to do through some sort of lookup. In any case, the code below is just meant to show you how to use the numbers to generate selection lists. Rather than issuing @Prompt. you will likely take the resulting values in the variable allowableApprovers and put them into the choices for your approvers listbox/radio button.
REM {How you get the names of the approvers and their approval levels is up to you - lookup perhaps?};
x = 0;
@Prompt([Ok]; "Holy sh.."; "You have asked for way too much money and nobody can approve that amount");
x = @Elements(approversByThreshold);
@Prompt([Ok]; "OK"; "Approval required from " + allowableApprovers);
@Prompt([OkCancelList]:[NoSort]; "OK"; "Approval required from one of"; ""; allowableApprovers)
If I can throw my two cents in here (since I am working on a similar project spec) I would make a suggestion to make this much easier.
What I would do is create a “Person” type doc in the database that allows you to specify the manager’s name, their department and the dollar threshold. then I would do a lookup based on the dollar amount and populate a hidden field with the values that correspond to both the department and the threshold. At that point I would then create a keyword field that uses the hidden field for the choice list.
I would probably do this in LotusScript in the exit event of the field, but you could probably pull it off using the formula language Cesar has posted and calling @Command([ViewRefreshFields]) when a dollar amount is selected.
The lookup for the approver is the correct approach but you can’t lookup on a value using inequality. A lookup will either find the exact value (the threshold) or it will not. So if the thresholds are
200
500
1000
2000
and the requested value is 850, this value will not be found and the lookup will fail. You have to retrieve all thresholds and then use @Formula (as I suggested) or Script to remove managers whose approval threshold is too low.
Subject: All values greater than X - slight modification
REM {How you get the names of the approvers and their approval levels is up to you - lookup perhaps?};REM {Presumably, both approversByThreshold and approvalThresholds would be synchronized and sorted by increasing values in approvalThresholds};
x = 0;
@Set("x";@Member("1"; @Text(approvalThresholdsMet)));
""
);
allowableApprovers := @Trim(@LeftBack((approversByThreshold + “|” + @Text(approvalThresholdsMet)); “|0”) : @LeftBack((approversByThreshold + “|” + @Text(approvalThresholdsMet)); “|1”)); REM {Put the zero first in the list - it should match the lowest and not the highest amount};
@If(
x = 0;
@Prompt([Ok]; "Holy sh.."; "You have asked for way too much money and nobody can approve that amount");
x = @Elements(approversByThreshold);
@Prompt([Ok]; "OK"; "Approval required from " + allowableApprovers);
@Prompt([OkCancelList]:[NoSort]; "OK"; "Approval required from one of"; ""; allowableApprovers)