Jump to content
Salesforce and other SMB Solutions are coming soon. ×

help with set fields


smithz
 Share

Recommended Posts

good day all.... its been 4 days and i still cannot seem to get it.... smiley-cry

 

this is basically what i want to do.

 

i have two files file 1 and file 2

 

i want to transfer a field from file 1 to a field in file 2.

 

basically the script step is copy the field from file 1

 

then make a new record (view as list mode) on file 2

 

then post the data to a field in file 2

 

so basically the script should be in file 1 not on file 2

 

someone told me to use set fields with globals but can't seem to make the field in file 2 catch the data from file 1 or make a new record on file 2 from a script in file 1.

 

i'm trying to rebuild a fm5 database someone made before from scratch to fm7 because if i autoupgrade it lots of errors seem to occur and my database crashes often.

 

can someone please show me a script step on how to do it? any help would be appreciated. thanks in advance.

Link to comment
Share on other sites

a) If you're rebuilding a FileMaker 5 solution in FileMaker 7, don't make separate files. (OK, opinions on this differ, but that's my recommendation). Put all your tables in one file.

 

b) Either your two tables are related by the field value you're moving from one table to the other, or they are not. If they are related, you have the option of creating the record in the second table in a different way. You set up the relationship so that Second Table allows for the creation of new records via the relationship, then in your script you set some OTHER field's value via the relationship, like so:

 

{Where the field you are wanting to have show up in Second Table is "Patient Social Security Number" and you are on a layout that is native to a table named "Patients", and you've made a text field "RecordCreator" in Second Table}:

 

Set Field [second Table::RecordCreator, Get(PrivilegeSetName)]

 

If Second Table is related to Patients via Patients Social Security Number, that's going to generate a related record where none existed before, with the same Patients Social Security Number as the local record in Patients that you are on at the time.

 

 

c) If the two tables are not related, or you do not want to allow the creation of related records via the relationship, or you always want to make a new related record in Second Table even if there's already one with that value, you are still best off not using "Copy" and "Paste". Using "Copy" and "Paste" to move data around is something we had to do in FileMaker 2, but there are better ways that don't ruin your end user's system clipboard every time they run a script, and which don't require you to actually be on a layout that actually has the field on it to be copied from and pasted into:

 

{assuming you're on a layout for which Patients is the native table, and another layout, "Second Table Layout", has "Second Table" as its native table}:

 

Set Variable [$SSNum, Patients::Patients Social Security Number]

Go to Layout [second Table Layout]

New Record/Request

Set Field [second Table::Patients Social Security Number, $SSNum]

 

See how that leaves the clipboard intact? So if the end user had copied the patients' email address and wanted to paste it into a Second Table record which didn't necessarily exist yet, this script wouldn't wipe out the end user's email address from the operating system clipboard and replace it with the social security number. They could paste into a field when they got there and it would work as they would expect it to.

 

Note that the above method (using the Set Variable, New Record, Set Field sequence) will keep making new records in Second Table. If you only wanted it to generate a new record with that value if there wasn't one already, you'd test for it first and branch your script accordingly, like this:

 

If [Count(Second Table::Patients Social Security Number)>0]

..Go To Related Record [second Table, via Layout "Second Table"]

Else

..Set Variable [$SSNum, Patients::Patients Social Security Number]

..Go to Layout [second Table]

..Set Field [second Table::Patients Social Security Number, $SSNum]

End If

Link to comment
Share on other sites

Variables are not available in version 7. You can however, use a Script Parameter in a script from file 1 to run a script in file 2 that uses Get(ScriptParameter).

Link to comment
Share on other sites

 Share



×
×
  • Create New...

Important Information

Terms of Use