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.

[Script + IWP] If statement working in client, but not in IWP

Featured Replies

Hello,

Here is the situation ???

I have a script that goes to a layout, checks alls the records to see if a defined field is equal to "1" (number field) and if it is it should delete this records. After it has checked all the records, it gets backs to its original layout.

The problem is that it seems that the line :

'IF [my_table::my_field = 1]'

is working fine in FMP 9 client, but is not working in IWP. So it always gets to the "Else" statement.

I've tried different writings such as

'IF [my_table::my_field = "1"]'

or :

'Set Variable [$selected, my_table::my_field]

IF [$selected = 1]

etc, and none works in IWP.

If anyone can help me, thank you.

  • Author

Ok, I haven't found the solution to this exact problem, but I did it differently.

I had forgot to mention there was a "find" querry, and I added "my_field" = 1 in the find querry, then I just delete all the found results and I don't need the IF at all.

Anyway, the explaination to the original problem would be interesting.

Edited by Guest

  • Author

Hello,

the alternative solution was worse because sometimes (only using IWP) the script did not go to the right form and once it deleted the whole data base instead of just the records I want.

So the question remains ???

Why do 'If [$variable = 1]' work in Filemaker Pro but does NOT work in Instant Web Pusblishing (it always goes to the 'else' statement)

(The rest of the script work and is IWP compatible.)

Make sure you go to the correct layout before you find. Your need to be on the correct table occurrence.

  • Author

Hello, thank you. Anyway I've completely given up the idea to use the multiple layouts to delete things ... it went to the right layout in FMP (100% of time) and to the right layout in IWP (but i'd say only 90% of time) ... Also I haven't found a way to skip the error when there are no records found ... because the script should have been able to find zero records, and then continue, do nothing, go back to previous layout, and end ... but it keep asking for records ...

I'm now trying to delete directly in the portal (and it works in FMP, but I've got troubles with IWP)

Now, my question remains:

Why do 'If [$variable = 1]' work in Filemaker Pro but does NOT work in Instant Web Pusblishing (it always goes to the 'else' statement)

(The rest of the script work and is IWP compatible.)

You need to post a demo of your script. You are doing something wrong, and I'll help, but continuing with pseudo-scripts is a waste of time.

  • Author

Ok sorry, I'm rather new to FMP. Is there a way to export a script as text ??

Here's the whole script ???


Commits Records/Requests[No Dialog]

Go to Object [Object Name:"portal-name" & Get (Scriptparameter)]

Go to Portal Row [First]

Loop

  Set Variable [$selected; value:my-table::a-field-that-can-contain-0-or-1]

  If[$selected = "1"]

    Delete Portal Row [No Dialog]

    Go to Object [Object Name:"portal-name" & Get (Scriptparameter)]

    Go to Portal Row [First]

  Else

    Go to Portal Row [Next; Exit after last]

  End If

End Loop

Some things may seem useless, but I did not get it to work correctly another way (and relatively correctly in IWP).

How about:

pseudo-code, because on Windows I can't copy scripts:


If (not isempty (Parent::Child_marked) using a relationship that not only matches on the parent key, but matches a constant "1" to the checkbox)

 Go to Related Records (Parent::Child_marked)

 Show Dialog, "Delete " & Get (FoundCount) & " Records?" 1=Cancel 2=Delete All

   If (get (lastmessagechoice = 2 )

     Delete All Records (no dialog)

   End If

 Go to Layout (Parent Form)

Else

 Show Dialog, "No Records Marked for Deletion"

End If



  • Author

Ok, I'll try this next time. For now, can you help me with the script I wrote in my last post ? I mean the script is ok like this ?

  • Author

Thank you, but if I do not go back to the portal using the "Go to object + Go to first row" commands, when I go to the next row, it goes in another portal.

After some tests, I'm still conviced that the IF statement is the key of the problem ...

  • Author

Well, the "selected" field's type was set to "Text". I set it to "Number" and the problem seems to be solved in my script.

Thank you anyway.

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.