The M-Files Community will be updated on Tuesday, April 2, 2024 at 10:00 AM EST / 2:00 PM GMT and the update is expected to last for several hours. The site will be unavailable during this time.

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

VBScript Not working properly

Hello Team
Good day to you :) 

I just was wondering if there is any new update that came up for M-files that will affect the data types. Because I had a code that actually was working, and just recently it stopped working and kept throwing this error:


<MetadataEditor>, -, Script execution failed. ((Abbvie Drug Prescribed, StateAction: 224-12-17)) (0x800408BB)
ScriptErrorHelper.cpp, 96, Script execution failed. ((Abbvie Drug Prescribed, StateAction: 224-12-17)) (0x800408BB)
MDispatchExImpl.h, 688, Script execution failed. ((Abbvie Drug Prescribed, StateAction: 224-12-17)) (0x800408BB)
MDispatchExImpl.h, 850, Script execution failed. ((Abbvie Drug Prescribed, StateAction: 224-12-17)) (0x800408BB)
MetadataCardAction.cpp, 386, Script execution failed. ((Abbvie Drug Prescribed, StateAction: 224-12-17)) (0x800408BB)
MetadataCardAction.cpp, 570, Script execution failed. ((Abbvie Drug Prescribed, StateAction: 224-12-17)) (0x800408BB)
MetadataEditor.cpp, 2960, Script execution failed. ((Abbvie Drug Prescribed, StateAction: 224-12-17)) (0x800408BB)
MetadataModel.cpp, 4276, Script execution failed. ((Abbvie Drug Prescribed, StateAction: 224-12-17)) (0x800408BB)
MetadataModel.cpp, 4713, Script execution failed. ((Abbvie Drug Prescribed, StateAction: 224-12-17)) (0x800408BB)
ElectronicSignatureUIHelper.cpp, 239, Script execution failed. ((Abbvie Drug Prescribed, StateAction: 224-12-17)) (0x800408BB)
MetadataModel.cpp, 12218, Script execution failed. ((Abbvie Drug Prescribed, StateAction: 224-12-17)) (0x800408BB)
CoVaultMountingDocumentOperations.cpp, 3284, Script execution failed. ((Abbvie Drug Prescribed, StateAction: 224-12-17)) (0x800408BB)
DocumentCache.cpp, 11717, Script execution failed. ((Abbvie Drug Prescribed, StateAction: 224-12-17)) (0x800408BB)
DocumentCache.cpp, 11826, Script execution failed. ((Abbvie Drug Prescribed, StateAction: 224-12-17)) (0x800408BB)
DocumentCache.cpp, 20330, Script execution failed. ((Abbvie Drug Prescribed, StateAction: 224-12-17)) (0x800408BB)
RPCMethodCallWithRetry.h, 35, Script execution failed. ((Abbvie Drug Prescribed, StateAction: 224-12-17)) (0x800408BB)
RPCMethodCallWithRetry.h, 35, Script execution failed. ((Abbvie Drug Prescribed, StateAction: 224-12-17)) (0x800408BB)
RPCDocumentOperations.cpp, 13050, Script execution failed. ((Abbvie Drug Prescribed, StateAction: 224-12-17)) (0x800408BB)
RPCDocumentOperations.cpp, 7391, Script execution failed. ((Abbvie Drug Prescribed, StateAction: 224-12-17)) (0x800408BB)
MCallInLoop.h, 712, Script execution failed. ((Abbvie Drug Prescribed, StateAction: 224-12-17)) (0x800408BB)
RPCDocumentOperationsHelper.cpp, 4221, Script execution failed. ((Abbvie Drug Prescribed, StateAction: 224-12-17)) (0x800408BB)
RPCDocumentOperationsHelper.cpp, 3779, Script execution failed. ((Abbvie Drug Prescribed, StateAction: 224-12-17)) (0x800408BB)
RPCDocumentOperationsHelper.cpp, 9461, Script execution failed. ((Abbvie Drug Prescribed, StateAction: 224-12-17)) (0x800408BB)
RPCDocumentOperationsHelper.cpp, 10135, Script execution failed. ((Abbvie Drug Prescribed, StateAction: 224-12-17)) (0x800408BB)
RPCDocumentOperationsHelper.cpp, 27973, Script execution failed. ((Abbvie Drug Prescribed, StateAction: 224-12-17)) (0x800408BB)
RPCDocumentOperationsHelperPrivate.cpp, 2914, Script execution failed. ((Abbvie Drug Prescribed, StateAction: 224-12-17)) (0x800408BB)
RPCDocumentOperationsHelperPrivate.cpp, 3131, Script execution failed. ((Abbvie Drug Prescribed, StateAction: 224-12-17)) (0x800408BB)
RPCDocumentOperationsHelperPrivate.cpp, 3552, Script execution failed. ((Abbvie Drug Prescribed, StateAction: 224-12-17)) (0x800408BB)
RPCDocumentOperationsHelperPrivate.cpp, 4391, Script execution failed. ((Abbvie Drug Prescribed, StateAction: 224-12-17)) (0x800408BB)
VaultScriptSessionTemplates.cpp, 275, Script execution failed. ((Abbvie Drug Prescribed, StateAction: 224-12-17)) (0x800408BB)
VaultScriptSessionTemplates.cpp, 340, Script execution failed. ((Abbvie Drug Prescribed, StateAction: 224-12-17)) (0x800408BB)
VaultScriptSessionTemplates.cpp, 340, Wrong data type for property definition "Lab Request Form". (0x8004009A)
VaultScriptSessionTemplates.cpp, 523, Wrong data type for property definition "Lab Request Form". (0x8004009A)
CoActiveScriptSite.cpp, 895, Wrong data type for property definition "Lab Request Form". (0x8004009A)
CoActiveScriptSite.cpp, 737, Wrong data type for property definition "Lab Request Form". (0x8004009A)
Abbvie Drug Prescribed, StateAction, 134, Wrong data type for property definition "Lab Request Form". (0x8004009A)
MNullPropagatingDispatchImpl.h, 126, Wrong data type for property definition "Lab Request Form". (0x8004009A)
MNullPropagatingDispatchImpl.h, 173, Wrong data type for property definition "Lab Request Form". (0x8004009A)
CoVaultObjectOperations.cpp, 569, Wrong data type for property definition "Lab Request Form". (0x8004009A)
CoVaultObjectOperations.cpp, 2287, Wrong data type for property definition "Lab Request Form". (0x8004009A)
ServerVaultObjectOperationsHelper.cpp, 1091, Wrong data type for property definition "Lab Request Form". (0x8004009A)
ServerVaultObjectOperationsHelper.cpp, 1376, Wrong data type for property definition "Lab Request Form". (0x8004009A)
ServerVaultObjectOperationsHelper.cpp, 1608, Wrong data type for property definition "Lab Request Form". (0x8004009A)
RPCObjectOperationsHelper.cpp, 485, Wrong data type for property definition "Lab Request Form". (0x8004009A)
CoRPCOverCOM.cpp, 6343, Wrong data type for property definition "Lab Request Form". (0x8004009A)
RPCDocumentOperations.cpp, 5607, Wrong data type for property definition "Lab Request Form". (0x8004009A)
MCallInLoop.h, 712, Wrong data type for property definition "Lab Request Form". (0x8004009A)
RPCDocumentOperationsHelper.cpp, 223, Wrong data type for property definition "Lab Request Form". (0x8004009A)
RPCDocumentOperationsHelper.cpp, 289, Wrong data type for property definition "Lab Request Form". (0x8004009A)
RPCDocumentOperationsHelperPrivate.cpp, 8845, Wrong data type for property definition "Lab Request Form". (0x8004009A)
RPCDocumentOperationsHelperPrivate.cpp, 9594, Wrong data type for property definition "Lab Request Form". (0x8004009A)
(M-Files 22.8.11717.3 2022-09-23T12:22:41.292Z)

