Jump to content

How to set fields in subscript to variables defined in ,win script

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

Recommended Posts

Hi all,


I need scripting assistance;


I have a script that searches on a layout for records on current date and creates invoice records on the found set in a different layout. I would like like after creation of each invoice record, i define variables and open another file where there is another script that creates a new record in that file and sets the fields to the variables defined in the first file.


is at all possible to reference variables in a subscript that are defined in the main script?


NB:Main Script and Sub script both belong to different database files.



This the contents of the main script......

#Script used to create Invoices that need to be paid daily.
Set Error Capture [ On ]
Go to Layout [ “Tour_List” (Tour_Storage) ] #Current Invoices found...
Enter Find Mode [ ]
Set Field [ Tour_Details_TimetableVehicle::lxd_Invoice_Date_Start; Get(CurrentDate) ] Perform Find [ ]
Constrain Found Set [ Specified Find Requests: Omit Records; Criteria: Tour_Details_Reservati::Cancelled_chk: “Yes” ]
[ Restore ]
Constrain Found Set [ Specified Find Requests: Find Records; Criteria: Tour_Details_TimetableVehicle::Vehicle: “*” ]
[ Restore ]
If [ Get ( FoundCount ) > 0 ]
Go to Record/Request/Page
[ First ]
#... loop array used to create Found Tour invoices begins ... Loop
#... Tour details set as variables ...
Set Variable [ $Tour; Value:Tour_Storage::lxt_Tour_Storage_Number ]
Set Variable [ $Start; Value:Tour_Details_TimetableVehicle::lxd_Invoice_Date_Start ] Set Variable [ $End; Value:Tour_Details_TimetableVehicle::lxd_Invoice_Date_End ] Set Variable [ $VHC; Value:Tour_Details_TimetableVehicle::Vehicle ]
#... Invoice Layout entered and new record created ...
Go to Layout [ “Invoice_Transport_New_TC” (Invoice_Transport) ]
New Record/Request
#... Tour details set to appropriate deatils ...
Set Field [ Invoice_Transport::Date_Tour_begin; $Start ]
Set Field [ Invoice_Transport::Date_Tour_end; $End ]
Set Field [ Invoice_Transport::Tour_Number; $Tour ]
Set Field [ Remittance_Tour_Storage::lxt_Tour_Number; $Tour ]
Set Field [ Invoice_Transport::Vehicle; $VHC ]
#... If to set correct Ledger Account is executed ...
If [ Middle ( $Tour ; 3 ; 3 ) = "PRT" ]
Set Field [ Invoice_Transport::Ledger_Accounts; "2011 Income Other Operator" ]
Set Field [ Invoice_Transport::Ledger_Accounts; "2010 Income" ]
End If
Set Variable [ $$Inv_Num; Value:Invoice_Transport::__ID_INVOICE_PT_NUMBER ] Set Variable [ $$Date_Inv; Value:Invoice_Transport::Date_Invoice_PT ]
Set Variable [ $$TourNum; Value:Invoice_Transport::Tour_Number ]
Set Variable [ $$DateTravel; Value:Invoice_Transport::lcd_TG_Start_TC ]
Set Variable [ $$VAT; Value:Invoice_Transport:: lcn_Amo_Debit_VAT_Output_Sum_TC ]
Set Variable [ $$Reference; Value:Console::Vehicle ]
TransportRemittance.fmp12 - Server Side - Daily Invoice Creation -1-
PS Transport Invoice: Server Side - Daily Invoice Creation
Set Variable [ $$GTotal; Value:Invoice_Transport::lcn_Amo_Debit_Unit_Grand_TC ]
Open File [ “Remittance 2” ]
Perform Script [ “Safari Remittance - New Record - Transport Invoice” from file: “Remittance 2” ]
Close File [ “Remittance 2” ]
Go to Layout [ “Tour_List” (Tour_Storage) ] Go to Record/Request/Page
[ Next; Exit after last ] End Loop
#... Mail with payable Tours sent to Transport ...
Perform Script [ “Transport Invoice - Mail Current” ] Else
Exit Script [ ] End If
#Script written b

Here is the contents of "Safari remittance - New record - Transport Invoice" subscript

Set Field [ Pack Safari Remittance::gt_Trigger_ Suppress; 1 ]
Go to Layout [ “Pack Safari Remittance New” (Pack Safari Remittance) ]
New Record/Request
// Paste [ Pack Safari Remittance::Invoice_Number ] [ Select ]
Set Field [ Pack Safari Remittance::Kürzel; "Pack Transport" ]
Set Field [ Pack Safari Remittance::Ledger_Accounts; "1022 Pack Transport" ]
Set Field [ Pack Safari Remittance::Invoice_Number; $$Inv_Num ]
Set Field [ Pack Safari Remittance::Date_Invoice; $$Date_Inv ]
Set Field [ Pack Safari Remittance::Tournumber; $$TourNum ]
Set Field [ Pack Safari Remittance::Date_Travel; $$DateTravel ]
Set Field [ Pack Safari Remittance::Input_VAT; $$VAT ]
Set Field [ Pack Safari Remittance::Reference:; $$Reference ]
Set Field [ Pack Safari Remittance::Amount_including_VAT; $$GTotal ]
Commit Records/Requests
[ Skip data entry validation; No dialog ]
Set Field [ Pack Safari Remittance::gt_Trigger_ Suppress; 0 ] Exit Script [ ]

Thank you for all kinds of suggestion,


Link to comment
Share on other sites

I'm assuming your script doesn't work and therefore the global variables defined in file A don't make it across to file B, hence you asking the question. I haven't tested it myself. One way to overcome this would be to pass variables in the perform script step. Multiple variables can be passed as a list.


Another way would be to use an intermediate table in file B. You'd have to link that table in file A in the relationship diagram, and can then add a record to the table, populate the fields, invoke a perform script command passing the record ID in the temp table, and handle the data in your subscript.


Another way would be to import data into file B from file A. Thhis might help too http://help.filemaker.com/app/answers/detail/a_id/12068/~/how-to-move-data-from-one-database-to-another

Link to comment
Share on other sites

Thank you very much and your first suggestion was the attempt i was on with the script i provided. i am not sure i can manage the second suggestion but let me do the readings for the links you have provided.


Thanx heaps!!!

Link to comment
Share on other sites

is at all possible to reference variables in a subscript that are defined in the main script?


No. But you can pass a value to the subscript as a script parameter in the Perform Script[] step. Passing multiple values as a single parameter is a little more complicated, but perfectly doable.


However, in your described case, I would say importing the records would seem like a better idea. That is assuming you really need to duplicate your data to another file (or to anywhere, for that matter).

Link to comment
Share on other sites

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