Jump to content
docasar

Script on tab control to change field value

Recommended Posts

Hello,

I have a tab control panel with four tabs, and I would like to achieve that when I change tabs a script is triggered and would set the value of a global field called "zzz_g_collection_type" according to the tab name which is active.

I need this field to dynamically filter the products that are shown on 1_row portals that I have put into each tab panel space.

I have followed Elishree Dey tip on http://burnignorance.com/filemaker-pro-tips/trigger-a-script-when-user-changes-the-tabs-in-filemaker/ but I cant make it work, it only changes the value of "collection_type" field once and only to show that the first condition is not met.

I have attached the picture of my script.

My initial idea was to place on each tab space a picture-field of a product as a 1 row portal and then duplicate as much as products I have so when I click on the picture a script is triggered and the product is added to the invoice.

Morever, I have set an Object name to each tab Control so it would work, and also the desired value for zzz_g_collection_type comes from another related table with only one record that I use as preferences, this is on Preferences Table I have three fields called "Product_Type_Short_#" and those match on Elishree Day script tutorial.

Any ideas what I could be doing wrong?

Screen Shot 2016-10-07 at 22.19.34.png

Edited by docasar

Share this post


Link to post
Share on other sites

You have FileMaker Advanced. Have you tried stepping through it with the script debugger?

You could probably do this more simply:

If [ Get ( TriggerTargetPanel ) = "Bottles"]
	etc.

 

Share this post


Link to post
Share on other sites

What would work:

If [ getValue( Get( TriggerTargetPanel ); 2 ) = "Bottles" ]

Share this post


Link to post
Share on other sites

Hi BruceR,

Many thanks for your tip. I am still quite new to filemaker scripting, and dont understand very well your suggestion. Could you please guide me a little be more about where to put the function within my script? I put it instead of  If ( $isBottlesInFronTab = 1 ) but it is not working... any further ideas?

Thanks a lot in advance for your help

Share this post


Link to post
Share on other sites

Sorry, no. Why not use what has already been given to you quite clearly by Tom and myself?

Share this post


Link to post
Share on other sites

When asking for help it is very important to give enough information to make the helper's job easier. Saying "I tried something and it didn't work"; well; doesn't work. Better to post a complete copy of your script; or your file; or a simplified version of your file which you have gone to the effort to construct in order to demonstrate the problem.

Share this post


Link to post
Share on other sites
On 10/7/2016 at 7:57 PM, BruceR said:

What would work:

If [ getValue( Get( TriggerTargetPanel ); 2 ) = "Bottles" ]

Yes, sorry about that. Thanks for catching that, Bruce!

On 10/7/2016 at 1:23 PM, docasar said:

I have a tab control panel with four tabs, and I would like to achieve that when I change tabs a script is triggered and would set the value of a global field called "zzz_g_collection_type" according to the tab name which is active.

My initial idea was to place on each tab space a picture-field of a product as a 1 row portal and then duplicate as much as products I have so when I click on the picture a script is triggered and the product is added to the invoice.

Reading over your initial post, I may have misinterpreted what you're asking. First you say you want to set a field when you change tabs. That's where TriggerTargetPanel would make sense. 

Then you say you want to click on a field and trigger a script At that point you're already on the tab panel, so TriggerTargetPanel wouldn't apply.

So... what do you see when you step through with the debugger? Do the variables get set as expected? Do the tab names match your script?

Share this post


Link to post
Share on other sites
15 hours ago, Fitch said:

Yes, sorry about that. Thanks for catching that, Bruce!

Reading over your initial post, I may have misinterpreted what you're asking. First you say you want to set a field when you change tabs. That's where TriggerTargetPanel would make sense. 

Then you say you want to click on a field and trigger a script At that point you're already on the tab panel, so TriggerTargetPanel wouldn't apply.

So... what do you see when you step through with the debugger? Do the variables get set as expected? Do the tab names match your script?

Hi Fitch,

Many many thanks for going back to my initial post. I am sorry for the confusion regarding my goal. I will try to reexplain :)

The whole purpose of this is to build a POS. Graphically it would look like a 5x5 grid that will display all our products, and when you click on the product (represented by a picture of the product itself thanks to a 1row portal for each product ) it will add that product to an invoice as a line_item. Since we have four categories of products the idea would be that I would place the 5x5 grid on each tabpanel and the products shown by the 1row portals would be related to the category that match the tab name. In order to make this work, my initial approach was to filter the portals according to the value of one field (zzz_g_collection_type) that would dynamically change when the user click on each tab.

