Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

This topic is 7285 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

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

Posted

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.

Posted

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

Posted

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.

Posted

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

This topic is 7285 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

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