Jump 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.

Pick up value from one script and give to another

Featured Replies

One would think this is easy but I have not found answers.

 

I have a script which does some work and then when done, I want it to pass a value from 'Status' to a sub script which wants it for its script parameter. I know at least I think it would be Exit Script but if I exit script then how can I run the sub script after it?  And if I put it before then it does not run the sub script.

 

Please where does this go and how?  This sub script sometimes gets its script parameter from button presses but sometimes it can get it from scripts like this one.  Thank you.

There are different es yes to do this. I use the sixfriedrice method most of the time. You can find it on their website. Sometimes I use global variables that I kill either with a script or at the end of the last script.

  • Author

Hi Agnes, Thank you for quick reply and ideas.

Can you tell me the name of the method you are referencing?  I do not know what I am looking for and there seems to be many things there.  Is it using LayoutAttribute?  I would rather not set global variable if I can pass it instead and I have many triggers which use this sub script exactly as it is so I hate to duplicate it if it can cross purpose.

 

Thank you again for link!

I have a script which does some work and then when done, I want it to pass a value from 'Status' to a sub script which wants it for its script parameter.

 

Not sure what exactly your question is. If the first script calls the second script by using the Perform Script[] step, then you can pass a value to the called script right there by adding a script parameter to the call - all within the same step.

  • Author

Oh wow. I was looking only in the main script for ways to add a script line to do it.  it was right in front of me.  Thanks for your help.  I appreciate it. It perplexed me for two days.

Oh, wrongfully assumed you knew that.

Parameter passing is what you're looking for on sixfriedrice. I use their method for passing multiple parameters, because FileMaker natively can only pass one to the perform scrip script step.

  • 2 weeks later...
  • Author

Thank you Agnes and Comment.  Even reading up it seems so abstract.  I believe I got confused when I read people pass data with Exit Script.  So would this be how the subscript or secondary script would pass something back in very basic example?  Then how would the parent script then read what comes back?

 

Parent script named: find status selected

 

I want to send a Status and have reported back the ids which match so

Perform Script [ Server Search and use script parameter of Status field

 

Subscript named: Server find

Enter Find

Go to Customers layout

Perform Find [Get (ScriptParameter)  

Exit Script[summary ListOf ids]

 

back at parent the script continues

Set Variable [ $$ids ; Get(scriptParameter)  and do whatever I want with them

 

I think it is close but so far I cannot make it work.  Is it safe to say that the way always into a script is with script parameter and the way out is exit script's parameter?  If I can pin this down then my problems are elsewhere.

 

Is it safe to say that the way always into a script is with script parameter and the way out is exit script's parameter?

 

The "exit script's parameter" is the script result.  The way to get it is through the Get(ScriptResult) function.

 

Note: there is only one script result at any time; it holds the result of the last script that exited with a non-empty an explicitly specified result (even an empty one).

I did some testing and it looks like there is a bit more to this.

 

Perform Script [ Script 1 ]

Perform Script [ Script 2 ]

Set Variable [ $sr; get( scriptResult]

 

Let's say script 1 ALWAYS returns "whatever"

If Script 2 has no exit script statement; then $sr is "whatever"

If Script 2 has exit script statement Exit[] ; then $sr is "whatever"

 

If Script 2 has exit script statement Exit[""] ; then $sr is empty

If Script 2 has exit script statement Exit[ $$null ] and $$null is an undeclared variable ; then $sr is empty

And of course if Script 2 has exit script statement Exit["something"] ; then $sr is "something"

You are right, I need to correct my formulation.

  • Author

So everything in my sample script is right except how I get the returned results from the sub script.  And this

 

back at parent the script continues

Set Variable [ $$ids ; Get(scriptParameter)  and do whatever I want with them

 

would be changed to this?

 

Set Variable [ $$ids ; Get ( ScriptResult )

 

If so then I have other issues because it didn't work and I know it is my lack of understanding.  So is it correct to say that any time I want the results of a script, said results must be placed in the Exit Script step's parameter for that script, can be retrieved even if a few scripts have ran after it as long as those scripts did not put something in their Exit Script or otherwise specifically set it to "".

 

Is this right?  I am sorry I am so obtuse on some things.  

So is it correct to say that any time I want the results of a script, said results must be placed in the Exit Script step's parameter for that script, can be retrieved even if a few scripts have ran after it as long as those scripts did not put something in their Exit Script or otherwise specifically set it to "".

 

That is essentially correct (minus a few quibbles about semantics), except one thing: the script result expires when the last script exits. IOW, there is no script result when no script is running.

 

 

back at parent the script continues

Set Variable [ $$ids ; Get(scriptParameter)  and do whatever I want with them

 

would be changed to this?

 

Set Variable [ $$ids ; Get ( ScriptResult )

 

That's kind of counter-productive, because the idea with both script parameter and script result is to avoid using global $$variables. Global $$variables are global (i.e. not specific to the script that created them). They persist even after all scripts have run out - until you either erase them or log out/close the file.  So instead of setting a $$variable to Get ( ScriptResult ) and "do whatever I want with them", just do whatever you want with Get ( ScriptResult ) directly. There's no need to "save" it to another variable, as long as you are not running another script with a result before you are done with it.

Rob, this would all be a lot easier if you would supply an example file.

Also, you mention the summary field option "List Of" but that is a FileMaker 13 function and your profile indicates you're on FileMaker 12.

 

But here's a simple example.

ScriptParams.fmp12.zip

  • Author

This is extremely helpful Bruce, thank you so much for it.  I now see how it all works together. I will change my profile now.  I can get rid of several global variables and fields this way.

 

 So instead of setting a $$variable to Get ( ScriptResult ) and "do whatever I want with them", just do whatever you want with Get ( ScriptResult ) directly. There's no need to "save" it to another variable, as long as you are not running another script with a result before you are done with it.

 

Your explanation is perfect and stops a bad habit I was developing of always setting a global variable with the value so I have it corralled and it would not get away from me.  I just need to get better at knowing when to corral and when not.  I could not imagine how I could ever do this on my own.

 

Thanks guys.   And we will move to 13 but I need to move carefully.  We just put out money for 12 and they are not too keen on me at the moment wanting even more bucks.  Ha.  Little do they know.  I have already included popovers so it is a done deal.

If you really just put out money for 12 then the upgrade may be free.

You got a volume license?

  • Author

It was four months ago.  Do you think?  We shall check.   Thank you. 

You have 90 days for the free upgrade if I remember correctly. In any event I would call FileMaker customer service and verify.

Create an account or sign in to comment

Important Information

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

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.