2011-04-23 26 views
0

是否有任何方式(或有任何工具)批量更改表發生的來源從本地文件到外部源文件?FileMaker:對錶發生源的批量更改

情況:我管理一個託管數據庫,其中有數百個表發生15個左右的表。我的一些用戶通過較慢的互聯網連接訪問數據庫。儘管許多表需要針對整個工作組進行更新,但其他表和UI信息中的一些數據大多是靜態的。

我想獲取數據庫的副本,將必須從本地文件源共享的表的表發生次數更改爲現有服務器的外部源。我可以手動完成此操作,但它需要數千次點擊,並且容易出現錯誤。如果我可以自動化這個過程,情況會更好。 (要指定銷售表的所有發生情況從本地文件移動到外部源。)

我意識到,如果沒有更好的方法來做到這一點,我可能會對AppleScript的用戶界面腳本做些什麼。

回答

2

到目前爲止沒有答案,所以我昨天寫了這個。它很骯髒,囉嗦,並沒有發現錯誤,但它會完成這項工作,並且是爲了未來而建立的。

--to prepare to run this script, you should already have the External Data Source set up 
--you should also open the Manage > Database menu and select the "Relationships" tab 

--set newDataSource to the name of the new external data source 
set newDataSource to "" 

--obtain tableOccurrences from TableNames (Get (FileName)) in the Data Viewer and copy the list into the tableOccurrences variable below 
--note that tableOccurrences will be a return-separated list which is quite long when set 
set tableOccurrences to "" 

--a list of which tables should be moved from the local file to the hosted file. Note that these should be proper table names not table occurrences 
set tablesToReplace to {"table1", "table2", ..., "tableN"} 

tell application "FileMaker Pro Advanced" 
    activate 
end tell 

set AppleScript's text item delimiters to {return} 
set j to the number of text items of tableOccurrences 

repeat until j < 1 
    tell application "System Events" 
     tell application Process "FileMaker Pro Advanced" 
      keystroke text item j of tableOccurrences 
      keystroke "o" using command down 
      delay 1 

      set i to 1 
      repeat until ((i > (count of rows of table 1 of scroll area 1 of window 1)) or selected of row i of table 1 of scroll area 1 of window 1) 
       set i to i + 1 
      end repeat 

      if (i <= (count of rows of table 1 of scroll area 1 of window 1) and name of static text of row i of table 1 of scroll area 1 of window 1 is in tablestoReplace) then 
       set currentMasterTable to name of static text of row i of table 1 of scroll area 1 of window 1 
       set currentOccurrenceName to value of text field 1 of window 1 
       click pop up button 1 of window 1 
       tell menu 1 of pop up button 1 of window 1 
        click menu item newDataSource 
       end tell 

       set k to 1 
       set tableSelected to false 
       repeat until tableSelected or k > (count of rows of table 1 of scroll area 1 of window 1) 
        if name of static text of row k of table 1 of scroll area 1 of window 1 = currentMasterTable then 
         select row k of table 1 of scroll area 1 of window 1 
         set tableSelected to true 
        end if 
        set k to k + 1 
       end repeat 

       set value of text field 1 of scroll area 1 of window 1 to currentOccurrenceName 
       click button "OK" of window 1 
      else 
       click button "Cancel" of window 1 
      end if 
     end tell 
    end tell 
    set j to j - 1 
end repeat 
+0

我一再試圖說「這不能做」,但認爲別人也許能夠拿出一些東西。令人印象深刻的解 – Chuck 2011-04-29 04:23:43