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

Err.raise MFScriptCancel generates an "Object Required" error

Hello everyone,

I've been struggling with a strange error coming up while i'm doing some vbscript on Workflows.
When I use Err.raise MFScriptCancel, "blabla" it generates an error message : "Object Required"

Can somebody help me with that ?

Thank you in advance

'
' Check on document creation that a document with the same Document ID does not exist
'

' Get the properties of the object

Const DOCUMENT_OBJECTTYPE = 0  ' Document Object Type
Const SUPPLIER_PROPERTY = 1042 ' Supplier Property
Const CONFIRMED_ORDER_NUMBER_PROPERTY = 1302 'Confirmed order number property
Const CONFIRMED_ORDER_CLASS_NUMBER = 29 'Confirmed order class number
Const CLASS_PROPERTY = 100 'Class Property
CONST PROJECT_PROPERTY = 1320 ' Project Property
CONST PROJECT_A3_PROPERTY = 1075 'A3 Project Property
CONST PROJECT_A3_BOOLEAN_PROPERTY = 1373 ' Projet A3 boolean
CONST CONFIRMED_ORDER_DATE_PROPERTY = 1231 'Confirmed order Date property
CONST CONFIRMED_ORDER_SUBJECT_PROPERTY = 1304 ' Confirmed order subject property
Dim PropertyValues : Set PropertyValues = Vault.ObjectPropertyOperations.GetProperties( ObjVer, True )

