This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Create New Assignment - Workflow Script

I am trying to create a new assignment via a script and it keeps telling me that I have a type mismatch when creating the assignment:

Dim newValue : Set newValue = CreateObject("MFilesAPI.TypedValue")
newvalue.SetValue MFDatatypeLookup, 104
Dim MyRecordSet : set MyRecordSet = CreateObject("ADODB.RecordSet")
MyRecordSet.Open SelectStatement, oConnection

Vault.ObjectOperations.CreateNewAssignment "Part " & MyRecordSet.Fields(3) & " Revision " & MyRecordSet.Fields(4) & " Assembly Update", "Please Update the assembly for " & MyRecordSet.Fields(0) & " Revision " & MyRecordSet.Fields(1) & ". The Assembly needs to be updated because the current revision was end dated.", newvalue

Parents
  • Hello,

    Even though these parameters are optional, you have to set them to nothing in the command.

    Optional ByVal Deadline As TypedValue = 0, _
       Optional ByVal AccessControlList As AccessControlList = 0 _

    Vault.ObjectOperations.CreateNewAssignment "Part " & MyRecordSet.Fields(3) & " Revision " & MyRecordSet.Fields(4) & " Assembly Update", "Please Update the assembly for " & MyRecordSet.Fields(0) & " Revision " & MyRecordSet.Fields(1) & ". The Assembly needs to be updated because the current revision was end dated.", newvalue, nothing, nothing

    Also, I think that you need to get the values of the fields in the record set, for example MyRecordSet.Fields(3).Value

  • I added those to the creation of the assignment. It is still having issues. I believe it is with the user input not being in the correct format. Any idea how I should be setting up the AssignedToUser? I did verify that MyRecordSet.Fields(3) shows the value when testing using err.raise.

    ByVal AssignedToUser As TypedValue, _
  • The assignement is created in a State with Run Action?

    If yes, does the metadata card of the object in the workflow, contains the user that you want to create the assignement?

  • Yes it is, and no it does not contain the user that I want to assign. Ideally I would like to assign a user group, but I don't know that that is possible. I do know the User group Id and it will be static.

  • I was able to get it working using this code for the User, do you know if it is possible to use a user group instead? When using a user group ID it did not find it.

    'Create the current user ID as typed value
    	Dim typed: Set typed = CreateObject("MFilesAPI.TypedValue")
    	Dim oLUUsers: Set oLUUsers = CreateObject("MFilesAPI.Lookups")
    	Dim oLUOneUser: Set oLUOneUser = CreateObject("MFilesAPI.Lookup")
    	
    	'Get the user
    	oLUOneUser.Item = 82' The id of the user (to be assigned)
    	oLUOneUser.Version = -1
    	Call oLUUsers.Add(-1, oLUOneUser)
    	Call typed.SetValueToMultiSelectLookup(oLUUsers)

  • Good to hear that.

    Members of the user group. Group IDs are negative, user IDs are positive. (From API Documentation).

    Try to add "-" before the id of the group.

  • The - in front didn't work. I guess I could create an array of Users in the user group and loop through that array and create individual assignments.

Reply Children
No Data