• Resolved barnez

    (@pidengmor)


    Hi,

    I am using the following equation in a quotation form here, and I would like to return a minimum fee in the calculated field (e.g. 8.00). Is this possible?

    (function(){
    var n;
    if( fieldname7<=5000 )
    {
        switch( fieldname8 )
        {
            case 5: n=2; break;
            case 4: n=1.5; break;
            case 3: n=1; break;
            case 2: n=0.9; break;
            case 1: n=0.8; break;
        }
    }
    else if( fieldname7<=10000 )
    {
        switch( fieldname8 )
        {
            case 5: return "-> Contact us"; break;
            case 4: n=2; break;
            case 3: n=1.5; break;
            case 2: n=1; break;
            case 1: n=0.9; break;
        }
    }
    else if( fieldname7<=25000 )
    {
        switch( fieldname8 )
        {
            case 5: return "-> Not available"; break;
            case 4: return "-> Contact us"; break;
            case 3: n=1.5; break;
            case 2: n=1; break;
            case 1: n=0.9; break;
        }
    }
    else if( fieldname7<=45000 )
    {
        switch( fieldname8 )
        {
            case 5: return "-> Not available"; break;
            case 4: return "-> Not available"; break;
            case 3: return "-> Contact us"; break;
            case 2: n=1.5; break;
            case 1: n=1; break;
        }
    }
    else
    {
        switch( fieldname8 )
        {
            case 5: return "-> Not available"; break;
            case 4: return "-> Not available"; break;
            case 3: return "-> Not available"; break;
            case 2: return "-> Contact us"; break;
            case 1: n=1; break;
        }
    }
    if( typeof n != "undefined" )
    {
    return '£'+PREC((fieldname5*fieldname7*fieldname9+(fieldname7*fieldname20)+(fieldname7/1000*fieldname21*6))*fieldname10*n,2);
    }
    return '';
    })()

    https://www.ads-software.com/plugins/calculated-fields-form/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author codepeople

    (@codepeople)

    Hi,

    You simply should use the “MAX” operation in the return of the equation, for example, your current equation’s return is:

    return '£'+PREC((fieldname5*fieldname7*fieldname9+(fieldname7*fieldname20)+(fieldname7/1000*fieldname21*6))*fieldname10*n,2);

    Modifies it as follows:

    return '£'+PREC(MAX(8,(fieldname5*fieldname7*fieldname9+(fieldname7*fieldname20)+(fieldname7/1000*fieldname21*6))*fieldname10*n),2);

    and that’s all.
    Best regards.

    Thread Starter barnez

    (@pidengmor)

    Thank you codepeople!
    As always, your advice is quick, precise and effective.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Return a mininum value in the calculated field’ is closed to new replies.