'If the object is a document and belongs to the "Confirmation de commande" class
if( ObjVer.Type = DOCUMENT_OBJECTTYPE) and (PropertyValues.SearchForProperty(CLASS_PROPERTY).TypedValue.DisplayValue = "Confirmation de commande") then

		 err.raise mfscriptcancel, "yourmessage here" 
	  'Get current property
	  Dim Supplier : Supplier = PropertyValues.SearchForProperty(SUPPLIER_PROPERTY).TypedValue.DisplayValue               
	  Dim confirmedOrderNumber : confirmedOrderNumber = PropertyValues.SearchForProperty(CONFIRMED_ORDER_NUMBER_PROPERTY).TypedValue.DisplayValue
	  Dim projectValue : projectValue = PropertyValues.SearchForProperty(PROJECT_PROPERTY).TypedValue.DisplayValue

	  'Get the A3 Project instead if it's mentioned		
	  Dim isProjectA3 : isProjectA3 = PropertyValues.SearchForProperty(PROJECT_A3_BOOLEAN_PROPERTY).TypedValue.Value
	  if (isProjectA3 = TRUE) then
	  	projectValue = PropertyValues.SearchForProperty(PROJECT_A3_PROPERTY).TypedValue.DisplayValue
	  End if

	  Dim confirmedOrderDateValue : confirmedOrderDateValue = PropertyValues.SearchForProperty(CONFIRMED_ORDER_DATE_PROPERTY).TypedValue.DisplayValue
	  Dim confirmedOrderSubjectValue : confirmedOrderSubjectValue = PropertyValues.SearchForProperty(CONFIRMED_ORDER_SUBJECT_PROPERTY).TypedValue.DisplayValue
	
	  'Create a reusable search condition to create Conditions to add to a Condition set
	  'Purpose is to search for documents with same suppliers and invoice numbers to get duplicatas
	  Dim Condition : Set Condition = CreateObject("MFilesAPI.SearchCondition")
	  'Create a search conditions set 
	  Dim ConditionSet : Set ConditionSet = CreateObject("MFilesAPI.SearchConditions")
	
	  'Create condition : Non deleted objects
	  Condition.ConditionType = MFConditionTypeEqual
	  Condition.Expression.DataStatusValueType = MFStatusTypeDeleted
	  Condition.TypedValue.SetValue MFDatatypeBoolean, False
	  ConditionSet.Add -1, Condition
	
	  'Create condition : Documents only
	  Condition.ConditionType = MFConditionTypeEqual
	  Condition.Expression.DataStatusValueType = MFStatusTypeObjectTypeID
	  Condition.TypedValue.SetValue MFDatatypeLookup, DOCUMENT_OBJECTTYPE
	  ConditionSet.Add -1, Condition

	  'Create condition : Confirmed order only
	  Condition.ConditionType = MFConditionTypeEqual
	  Condition.Expression.DataPropertyValuePropertyDef = CLASS_PROPERTY
	  Condition.TypedValue.SetValue MFDatatypeLookup, CONFIRMED_ORDER_CLASS_NUMBER 
	  ConditionSet.Add -1, Condition
	
	  'Get the SUPPLIER_PROPERTY of the object.
	  Condition.ConditionType = MFConditionTypeEqual
	  Condition.Expression.DataPropertyValuePropertyDef = SUPPLIER_PROPERTY
	  Condition.TypedValue.SetValue 1, Supplier
	  ConditionSet.Add -1, Condition

	  'Get the PROJECT of the object.
	  Condition.ConditionType = MFConditionTypeEqual
	  Condition.Expression.DataPropertyValuePropertyDef = PROJECT_PROPERTY
	  Condition.TypedValue.SetValue 1, projectValue ' 1 = MFDatatypeText
	  ConditionSet.Add -1, Condition
		
	  ' Get the Confirmed Order Number of the object
	  Condition.ConditionType = MFConditionTypeEqual
	  Condition.Expression.DataPropertyValuePropertyDef = CONFIRMED_ORDER_NUMBER_PROPERTY
	  Condition.TypedValue.SetValue 1, confirmedOrderNumber ' 1 = MFDatatypeText
	  ConditionSet.Add -1, Condition

	  ' Get the Confirmed Order Date of the object
	  Condition.ConditionType = MFConditionTypeEqual
	  Condition.Expression.DataPropertyValuePropertyDef = CONFIRMED_ORDER_DATE_PROPERTY
	  Condition.TypedValue.SetValue 5, confirmedOrderDateValue 
	  ConditionSet.Add -1, Condition

	  ' Get the Confirmed Order Subject of the object
	  Condition.ConditionType = MFConditionTypeEqual
	  Condition.Expression.DataPropertyValuePropertyDef = CONFIRMED_ORDER_SUBJECT_PROPERTY
	  Condition.TypedValue.SetValue 1, confirmedOrderSubjectValue ' 1 = MFDatatypeText
	  ConditionSet.Add -1, Condition
	
	  'Let out void offers
	  Condition.ConditionType = MFConditionTypeNotEqual
	  Condition.Expression.DataPropertyValuePropertyDef = CONFIRMED_ORDER_NUMBER_PROPERTY
	  Condition.TypedValue.SetValue 1, "" 
	  ConditionSet.Add -1, Condition
	
	  Dim oResults 'As ObjectSearchResults
	  Set oResults = Vault.ObjectSearchOperations.SearchForObjectsByConditions(ConditionSet, MFSearchFlagNone, False) 'False = SortResults
	  
	  
	  Dim doublonPropValue
	  If oResults.Count > 0 Then
		
	    Dim i : Dim oRes 'As MFilesAPI.ObjectVersion
	    dim err : err = false 
		For i=1 To oResults.Count
		    Set oRes = oResults.Item(i)
		    If oRes.ObjVer.ID<>ObjVer.ID Then
				err = true 
			End If
		Next
		If err = true Then 
			Set doublonPropValue = CreateObject("MFilesAPI.PropertyValue")
			doublonPropValue.propertyDef = 1162
			doublonPropValue.TypedValue.SetValue MFDataTypeBoolean, true
		
			Vault.ObjectPropertyOperations.SetProperty ObjVer, doublonPropValue
		Else 
			Set doublonPropValue = CreateObject("MFilesAPI.PropertyValue")
			doublonPropValue.propertyDef = 1162
			doublonPropValue.TypedValue.SetValue MFDataTypeBoolean, false
			
			Vault.ObjectPropertyOperations.SetProperty ObjVer, doublonPropValue
	  End if
	End if
End if

