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.

If/Loop Field

Featured Replies

Hi,

I'm having trouble completing a script that will go through a table and check off in the radio button. The field I'm investigating is state abbreviations where the radio button "US Resident" will be marked off as 'Yes' or 'No.' The times that I have tried to run the script has not produced the intended result.

Loop

Go to Record/Request/Page [First]

If[tour::Partner State="AL" or "AK" or "AS" or "AZ" or "CA" or "CO" or "CT" or"DE" or "DC" or "FM" or "FL" or "GA" or "GU" or "HI" or "ID" or "IL" or "IN" or "IA" or "KS" or "KY" or "LA" or "MA" or "MH" or "MD" or "MA" or "MI" or "MN" or "MS" or "MO" or "MT" or "NE" or "NV" or "NH" or "NJ" or "NM" or "NY" or "NC" or "ND" or "MP" or "OH" or "OK" or "OR" or "PW" or "PA" or "PR" or "RI" or "RI" or "SC" or "SD" or "TN" or "TX" or "UT" or "VT" or "VI" or "VA" or "WA" or "WV" or "WI" or "WY"

Set Field [tour::US Resident; tour::P="Yes"]

Else If[ doubttour::Partner State ≠ "AL" or "AK" or "AS" or "AZ" or "CA" or "CO" or "CT" or"DE" or "DC" or "FM" or "FL" or "GA" or "GU" or "HI" or "ID" or "IL" or "IN" or "IA" or "KS" or "KY" or "LA" or "MA" or "MH" or "MD" or "MA" or "MI" or "MN" or "MS" or "MO" or "MT" or "NE" or "NV" or "NH" or "NJ" or "NM" or "NY" or "NC" or "ND" or "MP" or "OH" or "OK" or "OR" or "PW" or "PA" or "PR" or "RI" or "RI" or "SC" or "SD" or "TN" or "TX" or "UT" or "VT" or "VI" or "VA" or "WA" or "WV" or "WI" or "WY" or "FC" = (tour::US Resident = "No")

End IF

Go to Record/Request/Page [Next]

End Loop

Okay:

a) Each and every one of your comparisons needs to have the field name next to it, e.g: tour::Partner state = "AL" or tour::Partner state="AK" ...

but that takes forever, so instead use this:

If[ PatternCount( List( "AL" ; "AK"; "AS" ; "AZ" ; "AZ" ; "CA" ; ... etc ) ; tour::Partner State)]

:P Your set Field Looks Funny -- is tour:: a typo?

c) I'm not sure what happened to your second else if statement, seems to kind of just fad after WY... i mean what's with: "FC" = (tour::US Resident = "No" )?

d) Your loop doesn't seem to terminate anywhere? In the Go to Record / Request / Page script step setup, make sure you check, exit after last (its located down the bottom when you are setting the step up).

Oh and e) Go to First Record should be outside the loop (i.e. before the loop starts)

Let me know how you get on.

Edited by Guest

GenX pretty well covered the apparent problems with your script as posted. A couple of further ideas:

1. Since your Else If statement doesn't really add anything to your If statement -- it's just the negation of it as far as I can tell -- it's not necessary. A plain Else will do.

E.g., it's not necessary to say:

If [a = a]

Set Field[answer;"yes"]

Else If [a <> a]

Set Field[answer;"no"]

End If

##

It's simpler / more efficient to write it:

If [a = a]

Set Field[answer;"yes"]

Else

Set Field[answer;"no"]

End If

##

Some people might write the whole thing in one step:

Set Field[answer; Case(a = a;"yes";"no")]

2. You may already have your list of states in a value list (let's say "States"). If so, there is a function you can use to compare, similar to what GenX posted:

If[ PatternCount( ValueListItems(Get(FileName);"States") ; tour::Partner State)]

Another approach would be to make a table with one record for each state. You could then compare your tour::Partner State to this table. Possible advantages of this structure: ease of maintenance and flexibility.

  • 3 weeks later...
  • Author

Sorry I haven't responded earlier. "FC" is "Foreign Country." I tried running the script but the it only came up with all the records that have "FC" in the Partner State field. Even when Partner State equals any of the state abbreviations, it doesn't check in the radio box as 'Yes.'

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.