Skip to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Loop and If Statement

Featured Replies

My quotes are correct i was just trying to distinguish the field names. As for exiting the script, i don't want it to exit even if the circumstance is true, i want it to keep looping through the rest of my found records.

OK, let's try it with some sample data:

Let's say that:

Record 1: Months Due = 1

Record 2: Months Due = 2

In both records,

Months = 3

Due = ""

The first record should return {result}:

Loop

. Set Field(Months Due, Months Due + 1) ... {1 + 1 = 2}

. If(Months Due = Months) ... {2 notequal.gif 3}

.. Set Field(Due, "Due") ... {""}

. End If

. Go to Next Record, Exit after last

End Loop

The next record should return:

Loop

. Set Field(Months Due, Months Due + 1) ... {2 + 1 = 3}

. If(Months Due = Months) ... {3 = 3}

.. Set Field(Due, "Due") ... {Due}

. End If

. Go to Next Record, Exit after last

End Loop

Everything looks right to me! All I can say is insert a bunch of Pauses in your script and see what's going on after each step.

Another option would be to use a couple of Replace commands instead of a loop. You'd have to test to see if it was any faster.

  • Author

I have this step in script:

Loop

Set Field("Months Due" , "Months Due" + 1)

Go to Next Record, Exit after last

End Loop

This works to increment my months by one, however when it reaches a certain referenced number (my field "Months"), i need a "Due" field box checked. So, i added this step in the loop before the Go to Next Record:

If("Months Due" = "Months")

Set Field("Due", "Due")

End If

(the second Due is my value field for "Due")

When i did this it made each record = it's "Months" (instead of +1) and checked the "Due" box.

What am i doing wrong??

Hi, try an Exit Loop If step in there.

Loop

Set Field("Months Due" , "Months Due" + 1)

Exit Loop If [Months Due = Months]

Go to Next Record

End Loop

Looks right to me. Are you typing in the script steps or constructing them by selecting fields and calcs? Because this:

Set Field("Months Due" , "Months Due" + 1)

... should look like this:

Set Field("Months Due" , "Months Due + 1")

... and this:

If("Months Due" = "Months")

... should be:

If("Months Due = Months")

Only difference is placement of quote marks.

  • Author

Oh, i see what you are saying... i read it wrong at first. I have what you said , and it does look right, however, for some reason, it make all my records = the months and checks them as due. (instead of just one upping the number) It doens't look like it should do that but, it does. any body else have a suggestion or see the prob? Thanks!

Again, I suggest: insert Pauses in your script and see what's happening after each step as you go through the loop.

  • Author

Sorry... i've been out of town... But i don't want the records to add to each other. They are independent of each other.

Let me hazard a guess: when you added in the If steps, did you create them by duplicating and dragging? If so, have you mistakenly left some of the steps unadjusted? For all the records to change, you must have an If test that is always true - something like

If (Due = Due)

SetField (Months Due, Months)

SetField(Due,"Due")

Instead of

If(Months Due = Months)

SetField(Due,"Due")

This is so easy to do when scripting quickly and dragging a step you already used. I've done it many a time...

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.