Automatically update "Assigned to" outside of executing state transitions.

We are using Assigned to during workflow transitions to assign specific tasks, eg Author,Responsible Person etc, you then move the workflow on Assign to then gets executed and the person will see their task in the Assigned to Me view, the issue is when its in that state and you add a new Author or Responsible Person, it will not update the assigned to field, send the email, and they wont see the newly assigned task in there "Assigned to Me" view.

Is there a systematic/programmatic way without having to add a new transition state to trigger the assigned to review all of these and then automatically update the assigned to?

Or is is a case of creating a new view that shows all objects (documents, tasks etc) that you are an Author or Responsible Person of?

Parents
  • We have a Metadata card group 'Who is working on this case' where you can choose the persons that fulfill certain roles:

    These persons are from Object 'Employee'.

    Let the Case Handler 'YS Test User' also be the Assigned To:

    You can choose another Case Handler, but that does not immediately change the 'Assigned to'.

    We have built an 'Advanced process handling' property for this:

    When you choose 'Change Assigned To you can choose the 'New Assigned To':

    Hit Save and an Event handler does the work, changing the current Assigned To into the New Assigned To.

    The result of this Advanced Process Handling is written in the Comments:

    With this solution you can do a bulk change of only the Assigned To (in case a person is not available for a day), or both Case Handler AND Assigned to (in case a person takes over many cases).

    The Event Handler's code as 'BeforeCheckInChangesFinalize':

    If ValueOfProperty = "Change Assigned To" Then
    
    	Dim ParentObject, oObjID, oObjVer, ChildPropertyItem, ChildPropertyName
    
    	' Logging: who requested this
    	Logging = "Advanced Process Handling request 'Change Assigned To' started"
    	IDOfProperty = 23	'Last modified by
    	ValueOfProperty = PropertyValues.SearchForProperty(IDOfProperty).TypedValue.GetValueAsUnlocalizedText
    	Logging = Logging & Chr(10) & "The requestor is: " & ValueOfProperty & "."
    
    	' Get the M-files username from the 'New Assigned To'
    	' == Get a property value of a different object. This is the scripting equivalent of %PROPERTY_XXX.PROPERTY_xxxx% ==
    	IDOfProperty = Vault.PropertyDefOperations.GetPropertyDefIDByAlias ("PD.NewAssignedTo")
    	Set ParentObject = PropertyValues.SearchForProperty( IDOfProperty ).TypedValue.GetValueAsLookups.Item(1)
    	Set oObjID = CreateObject("MFilesAPI.ObjID")
    	Call oObjID.SetIDs(ParentObject.ObjectType, ParentObject.Item)
    	IDOfProperty = Vault.PropertyDefOperations.GetPropertyDefIDByAlias ("PD.MfilesUsername")
    	Set oObjVer = Vault.ObjectOperations.GetLatestObjVer( oObjID, False, False)
    	ChildPropertyItem = Vault.ObjectPropertyOperations.GetProperty(oObjVer, IDOfProperty).TypedValue.GetValueAsLookup.Item
    	ChildPropertyName = Vault.ObjectPropertyOperations.GetProperty(oObjVer, IDOfProperty).TypedValue.GetValueAsUnlocalizedText
    
    	' Check if there is an 'Assigned To'
    	IDOfProperty = 44
    	If PropertyValues.IndexOf(IDOfProperty) > -1 Then
    		' It has the property; does it have a value?
    		If True = PropertyValues.SearchForProperty(IDOfProperty).TypedValue.IsNULL() Then
    			' It has no value
    			Err.Raise MFScriptCancel, "This case does not have an 'Assigned To', so it cannot be assigned to a different person. Please choose a different 'Advanced Process Handling' or discard."
    		End If
    	Else
    		' It does not have the property
    		Err.Raise MFScriptCancel, "This case does not have an 'Assigned To', so it cannot be assigned to a different person. Please choose a different 'Advanced Process Handling' or discard."
    	End If
    
    	' Logging: The current 'Assigned To'
    	ValueOfProperty = PropertyValues.SearchForProperty(IDOfProperty).TypedValue.GetValueAsUnlocalizedText
    	Logging = Logging & Chr(10) & "The current 'Assigned to' is: " & ValueOfProperty & "."
    
    	' Logging: The new 'Assigned To'
    	Logging = Logging & Chr(10) & "The new 'Assigned to' is: " & ChildPropertyName & "."
    
    	' Check if the current 'Assigned To' and the 'New Assigned To' are not the same persons:
    	If ValueOfProperty = ChildPropertyName Then
    		Err.Raise MFScriptCancel, ChildPropertyName & " is already assigned to this case. Please choose another person or discard."
    	End If
    				
    	' Set the Employee's M-files Username as the 'Assigned to' of this object
    	IDOfProperty = 44	' We want to write to 'Assigned To
    	DataTypeOfProperty = Vault.PropertyDefOperations.GetPropertyDef( IDOfProperty ).DataType
    	Set SetPropertyValue = CreateObject("MFilesAPI.PropertyValue")
    	SetPropertyValue.PropertyDef = IDOfProperty
    	SetPropertyValue.TypedValue.SetValue DataTypeOfProperty, ChildPropertyItem
    	Vault.ObjectPropertyOperations.SetProperty ObjVer, SetPropertyValue
    
    	' Reset the Advanced process handling' properties:
    	
    	' Clear the value of 'New Assigned To'
    	IDOfProperty = Vault.PropertyDefOperations.GetPropertyDefIDByAlias ("PD.NewAssignedTo")
    	DataTypeOfProperty = Vault.PropertyDefOperations.GetPropertyDef( IDOfProperty ).DataType
    	Set SetPropertyValue = CreateObject("MFilesAPI.PropertyValue")
    	SetPropertyValue.PropertyDef = IDOfProperty
    	SetPropertyValue.TypedValue.SetValueToNULL DataTypeOfProperty
    	Vault.ObjectPropertyOperations.SetProperty ObjVer, SetPropertyValue
    
    	' Clear the value of Advanced Process Handling
    	IDOfProperty = Vault.PropertyDefOperations.GetPropertyDefIDByAlias ("PD.AdvancedProcessHandling")
    	DataTypeOfProperty = Vault.PropertyDefOperations.GetPropertyDef( IDOfProperty ).DataType
    	Set SetPropertyValue = CreateObject("MFilesAPI.PropertyValue")
    	SetPropertyValue.PropertyDef = IDOfProperty
    	SetPropertyValue.TypedValue.SetValueToNULL DataTypeOfProperty
    	Vault.ObjectPropertyOperations.SetProperty ObjVer, SetPropertyValue
    
    	' Write Logging to Comment
    	IDOfProperty = 33	' We want to write to 'Comment'
    	DataTypeOfProperty = Vault.PropertyDefOperations.GetPropertyDef( IDOfProperty ).DataType
    	Set SetPropertyValue = CreateObject("MFilesAPI.PropertyValue")
    	SetPropertyValue.PropertyDef = IDOfProperty
    	SetPropertyValue.TypedValue.SetValue DataTypeOfProperty, Logging
    	Vault.ObjectPropertyOperations.SetProperty ObjVer, SetPropertyValue
    

    One thing missing from your wishes is sending a mail to the new Assigned To.

    This forum entry describes a generic way to send emails:

    https://community.m-files.com/forums-1552881334/f/m-files-api/5659/adding-an-attachment-to-a-notification-vbscript

  • This is great information, i think what I would like to be able to do is to have a check if the responsible person is updated and saved, then the assigned to gets updated too. We might need to dig through the details above and come up a solution of our own :-)

Reply Children
No Data