First, Get rid of the Copy and paste steps. Use Set Field instead.
Now modify your script as:
Set Variable [$CompID ; Firm Data::CompanyID]
Set Variable [$2ndField ; Firm Data::2ndField]
New Window ["Add New Meeting"]
Go to Layout ['Add Meeting" (Meeting History)]
Set Field [Meeting History::CompanyID; $CompID]
Set Field [Firm Data::2ndField; $2ndField]
Go to Field [Meeting History::Name]
Edit Note: Script corrected to fix error mentioned in following post.
Works like a charm. I had to tweak the bottom of the formula such that Set Field [Meeting History::CompanyID ; $CompID] but this is terrific. Now that I understand how Set Variable works, I'm going to use this in a lot more scripts.
This forum never disappoints.
I feel like I'm doing the exact thing as stated in this thread, but my field is not being populated with my global variable as expected. I have a presentation table with a unique ID field (PresentID) that links to a grant table which includes PresentID and GrantID...one presentation can be associated with multiple grants. I pass the variable PresentID into my PresentationGrants table layout using the following script...(triggered by clicking on a button)
Set Variable [$PresentID; Value:Presentations::PresentID]
Go to Layout ["PresentationGrants" (PresentationGrants)]
New Record / Request
Set Field [PresentationGrants::PresentID[$PresentID]]
I know my variable is capturing PresentID OK because I added a Show Custom Dialog script which showed the proper PresentID. The only difference I can see between what I'm doing and the example in this post is a slightly different syntax with Set Field...my variable is in brackets whereas the example below uses ; which may be a difference in FileMaker versions...I'm using version 10.
In any event, the new record command is successful but my PresentID field remains blank. I've tried Replace Field Contents, but that updates the field in every record, not just the new record. I've also tried Go to Field thinking it needed to set focus to the field to set the field value...no luck. Any clue what I'm doing wrong...this is driving me nuts!!
Ok, so the smiley faces are really : next to the letter P
To get rid of the emoticons, put a space after the colon. You can edit a post after the fact by selecting "Edit" from the options menu just above the Kudo control on the right.
Your last script step should look like this:
Set Field [PresentationGrants:: PresentID; $PresentID]
[$PresentID]] shows you've put this variable in the repeitition box when specifying the target field, PresentationGrants:: PresentID.
Set this back to 1 and click the lower specify... (calculated result) button and enter your variable's name there