Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

How to write 'If' formulas in designer?

Jen_Sav
Level 2
Level 2

Hi there,

I have just been given the task of converting all of our existing forms into livecycle designer and am struggling a little bit with the formula side of things. I am trying to create a form that calculates the amount of km's driven by the $ amount allocated for for the range of km's and then to give me a total, this is the formula i have created and the km's range i am trying to work with:

form1.#subform[0].Subform1.totalkms::calculate - (FormCalc, client)

if(kms120<200)thentotalkms=40.00elseif(kms201<520)thentotalkms=95.00elseif(kms521<700)thentotalkms=150.00elseif(kms701<1100 thentotalkms=223.00elseif(kms>1100)thentotalkms=273.00endif

Rates paid per kms (return)

120kms to 200km      $40.00

201km to 520km        $95.00

521km to 700km        $150.00

701km to 1100km      $223.00

>1100km                   $273.00

the problem with this formula not working is it always tells me that there is a "syntax error near token "thentotalkms" on line 1,column 26". I have tried to rewrite it so many different ways but it just doesnt seem to work.

I have attached the document for visual representation and hopefully someone can help me as i will be needing to use these quite a bit.

Thanks in advance

0 Replies
Garreth_Curran
Level 2
Level 2

If you change script language to JavaScript the following can be used:

var total;

if (kms.rawValue > 1100)
    {
        total = 273.00;
    }
else if (kms.rawValue > 700)
    {
        total = 223.00;
    }
else if (kms.rawValue > 520)
    {
        total = 150.00;
    }
else if (kms.rawValue > 200)
    {
        total = 95.00;
    }
else if (kms.rawValue > 119)
    {
        total = 40.00;
    }

this.rawValue = total;

pguerett
Level 10
Level 10

here is a modified version of your sample using FormCalc. You were close but when you reference the field that the user enters the number of Kms in then you must use the field reference only. Also writing the script in a single line will not work ...it must be seprated as I have done in my sample. You do not have to indent like I did but I do that so that it is easier to read and follow the flow for debugging.

Paul

Jen_Sav
Level 2
Level 2

Thank you so much for your response.

It was exactly what i needed to use.

Would all of my if formulas need to be similar to that if used in the same scenario?

Thanks again.

LindsayKr
Level 1
Level 1

Hello,

I am trying to write am IF/THEN formula within livecycle that allows the sum of two fields to remain zero if left empty and not exceed 0.60. The current formula I'm using looks like this:

if((CommunityService+participatioin)>0.60)then

          total(CommunityService+participatioin)=0.60

Any help/guidance you can provide will be helpful!

Thank you,

Lindsay