And The code I was using is this:

Option Explicit

Dim iPDLabRequest: iPDLabRequest = 1605 'LabRequest Property Definition ID
Dim iPDName: iPDName = 1032 'Patient Property Definition ID
Dim iPDBirthdate: iPDBirthdate = 1046 'Patient Property Definition ID
Dim iPDGender: iPDGender = 1019 'Patient Property Definition ID
Dim iPDMobile: iPDMobile = 1044 'Patient Property Definition ID
Dim iPDCity: iPDCity = 1029 'Patient Property Definition ID
Dim iPDCountry: iPDCountry = 1027 'Patient Property Definition ID
Dim iPDNationality: iPDNationality = 1021 'Patient Property Definition ID
'Dim iPDDose: iPDDose = 1092 'Dose Property Definition ID
Dim iPDDrug: iPDDrug = 1133 'Drug Property Definition ID
Dim iPDCareConsultant: iPDCareConsultant = 1045 'Drug Property Definition ID
Dim iPDIndication: iPDIndication = 1025 'Drug Property Definition ID
Dim iPDPharmacy: iPDPharmacy = 1069 'Drug Property Definition I
Dim iPDReferralDate: iPDReferralDate = 1257 'Due Date Property Definition ID
Dim iPDFirstEncounterDate: iPDFirstEncounterDate = 1258 'Next Dose After Property Definition ID
Dim iPDEnrollmentDate: iPDEnrollmentDate = 1073 'Next Dose After Property Definition ID

Dim iOTDoseReminder: iOTDoseReminder = 110 'Patient Object Type
Dim iCLDoseReminder: iCLDoseReminder = 4 'Patient Class ID

