Jump to content
Sign in to follow this  
Woodeye

Export Field Contents - Variable

Recommended Posts

Woodeye    0

I have a button on a portal that calls a script "Show_Container": 

Line 1:   Set Variable [ $Param ; Value: Get ( ScriptParameter ) ]        (name of container field is passed thru script parameter)

Line 2:   Set Variable [ $Path ; Value: Get ( TemporaryPath ) & GetContainerAttribute ( $Param ; "Filename" ) ]

Line 3:   Export Field Contents [ Table::Field ; ""$Path"" ; Automatically open ]

 

Wanting to reuse this script in multiple places, I need to be able to replace the "Table::Field" in line three with a variable, but can't see how to accomplish this.

Any ideas?

Thanks,

John

 

 

Edited by Woodeye

Share this post


Link to post
Share on other sites
comment    1,382

Before looking for a solution to the problem as presented, I would ask why this problem exists in the first place. To me, it sounds like you have multiple fields where you should have multiple records in a related table.

Share this post


Link to post
Share on other sites
Woodeye    0

I could easily rewrite the script for each layout/table it would be used in (the script is only 3 lines). What I am trying to do is get better at writing reusable scripts. In this case, I don't see how I can do this.

 

Share this post


Link to post
Share on other sites
comment    1,382

You're not answering my question: the fact that you want this script to be reusable indicates a structural issue. It will be easier to solve the structural issue than to make this script reusable - not to mention that the structural issue will remain to cause you many other problems.

The target field of Export Field Contents[] cannot be parametrized. The only way to make this work the way you describe is to make sure that the required field is the currently active field - then use Export Field Contents[] without specifying the target field. You can make the required field active by looping among all fields in the layout's tab order until the active field's name is equal to the script parameter. Or give the field an object name and use Go to Object[] to make it active. Both are hacks designed to work around the real problem. And, IMHO, so is the solution linked to by @webko.

Share this post


Link to post
Share on other sites
webko    52

I'm not sure it has to be a structural issue - I can think of a number of scenarios where I have container fields in different tables that I would like to Export - having one script to perform that function, rather then one for each Container field seems logical to me...

Share this post


Link to post
Share on other sites
Woodeye    0

I am obviously not only a failure at FileMaker, as I should have thought of using a global field. I am now conflicted as to whether to sign up for training in FileMaker or have someone teach me to use a Google search properly. 

Thank you for the help.

Share this post


Link to post
Share on other sites
Lee Smith    147

Hi Woodeye, and welcome to the FMForums,

I posted a couple of links to training sites the other day here. 

 

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

Sign in to follow this  

  • Similar Content

    • By randyinla
      Hi, I have a field called 'mytournament1'.  I also have a field called 'mytournament1played'.  With a form, I create the variable $tournament to bring 'mytournament1' to my results page.
      $tournament = $_GET['tournament'];
      I'd like to force the results page to search for the field 'mytournament1played' for each record by using the variable $tournament and combining the word 'played' or the variable $played.  
      $played = 'played';
      $tournamentplayed = $tournament . $played;
      $tournamentplayed2 = $record->getField('$tournamentplayed');
      (I want it to deliver)      $record->getField('mytournament1played');

      I know the 1st '$record->getField' line is wrong.  Can I combine 2 variables that spell out a database field name (mytournament1played) that can be used to call up a field in a search?  i.e.
      if ($tournamentplayed2!='1') {

      thanks in advance for your help!
       
    • By Nathan Wilcox
      Hi All,
      I can never seem to get my head around file paths and even more so when we need to use variables. Can any of you help me with the following please?
      What I have is an inventory system that has been adapted from the starter solutions, I have created a new field called colour.
      I have a folder system set up with lots of different colour folders i.e. black, blue, yellow etc...
      I would like to add a button that performs a script that goes to the correct colour folder so that I can select the correct part. The folder path containing these colours would be "/Users/USERNAME/Documents/FOLDER/FOLDER/FOLDER/FOLDER/HERE ARE THE COLOUR FOLDERS" if that makes sense....
      I know this involves a variable using the colour field but cannot get my head around it.
      (I am aiming to then further this later on by being able to go straight to the part code within that folder without having to manually select one. I think I will be able to complete this once I have got used to doing the first part)
      Thank you to everyone who can help.
    • By Anthony
      I am using a custom function to format a number into currency format ( two decimals ). 
      RoundDecimals(11.0) = 11.00 The problems occurs when I use a variable:
      $amount = 11.0 RoundDecimals($amount) = 11.11 Similarly, I get the same error using a string:
      RoundDecimals("11.0") = 11.11  
      Is there any tricks to get around this issue ? 
      This is the custom function that I used (I replaced the comma for a dot and defaulted second parameter to 2):
      https://www.briandunning.com/cf/974
       
    • By Rook183
      I am sure this is one of those simple ones… that has me bamboozled for nearly 2 days now.
      I need to limit access of my users viewing only a limited set of "Company" records after they log in. The companies that they are allowed to see are listed in each respective user's profile.
      My opening script goes to the user's profile and creates a global variable for each company that they are allowed to view.
      When I go to the "Manage Security > Edit Privilege Sets > Records > Custom Privileges > Limited > Script", and use any of those variables (e.g. $$Company01"), the records table returns no records at all (i.e. as if there were no matches). When I test the script and use text for any one (or several) of those companies by name (e.g. "ACME PTY LTD"), the access rules work perfectly.
      To be clear: The global variables themselves are correct. I know this this because they work in other scripts absolutely perfectly, so the variables DO match the names in the field.
      The script looks like this:
      $$Company = Table Manufacturer or 
      $$Company01 = Table Manufacturer or
      $$Company02 = Table Manufacturer or 
      $$Company03 = Table Manufacturer or 
      $$Company04 = Table Manufacturer or 
      $$Company05 = Table Manufacturer
       
      In every respect, the variable matches the actual text, but I can only imaging that there is a problem with my syntax?
       
      Please advise.
       
      Many thanks
    • By Enigma20xx
      I'm trying to collect the correct answers from a test exam.
      For example, 35 questions, a, b or c as possible answers.
      I've made a script with a variable into a loop that collects the data such as: $Var [ question number & "space" & correct answer & "carriage return" & $Var ].
      With it I get something like this:
      1. a)
      2. c)
      3. a)
      4. c)
      5. a)
      6. a)
      ...
      Is there a way I could make this appear in columns?
      Like
      1. a)     4. c)   ...
      2. c)     5. a)
      3. a)     6. a)
      or
      1. a)     3. a)     5. a)     ...
      2. c)     4. c)     6. a)
      Thank you.
×

Important Information

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