CoScriptObjectFactory.cpp, 465, Script execution failed. ((010 - Gestion des doublons, StateAction: 1596915-8)) (0x800408BB)
ScriptErrorHelper.cpp, 96, Script execution failed. ((010 - Gestion des doublons, StateAction: 1596915-8)) (0x800408BB)
MDispatchExImpl.h, 694, Script execution failed. ((010 - Gestion des doublons, StateAction: 1596915-8)) (0x800408BB)
MDispatchExImpl.h, 994, Script execution failed. ((010 - Gestion des doublons, StateAction: 1596915-8)) (0x800408BB)
MetadataCardAction.cpp, 386, Script execution failed. ((010 - Gestion des doublons, StateAction: 1596915-8)) (0x800408BB)
MetadataCardAction.cpp, 570, Script execution failed. ((010 - Gestion des doublons, StateAction: 1596915-8)) (0x800408BB)
MetadataEditor.cpp, 2967, Script execution failed. ((010 - Gestion des doublons, StateAction: 1596915-8)) (0x800408BB)
MetadataModel.cpp, 4262, Script execution failed. ((010 - Gestion des doublons, StateAction: 1596915-8)) (0x800408BB)
MetadataModel.cpp, 4699, Script execution failed. ((010 - Gestion des doublons, StateAction: 1596915-8)) (0x800408BB)
ElectronicSignatureUIHelper.cpp, 235, Script execution failed. ((010 - Gestion des doublons, StateAction: 1596915-8)) (0x800408BB)
MetadataModel.cpp, 12187, Script execution failed. ((010 - Gestion des doublons, StateAction: 1596915-8)) (0x800408BB)
CoVaultMountingDocumentOperations.cpp, 3140, Script execution failed. ((010 - Gestion des doublons, StateAction: 1596915-8)) (0x800408BB)
DocumentCache.cpp, 11174, Script execution failed. ((010 - Gestion des doublons, StateAction: 1596915-8)) (0x800408BB)
DocumentCache.cpp, 11283, Script execution failed. ((010 - Gestion des doublons, StateAction: 1596915-8)) (0x800408BB)
DocumentCache.cpp, 19436, Script execution failed. ((010 - Gestion des doublons, StateAction: 1596915-8)) (0x800408BB)
RPCMethodCallWithRetry.h, 35, Script execution failed. ((010 - Gestion des doublons, StateAction: 1596915-8)) (0x800408BB)
RPCMethodCallWithRetry.h, 35, Script execution failed. ((010 - Gestion des doublons, StateAction: 1596915-8)) (0x800408BB)
RPCDocumentOperations.cpp, 12536, Script execution failed. ((010 - Gestion des doublons, StateAction: 1596915-8)) (0x800408BB)
RPCDocumentOperations.cpp, 7383, Script execution failed. ((010 - Gestion des doublons, StateAction: 1596915-8)) (0x800408BB)
MCallInLoop.h, 711, Script execution failed. ((010 - Gestion des doublons, StateAction: 1596915-8)) (0x800408BB)
RPCDocumentOperationsHelper.cpp, 3925, Script execution failed. ((010 - Gestion des doublons, StateAction: 1596915-8)) (0x800408BB)
RPCDocumentOperationsHelper.cpp, 3492, Script execution failed. ((010 - Gestion des doublons, StateAction: 1596915-8)) (0x800408BB)
RPCDocumentOperationsHelper.cpp, 8880, Script execution failed. ((010 - Gestion des doublons, StateAction: 1596915-8)) (0x800408BB)
RPCDocumentOperationsHelper.cpp, 9452, Script execution failed. ((010 - Gestion des doublons, StateAction: 1596915-8)) (0x800408BB)
RPCDocumentOperationsHelper.cpp, 26788, Script execution failed. ((010 - Gestion des doublons, StateAction: 1596915-8)) (0x800408BB)
RPCDocumentOperationsHelperPrivate.cpp, 2826, Script execution failed. ((010 - Gestion des doublons, StateAction: 1596915-8)) (0x800408BB)
RPCDocumentOperationsHelperPrivate.cpp, 3038, Script execution failed. ((010 - Gestion des doublons, StateAction: 1596915-8)) (0x800408BB)
RPCDocumentOperationsHelperPrivate.cpp, 3457, Script execution failed. ((010 - Gestion des doublons, StateAction: 1596915-8)) (0x800408BB)
RPCDocumentOperationsHelperPrivate.cpp, 4295, Script execution failed. ((010 - Gestion des doublons, StateAction: 1596915-8)) (0x800408BB)
VaultScriptSessionTemplates.cpp, 269, Script execution failed. ((010 - Gestion des doublons, StateAction: 1596915-8)) (0x800408BB)
VaultScriptSessionTemplates.cpp, 328, Script execution failed. ((010 - Gestion des doublons, StateAction: 1596915-8)) (0x800408BB)
VaultScriptSessionTemplates.cpp, 328, Object required: '' (0x80040008)
VaultScriptSessionTemplates.cpp, 501, Object required: '' (0x80040008)
CoActiveScriptSite.cpp, 893, Object required: '' (0x80040008)
CoActiveScriptSite.cpp, 735, Object required: '' (0x80040008)
010 - Gestion des doublons, StateAction, 22, Object required: '' (0x80040008)
MErrorHelper.cpp, 2457, Object required: '' (0x80040008)
(M-Files 21.2.9928.4)

Parents Reply Children
No Data