Filemaker vs Standalone Script

Any other Filemaker developer & Applescripter experienced a script that runs fine as a standalone file, but doesn’t when embedded within a Filemaker script? The script is fairly simple:


tell application "Adobe InDesign CS4"
	set theItems to selection of document 1
	
	if theItems is {} then
		display dialog "Please select some items to pull." buttons "OK" default button 1
		return 0
	end if
	
	tell application "FileMaker Pro Advanced"
		create new record
		go to last record
	end tell
	
	repeat with oneItem in theItems
		
		set contentType to (content type) of oneItem as string
		
		if contentType is "graphic type" then
			set allGraphics to all graphics of oneItem
			
			if allGraphics is not {} then
				set filePath to file path of item link of item 1 of all graphics of oneItem
				
				tell application "Finder"
					if filePath contains ":" then
						set AppleScript's text item delimiters to ":"
						set fileName to text item -1 of filePath as string
						set AppleScript's text item delimiters to ""
					else if filePath contains "/" then
						set AppleScript's text item delimiters to "/"
						set fileName to text item -1 of filePath as string
						set AppleScript's text item delimiters to ""
					end if
				end tell
				
				if fileName contains "." then set fileName to characters 1 thru ((offset of "." in fileName) - 1) of fileName as string
				
				tell application "FileMaker Pro Advanced"
					set cell "Image Path" of current record to filePath
					set cell "Image Number" of current record to fileName
				end tell
				
			end if
			
		end if
		
		if contentType is "text type" then
			set theText to text of oneItem as string
			
			if theText contains "Coupon valid thru" then --COUPON EXPIRATION DATE
				set theDate to ""
				repeat with p from 1 to count of paragraphs of theText
					if paragraph p of theText contains "Coupon valid thru" then
						set thePara to paragraph p of theText
						set theDate to characters ((offset of "Coupon valid thru" in thePara) + 18) thru -1 of thePara as string
						if theDate contains "." then set theDate to characters 1 thru ((offset of "." in theDate) - 1) of theDate as string
					end if
				end repeat
				
				if theDate is not "" then
					tell application "FileMaker Pro Advanced" to set cell "Expires On" of current record to theDate
				end if
				
			else if the (count of text paths of oneItem) is greater than 0 then --Limit on a path
				
				set theText to the text 1 of text path 1 of item 1 of oneItem as string
				
				tell application "FileMaker Pro Advanced" to set cell "Limit" of current record to theText
				
			else if theText contains "Limit" then --Limit as straight text
				
				tell application "FileMaker Pro Advanced" to set cell "Limit" of current record to theText
				
			else if (count of paragraphs of theText) = 1 then --PRICE
				if (count of character of theText) = 4 then
					set theText to characters 1 thru 2 of theText & "." & characters 3 thru 4 of theText as string
				else if (count of character of theText) = 3 and theText does not contain "¢" then
					set theText to character 1 of theText & "." & characters 2 thru 3 of theText as string
				end if
				
				tell application "FileMaker Pro Advanced" to set cell "Price" of current record to theText
				
			else --DESCRIPTION
				set newText to ""
				repeat with c from 1 to count of characters of theText
					if (ASCII number (character c of theText)) = 10 then
						set newText to newText & " "
					else if (ASCII number (character c of theText)) = 13 then
						set newText to newText & " "
					else
						set newText to newText & character c of theText
					end if
				end repeat
				tell application "FileMaker Pro Advanced" to set cell "Purchase Description" of current record to newText
			end if
		end if
		
	end repeat
	
	set selection of document 1 to {}
	
	tell application "FileMaker Pro Advanced"
		do script "Check Product Description"
	end tell
	
end tell

Well, I figured it out. I needed to add an “activate” right after the tell application commands(both for Indesign & Filemaker). Now it works embedded in a filemaker script.