Dim iPDState: iPDState = 39 'State Property Definition
Dim iPDStateDoseScheduled: iPDStateDoseScheduled = 101 'State Dose Scheduled Property Definition
Dim iPDWorkFlow: iPDWorkflow = 38 'Workflow Property Definition
Dim iPDDoseReminderWorkflow: iPDDoseReminderWorkflow = 101 'Dose Reminder Workflow Property Definition


	        ' Create a new Patient
	        Dim oPropVals: Set oPropVals = CreateObject("MFilesAPI.PropertyValues")
	        Dim oOnePropVal: Set oOnePropVal = CreateObject("MFilesAPI.PropertyValue")
	        
	         ' Class = Patient
	        oOnePropVal.PropertyDef = 100
	        oOnePropVal.TypedValue.SetValue MFDatatypeLookup, iCLDoseReminder
	        oPropVals.Add -1, oOnePropVal

			' Lab Request Form
	        oOnePropVal.PropertyDef = iPDLabRequest
	        oOnePropVal.TypedValue.SetValue MFDatatypeLookup, Objver.ID
	        oPropVals.Add -1, oOnePropVal

	        ' Patient
	        oOnePropVal.PropertyDef = iPDName
	        oOnePropVal.TypedValue.SetValue MFDatatypeText, PropertyValues.SearchForProperty(iPDName).TypedValue.Value
	        oPropVals.Add -1, oOnePropVal

			' Drug
	        oOnePropVal.PropertyDef = iPDDrug
	        oOnePropVal.TypedValue.SetValue MFDatatypeLookup, PropertyValues.SearchForProperty(iPDDrug).TypedValue.Value
	        oPropVals.Add -1, oOnePropVal
			
	        ' Dose
	        'oOnePropVal.PropertyDef = iPDDose
	        'oOnePropVal.TypedValue.SetValue MFDatatypeLookup, PropertyValues.SearchForProperty(iPDDose).TypedValue.Value
	        'oPropVals.Add -1, oOnePropVal

	        ' Referral Date
	        oOnePropVal.PropertyDef = iPDReferralDate
	        oOnePropVal.TypedValue.SetValue MFDatatypeDate, PropertyValues.SearchForProperty(iPDReferralDate).TypedValue.Value
		    oPropVals.Add -1, oOnePropVal
			
			' FirstEncounterDate
	        oOnePropVal.PropertyDef = iPDFirstEncounterDate
	        oOnePropVal.TypedValue.SetValue MFDatatypeDate, PropertyValues.SearchForProperty(iPDFirstEncounterDate).TypedValue.Value
		    oPropVals.Add -1, oOnePropVal

			' EnrollmentDate
	        oOnePropVal.PropertyDef = iPDEnrollmentDate
	        oOnePropVal.TypedValue.SetValue MFDatatypeDate, PropertyValues.SearchForProperty(iPDEnrollmentDate).TypedValue.Value
		    oPropVals.Add -1, oOnePropVal
			
			'Birthdate
			oOnePropVal.PropertyDef = iPDBirthdate
	        oOnePropVal.TypedValue.SetValue MFDatatypeDate, PropertyValues.SearchForProperty(iPDBirthdate).TypedValue.Value
		    oPropVals.Add -1, oOnePropVal
			
			'Gender
			oOnePropVal.PropertyDef = iPDGender
	        oOnePropVal.TypedValue.SetValue MFDatatypeLookup, PropertyValues.SearchForProperty(iPDGender).TypedValue.Value
		    oPropVals.Add -1, oOnePropVal
			
			'Mobile
			oOnePropVal.PropertyDef = iPDMobile
	        oOnePropVal.TypedValue.SetValue MFDatatypeText, PropertyValues.SearchForProperty(iPDMobile).TypedValue.Value
		    oPropVals.Add -1, oOnePropVal
			
			'City
			oOnePropVal.PropertyDef = iPDCity
	        oOnePropVal.TypedValue.SetValue MFDatatypeLookup, PropertyValues.SearchForProperty(iPDCity).TypedValue.Value
		    oPropVals.Add -1, oOnePropVal
			
			'Country
			oOnePropVal.PropertyDef = iPDCountry
	        oOnePropVal.TypedValue.SetValue MFDatatypeLookup, PropertyValues.SearchForProperty(iPDCountry).TypedValue.Value
		    oPropVals.Add -1, oOnePropVal
			
			'Nationality
			oOnePropVal.PropertyDef = iPDNationality
	        oOnePropVal.TypedValue.SetValue MFDatatypeLookup, PropertyValues.SearchForProperty(iPDNationality).TypedValue.Value
		    oPropVals.Add -1, oOnePropVal
			
			'CareConsultant
			oOnePropVal.PropertyDef = iPDCareConsultant
	        oOnePropVal.TypedValue.SetValue MFDatatypeLookup, PropertyValues.SearchForProperty(iPDCareConsultant).TypedValue.Value
		    oPropVals.Add -1, oOnePropVal
			
			'Indication
			oOnePropVal.PropertyDef = iPDIndication
	        oOnePropVal.TypedValue.SetValue MFDatatypeLookup, PropertyValues.SearchForProperty(iPDIndication).TypedValue.Value
		    oPropVals.Add -1, oOnePropVal
			
			'Pharmacy
			oOnePropVal.PropertyDef = iPDPharmacy
	        oOnePropVal.TypedValue.SetValue MFDatatypeLookup, PropertyValues.SearchForProperty(iPDPharmacy).TypedValue.Value
		    oPropVals.Add -1, oOnePropVal
			

	        ' Assign workflow - Patient Workflow
	        oOnePropVal.PropertyDef = iPDWorkFlow
	        oOnePropVal.TypedValue.SetValue MFDatatypeLookup, iPDDoseReminderWorkflow
	        oPropVals.Add -1, oOnePropVal

	        ' Assign workflow state - New Patient
	        oOnePropVal.PropertyDef = iPDState
	        oOnePropVal.TypedValue.SetValue MFDatatypeLookup, iPDStateDoseScheduled
	        oPropVals.Add -1, oOnePropVal

	        ' Not single file document 
	        oOnePropVal.PropertyDef = 22
	        oOnePropVal.TypedValue.SetValue MFDataType.MFDatatypeBoolean, false
	        oPropVals.Add -1, oOnePropVal			
  	        
	        Dim oObjectVersionAndProperties: set oObjectVersionAndProperties = Vault.ObjectOperations.CreateNewObject(iOTDoseReminder, oPropVals, nothing, nothing)
			Call Vault.ObjectOperations.CheckIn(oObjectVersionAndProperties.ObjVer)


