Set Next Contractor For Batch
This topic describes functionality that you can use with features introduced in Meridian 2021.
Use Case
When there are multiple waiting project copies, the user can change their priority, but only one document at a time. This is because each document can have a different set and order of waiting Project Copies. It can be useful to set the priority for instance prioritizing a particular contractor on a batch of documents.
This example shows how you can implement a custom command that allows users to:
- Select a batch of documents
- Select a particular contractor, contact person and project to apply the command to
- Set the waiting Project Copy for this contractor as the one with priority 1 (i.e. the next Working Copy to be worked on when the active Project Copy is released as Master).
The contractor and contact person are identified by the custom properties ContractorData.ContractorName and ContractorData_ContactName.
Implement the Sample Configuration
You can download 2021 KB Articles.zip, which contains a .met file that includes a sample implementation you can use for this use case.
Select Contractor and Contact
The wizard page ‘Set next Contractor’ is used to let the user select the contractor and contact person to be the next to work on the document. The user selection is stored in the property ‘ContractorData.NextContractor'. The validation settings of this property uses the function 'WaitingContractors’ to evaluate the list of combinations of contractor, contact person and project name the user can select from:
Function WaitingContractors
Dim N: N = Document.WaitingList.Documents.Count
Dim i, sList
For i = 0 To N - 1
Dim wlDoc : Set wlDoc = Vault.GetDocument (Document.WaitingList.Documents.Document (i).ID)
sList = sList & IIf (sList = "", "", vbTab) & WaitingContractorLabel (wlDoc)
Next
WaitingContractors = Split (sList, vbTab)
End Function
The function WaitingContractorLabel calculates the label to use for the combination:
Function WaitingContractorLabel (wlDoc)
WaitingContractorLabel = wlDoc.ContractorData_ContractorName & " (" & wlDoc.ContractorData_ContactName & ") in " & wlDoc.ProjectName
End Function
Command Script
Changing the priority of the waiting project copy that matches the selection is done in this script:
Sub SetnextContractor_Execute(Batch)
If Not Document Is Nothing Then
If Not Document.ParentProject Is Nothing Then
Batch.FailCurrent "Please select a master document"
Else
Dim N: N = Document.WaitingList.Documents.Count
Dim i
For i = 1 To N - 1
Dim wlDoc : Set wlDoc = Vault.GetDocument (Document.WaitingList.Documents.Document (i).ID)
If WaitingContractorLabel (wlDoc) = Document.ContractorData_NextContractor Then
Document.WaitingList.Move Document.WaitingList.Documents.Document (i), -i
Batch.PrintDetails "Waiting project copy for " & Document.ContractorData_NextContractor & " was moved to priority 1"
Exit Sub
End If
Next
Batch.FailCurrent "No waiting project copy for " & Document.ContractorData_NextContractor & " with priority > 2 was found"
End If
End If
End Sub
The second argument if the WaitingList.Move method is a priority shift, not an absolute priority. So to move the document to the top of the list, it must be moved up by the number of steps equal to its current position in the list. Hence the value -i for that argument in line 12.
