Getting Notified of Source File Changes
The users can be notified through a pop-up dialog or through the SDK when the source file of a referenced object is changed. This is useful when you have made changes to a common file and you want the changes to propagate to all users. The user can choose to accept or reject the new version. However, the file is updated on reload, if rejected.
You can respond to the file change event using FBFileMonitoringManager
. The EventFileChangeFileReference
function is called when the external file is changed. The callback function displays a dialog with two options: Load and Merge. If you choose Load, the file reference object is loaded along with the reference edit of others. If you choose Merge, the new reference edits from the external sources are merged into the current file reference object.
def EventFileChangeFileReference(control,event):
lFileRefObj = FBFindObjectByFullName( 'FileReference::NS' )
lOption = FBMessageBox( "External File Changed", "Please choose the following action for Reference: NS!", "Load", "Merge", "Ignore" )
if lOption != 3:
lUndo = FBUndoManager()
lUndo.Clear()
lFileRefObj.IsLoaded = False
lFileRefObj.IsLoaded = True
if lOption == 2:
if lFileRefObj.GetContentModified( FBPlugModificationFlag.kFBContentAllModifiedMask ):
lFileRefObj.ApplyRefEditPyScriptFromString( lFileRefObj.GetRefEdit() )
lFileMonitoring = FBFileMonitoringManager()
lFileMonitoring.OnFileChangeFileReference.Add(EventFileChangeFileReference)