Any Ideas?

Parents
  • Well seems the error is in this line:

    Dim oObjectVersionAndProperties: set oObjectVersionAndProperties = Vault.ObjectOperations.CreateNewObject(iOTDoseReminder, oPropVals, nothing, nothing)

    For some reason, it stopped functioning the same old way. Any ideas?
    The code works without this line.

    Does that mean one of the properties in the object I am trying to create is not matching with what I am getting?

  • Hi Mohammed,

    Don't know if they have changed anything in the way the API functions but I too have seen a script that has worked for years suddenly create errors after the 22.9 update. However, it is not quite the same type of problem as you get here.

    Anyway, at a quick glance it seems like you pretty much are creating a new object as a clone of an object already chosen (getting values from PropertyValues and ObjVer). I assume you are starting out from some kind of template or other object that is supposed to have all the relevant propertyvalues except for the few properties where you enter a fixed value.

    I noticed that you do not use Aliases but type in the property definition IDs directly in your script. That is fine as long as you only use the script in this particular vault. If you ever create a new vault as a copy of the old one, the properties will not necessarily get the same ID in the new vault. This would then cause the script to create errors. Same thing will happen if you try to copy the script to a different vault.

    Regardless of Aliases or not, if a property changes type it would also cause errors like the one you get here. Not many types can change at all, but it is possible to go from single select to multi select lookup as well as a few other changes, I believe. Might that have happened here?

  • Hello Sir.

    I appreciate your response. Regarding your question, we didn't touch anything within the vault after implementing this code. we didn't change any property type.

    So usually what I am doing is implementing the code in 2 vaults.. one in the test vault and another in the production vault. The code worked in both of them before. But now it doesn't work anymore.


    Another test I made is that I tried to capture each property alone first. to see if the code error is caused by property type or something else.
    So I extracted every property using the script and it worked just fine. ONLY when I reach the line of creating a new object, it throws the error

    This line: Dim oObjectVersionAndProperties: set oObjectVersionAndProperties = Vault.ObjectOperations.CreateNewObject(iOTDoseReminder, oPropVals, nothing, nothing)

Reply
  • Hello Sir.

    I appreciate your response. Regarding your question, we didn't touch anything within the vault after implementing this code. we didn't change any property type.

    So usually what I am doing is implementing the code in 2 vaults.. one in the test vault and another in the production vault. The code worked in both of them before. But now it doesn't work anymore.


    Another test I made is that I tried to capture each property alone first. to see if the code error is caused by property type or something else.
    So I extracted every property using the script and it worked just fine. ONLY when I reach the line of creating a new object, it throws the error

    This line: Dim oObjectVersionAndProperties: set oObjectVersionAndProperties = Vault.ObjectOperations.CreateNewObject(iOTDoseReminder, oPropVals, nothing, nothing)

Children
No Data