All values greater than X

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.

Any suggestions?

Subject: All values greater than X

REM {How you get the names of the approvers and their approval levels is up to you - lookup perhaps?};

approversByThreshold := “John Bigboote”:“John Whorfin”:“John Smallberries”;

approvalThresholds := 200:500:1000;

approvalAmountRequested := 50;

approvalThresholdsMet := @Sign(approvalThresholds - approvalAmountRequested);

x := @Member(“1”; @Text(approvalThresholdsMet));

@If(

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")

)

Subject: RE: All values greater than X

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

Subject: RE: All values greater than X

Sorry - I had gone one step further and offered the first approver that met a threshold for approval. Are you saying that if

approversByThreshold := “John Bigboote”:“John Whorfin”:“John Smallberries”:“John Yaya”;

approvalThresholds := 200:500:1000:2000;

approvalAmountRequested := 250;

then you would want to display a list containing everyone but John Bigboote (who is only authorized to approve up to 200)?

Subject: RE: All values greater than X

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.

Subject: RE: All values greater than X

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?};

approversByThreshold := “John Bigboote”:“John Whorfin”:“John Smallberries”:“John Yaya”;

approvalThresholds := 200:500:1000:2000;

approvalAmountRequested := 1000;

approvalThresholdsMet := @Sign(approvalThresholds - approvalAmountRequested);

x := @Member(“0”; @Text(approvalThresholdsMet));

@If(

x = 0;

@Set("x";@Member("1"; @Text(approvalThresholdsMet)));

""

);

allowableApprovers := @Trim(@LeftBack((approversByThreshold + “|” + @Text(approvalThresholdsMet)); “|1”) : @LeftBack((approversByThreshold + “|” + @Text(approvalThresholdsMet)); “|0”));

@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)

)

Subject: RE: All values greater than X

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.

just my two cents.

brandt

Subject: RE: All values greater than X

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};

approversByThreshold := “John Bigboote”:“John Whorfin”:“John Smallberries”:“John Yaya”;

approvalThresholds := 200:500:1000:2000;

approvalAmountRequested := 1000;

approvalThresholdsMet := @Sign(approvalThresholds - approvalAmountRequested);

x := @Member(“0”; @Text(approvalThresholdsMet));

@If(

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)

)

Subject: RE: All values greater than X

thankswill give it a go