Jump to content

Help with Script Triggers on Pop-up Menu


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

Recommended Posts

Hi

So I'm just trying to understand why my logic isn't working as expected. I have a pop-up menu within a portal that resides on one of six tabs of a multi-tab control.

The options for the pop-up menu are 'Complete' or 'Pending'. The business logic is that if the field is Complete, it cannot be set back to Pending. So my logic was to write two small scripts; one to store the value of the field, and another to tell the user they are unable to revert it and to reset it back to it's original value.

 

so the first script (called StoreCurrentStatus) is simply:

Set Variable [$$CurrentStatus; Value:Client_ACTIVITY:_Status]

The second one (called ResetStatusChange) is as follows:

If[Client_ACTIVITY:_Status ≠ $$CurrentStatus]
  Show Custom Dialog["App Name"; "You cannot revert a status of 'Complete' back to 'Pending'"]
  Set Field[Client_ACTIVITY:_Status; $$CurrentStatus]
End If

I then set the script triggers on the field Client_ACTIVITY::D_Status to:

post-109525-0-36161800-1422620520_thumb.

 

To test this works, I added a line to StoreCurrentStatus to show the value that's being stored:

Show Custom Dialog["App Name"; "Current Status = " & $$CurrentStatus]

What I am seeing is that the trigger isn't firing when I enter the field, but as soon as I modify the selected item, it pops up the message to show the status it was changed to, not the one that I started with. Is there something I'm missing, or a better way to manage this? And could i get away with a local variable here instead of a global one?

 

Many thanks

 

Martin

Link to comment
Share on other sites

Pop-ups don't behave like you expect them to.  They change the value *then* enter the field

 

One way to solve this is to lock down that field and give the user a "progress status" button that runs a script to set the status to the next one. This way they can never use an older status

Link to comment
Share on other sites

Thanks.

As a relative newbie (who is trying to maintain a FM app written by a third party), not quite sure I understand your suggestion. For some background, the default value for this field is Pending, and can only be changed to Complete once. If there is a need to revert it, admin users can delete the record and allow the user to re-enter a new one. In other languages, I'd simply disable the control once it was set to Complete but this isn't possible (as far as I am aware) in FM.

Thanks again

Martin

Link to comment
Share on other sites

If you want to capture the field content of a popup-formatted field before you enter it, pass the field as a script parameter to the triggered script.

 

Besides that, I'd follow Wim's advice in this scenario.

Link to comment
Share on other sites

In other languages, I'd simply disable the control once it was set to Complete but this isn't possible (as far as I am aware) in FM.

 

There are workarounds to programmatically control field access; besides using a script trigger (which is awkward with a popup), you can use Conditional Hide:

 

Put two copies of the field (object) onto the layout: one formatted as a popup, the other one as an edit box and set to disallow field entry.

 

Use a hide calculation for the popup as 

Self = "Complete"

and one for the edit box as

Self ≠ "Complete"
Link to comment
Share on other sites

 

There are workarounds to programmatically control field access; besides using a script trigger (which is awkward with a popup), you can use Conditional Hide:

 

Put two copies of the field (object) onto the layout: one formatted as a popup, the other one as an edit box and set to disallow field entry.

 

Use a hide calculation for the popup as 

Self = "Complete"

and one for the edit box as

Self ≠ "Complete"

OK, so I wasn't aware you could use Self in this context...very useful! But for some reason, even after double-checking (and triple-checking) my logic, they both hide when set to Complete. I have removed all script triggers from the events, and am simply relying on the logic above.

So to check, they both point to the same data field, ie Client_ACTIVITY::D_Status and they are both the same size/position, the new one is a simple Edit box but with the options in 'Field entry' unticked...

Original field:

post-109525-0-02697700-1422626066_thumb.

New field:

post-109525-0-90661300-1422626055_thumb.

Any ideas what I've done wrong?

Thanks in advance

Martin

Don't worry, have just spotted it! Am using the Status from another layout!!  :blush2:  :laugh:

Link to comment
Share on other sites

Hi

Following on from this thread, I have made the changes to the test version of the application by adding a duplicate edit-box control and tested that it works when running locally in FileMaker. Users are now testing but are now unable to select an option from the pop-up menu (which they could previously). All I ended up doing was setting a conditional hide to the input alongside the status so it was hidden when status was set to Pending, and then after adding the edit-box, hide either the pop-up or edit-box based on the content of the field being "Complete"

I'm viewing this in Chrome.

post-109525-0-76323100-1422631259_thumb.

As you can see, the settings for the pop-up are correct in that it allows users to enter the field.

Anyone have any ideas why the pop-up menu has stopped working in Chrome?

Thanks

Martin

Link to comment
Share on other sites

This topic is 3345 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.