|
|
|
BlueCielo Meridian Enterprise 2012 Developer's Guide | BlueCielo ECM Solutions |
Importing the SetCustomerInfo.met file defines a wizard page in the vault for selecting a customer for a new document. The user needs to select a customer name from a lookup list.
In the Meridian Enterprise Configurator you can see the following script for the NewDocument events.
Sub DocGenericEvent_BeforeNewDocument(Batch, Action, SourceFile, DocType, DocTemplate) If Len(Document.CustomerID) = 0 Then Document.CustomerName = "" Document.CustomerID = "" Document.AccountNumber = "" Document.Address = "" Document.City = "" Document.Zipcode = "" End If End Sub
Before the new document is created, the customer properties are cleared, unless the CustomerID contains a value. In that case, the task was run before and the properties will contain valid values.
After the document has been created, the Select Customer property is checked as shown in the following script. If it is not equal to the value of CustomerName, the current property values must be incorrect. In that case, the values are set to "<update pending...>" and the SetCustomerInfo task is submitted by the UpdateCustomerInfo procedure.
Sub DocGenericEvent_AfterNewDocument(Batch, Action, SourceFile, DocType, DocTemplate) If Document.CustomerName <> Document.SelectCustomer Then ' The user entered a new/changed customer ' Reset the CustomerID Document.CustomerID = "" ' Set a temporary value for the other customer properties Document.AccountNumber = "<update pending...>" Document.Address = "<update pending...>" Document.City = "<update pending...>" Document.Zipcode = "<update pending...>" End If ' Set the CustomerName Document.CustomerName = Document.SelectCustomer ' Submit a task to update the other customer properties Call UpdateCustomerInfo (Document, Document.CustomerID, Document.SelectCustomer) ' Signal the DocGenericEvent_BeforeCalculateFileName that the Customer update is already pending vault.Parameter("UpdateCustomerInfo") = "Started" End Sub Sub UpdateCustomerInfo(Document, CustomerID ,CustomerName ) ' Set the name of the lookup list with customer names Vault.Task.Set "LookupName", "Customers" ' Set the selected Customer Name Vault.Task.Set "CustomerName", CustomerName ' Set the current Customer ID Vault.Task.Set "CustomerID", CustomerID ' Submit the Task (for the current document) Vault.Task.Submit "AMSampleTask.SetCustomerInfo",Document ' Vault.Task.Reset End Sub
There are three parameters to the task. "LookupName" is the name of the lookup list that contains the customer names. The task will check this list and update it, if required.
The other parameters are "CustomerName" and "CustomerID". This information is used by the task to find the correct customer record in the external database.
The Document object is passed as the second parameter to Submit. The task extension requires this optional parameter because it will update the document property values.
After the wizard, the user will see a property page like the one in the following figure. In the background, the Task Server will be busy updating the properties. When the user refreshes the property page, after a few seconds the correct information will be available.
Copyright © 2000-2012 BlueCielo ECM Solutions |