1
votes

There is a computed numeric field called: Sum. As its name says, it is basically a percent, that changes every time a user completes other fields. Initially, it is 100 (%).

I created a configuration zone where there is a view with 2 columns:

         Minimum value | Names
-------------------------------------
            60          Name1, Name2
-------------------------------------
            30          Name3
-------------------------------------
            15          Name5

So, when Sum <= 60 it should notificate the names: Name1, Name2 ( but only once ). Also, when Sum reaches the immediate value lower than 30 => notification for Name3( only one time ), and finally when the numeric field Sum reaches the immediate value lower than 15 => notification for another Name5 fixed in the configuration zone, also one time only. ( The reason why I want to @MailSend only one time is that when, let say, Sum=20 => the first two @MailSend not to be effectuated any more, because they ran when the Sum was, for example in first case, =59.61, and, respective, =29.14 ).

What I did tried:

I tried creating some computed fields ( hidden , as flags ) with the default value = 0. And when the first notification goes just verify if the flag value is 0 and change then the value to 1. But, if the admin creates in the configuration zone let say 10 minimum values for Sum, should I create each flag for this 10 values?

I appreciated your time and your help.

2

2 Answers

1
votes

Get all Sum values from view's first column and send mail for every entry which is less or equal than field Sum if mail wasn't send yet. Here is a untested sample formula code just to get an idea how it could work:

_SumViewList := @DbColumn(...; 1);
@Transform(_SumViewList; "_SumView";
    @If(Sum <= _SumView & !(MailSentFor = @Text(_SumView));
            @Do(    @MailSend(@DbLookup(...; _SumView; 2); ...);
                    FIELD MailSentFor := @Trim(MailSentFor : @Text(_SumView)));
            ""))
0
votes

check if newminimum is in range, and then if oldminimum is out of range

perphaps a array helps you

dim minimum(3) as integer
dim sendTo(3) as string
dim x as integer

minimum(0) = 0
minimum(1) = 10
minimum(2) = 30
minimum(3) = 70

sendTo(0) = "nameA"
sendTo(1) = "nameB"
sendTo(2) = "nameC"
sendTo(3) = "nameD"

x=0

newminimum = oldminimum + newvalue
do until x=UBound(minimum)
    if newminimum >= minimum(x) and newminimum >= minimum(x+1) 
         if oldminimum < minimum(x) then
                'send mail to Usergroup sendTo(x)
            end if
    end if
    x=x+1
loop