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.

Set (dynamical) Field in ScriptMaker

Featured Replies

Hi,

I want to avoid long "If/ElseIf...ElseIf/EndIf" sections in ScriptMaker by dynamically set a field.

Please, let me explain...

I have (among other fields) un-editable date fields (simply called date_01, date_02, etc.) and I don't want the users to edit these fields manually (to avoid month/day vs. day/month errors).

Each date field has a "calendar" button that calls a script (with the field number as parameter). This script stores the parameter value in a dummy field then goes to a calendar layout where the user clicks on a day button (user can change year/month of course). This will trigger another script that brings him/her back to the original layout and fills the appropriate date field with the selected date (from the dummy field).

This works great (it's all transparent to the user), but I'm worried about the future. I have just 8 date fields and my "back from calendar" script have enough "ElseIf" lines, but eventually I could end up with 16 (or more) date fields and I will have a very long script...

Here's the QUESTION:

Is there a way to dynamically specify a field in a "Set Field" script step? In other words, can I "Set Field [calculated field name; calculated/stored result]"?

Thanks,

-GerryGerry

No, but if you have all the possible fields to be set on a single layout and their tab order is set consecutively, then you can run a loop like

Go to Layout [{layout with fields to be set}]

Commit Records/Requests [ ]

Loop

Go to Next Field

If [Get(ActiveFieldName) = selectedfield] {replace with your specific test}

Set Field [ ; dummyfieldvalue ]

Go to Layout [Original]

Exit Script

End If

End Loop

The trick is not to specify a target field under the Set Field step, so that it operates on the currently selected field.

  • Author

Hi,

Thanks for the prompt response... But don't think this is the best solution for me.

I don't want to depend on the tab-order because (like most projects) this is a work in progress. Eventually the tab-order will change according to other criteria. Plus, new fields will be added and others will be deleted in time... I don't want future developers to be mad at me because they changed a seemingly innocent tab-order and the solution broke. frown.gif

Thanks for the idea though (I will use it for other solutions for sure)

I guess I will keep my long "If/ElseIf" script for now...

-GerryGerry

The tab order is merely to ensure that all fields on the layout are tested. This should be a special layout containing only the fields to be tested/set and should neither be visible nor modifiable by a user, so the tab order should be irrelevant to them. It's also easy to add the text 'DO NOT MODIFY THIS LAYOUT OR ITS TAB ORDER - IT IS REQUIRED FOR <SUCH AND SUCH> SCRIPT' or something similar to the layout for future developers. A deleted field poses no problems either; it will simply be removed from the layout and not included in the test.

  • Author

Hi,

Now that you put it that way... Yeap, it will work!

I probably look like an idiot, hehehe... crazy.gif

Thank you very much I will modify my script right now...

-GerryGerry

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.