So what I need to achieve is that the value of the field "zzz_g_collection_type" changes accordingly to the active tab.

Reading through Elishree Dey tip I tried again and "magically" now the script is working. I am attaching a sample file with the script in case this might help anybody else in the future.

I cant stress enough how grateful I am for you guys putting your effort and time to help us newbies when we struggle so much...

Thanks a lot again.

Luis

TabPanelControl.fmp12

Share this post


Link to post
Share on other sites

Here's a data-driven extension of the technique.

Uses the originally discussed on OnPanelSwitch technique, not on object modify.

TabPanelControlMOD.fmp12

Edited by BruceR

Share this post


Link to post
Share on other sites

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

  • Similar Content

    • By john renfrew
      This has long been an issue, I have no idea why it happens and it is making life quite difficult
      Win Server 2012 FMS 16 (current but this happens on other configurations)
      With ScriptMaster installed 
      run a script which resets the server ( SMReset) and then loads jars and functions return to you the result of SMGetRegisteredModules and show it in a dialog box
      run another script on the server which just returns to you the result of SMGetRegisteredModules and show it in a dialog box
       
      dialog 1 SHOWS the modules you installed
      dialog 2 is EMPTY
      fmsadmin restart fmse
      do the above again, same result
       
      this means you can not do a test on the server to see if a particular function is loaded before you want to use it.... in fact there is no test you can do to see if the ScriptMaster has fallen over as far as I can tell.
       
      Any solutions???
    • By JMart
      Hi gurus,
      I am sure I’m missing something simple, but for the life of me I can’t figure this out. I have a database with tickets. What I want is when a new ticket is created I want to see a popover (see attached) then I want the user to type in the top box and as they type I want to filter the list below (a portal) and once they client is shown they would select it and a ticker is created for the client. I sound a script and modified to fit my needs but can’t get it to work. Can someone stretch a helping hand?
      BTW the filtering is working but its not reflecting in the popover its reflecting on the layout.


    • By Hoytopher
      Hi all,
      I'm an FM novice who has a functioning database, and I'm trying to add layers of functionality to it. One feature I'm trying to design is a script to search through a Gmail outbox with certain keywords.
      In URLs, "%" translates to "%25". Filemaker appears to do this automatically - In Gmail syntax, you need to write "in%3Asent" to have the Gmail search bar contain "in:sent" which searches my outbox. Here's my current code for Go to URL:
      This "%" bit translates to "%25". I've tried "\%", I've tried creating a string, x, then having it open x, but no matter what I cannot get "%" to show up as-is, it always translates to "%25". Is there any way around this? I've tried subtracting text, but I just can't seem to get it to work. Any bright ideas? I can't find an answer to this specific question of disabling URL string substitution.
    • By Agentshevy
      Hello everyone..
      Guess I have been away for a while. Not fully back though because I am not really engaged with computer tech stuff at the moment. However, I really stumbled across a problem earlier today while going through my email logs. I observed that a server script I had set up has not been attaching the Pdf file report as supposed to. It only delivers the message while leaving out the file attachment. I did test the script when I added it but what I did not test was the result when run by the server.
       
      Allow user Abort [Off]
      Commit Records/Requests [No dialog]
      Set Variable [$FileName;Value:"Summary"&".pdf"]
      Set Variable [$PDFPath;Value:Get(TemporaryPath) &".pdf"]
      Go to Layout ["Summary_Layout]
      Perform Script ["Print_Page_Setup"]
      Save Records as PDF [Restore;No dialog;"$PDFPath";Current record]
      Send Mail [Send via SMTP Server;No dialog]
       
      As at the time of my writing the script, I was not observant about server-side scripts. I did go back just recently to observe that the "Save Records as PDF" script step is not server compatible.
      Please, is there any work around on this? Much help is appreciated.
    • By michael3785
      I have avery big solution that was built in FM7 originally and it needs a UI overhaul. So, no themes are as good as they are I am rolling up my sleeves and putting together a reference design. have been looking around at design templates to lift (speaking frankly) and I like the FM Starting Point design. However there are a few things I need to tweak that I can't readily see how to do it in Inspector. The main one is the height of the tabs in the tab controls. They are too high for my layouts. As far I can see I either have to hack the CSS somehow or I have to use a conditional fomatting workaround, set the text size really small to reduce the height of the tab, then conditional format the text back up to the correct size, which is a bit yuck, seeing as I have lots of tabs.
      Any advice much appreciated. Many thanks.
×

Important Information

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