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

Help with VBScript to Create Document in Event Handler

Former Member
Former Member
Hi All,

I have search the forum and have managed to covert VB to VBScript but i still cant get the following to work. I am being held up on the final line of code which creates the object with a Type Mismatch Error.

Can someone please help.

here is my code;

Option Explicit

Dim oClass: Set oClass = CreateObject("MFilesAPI.PropertyValue")
Dim oName: Set oName = CreateObject("MFilesAPI.PropertyValue")
Dim oPropValsNew: Set oPropValsNew = CreateObject("MFilesAPI.PropertyValues")

'Set Name
oName.PropertyDef = MFBuiltInPropertyDefNameOrTitle
oName.TypedValue.SetValue MFDatatypeText, "Test"
oPropValsNew.Add -1, oName

'Set Class
oClass.PropertyDef = MFBuiltInPropertyDefClass
oClass.TypedValue.SetValue MFDatatypeLookup, 0
oPropValsNew.Add -1, oClass

vault.ObjectOperations.CreateNewObject 0, oPropValsNew


Parents
  • Former Member
    Former Member
    Thankyou for reply Samppa,

    This gives me a better Idea of how to structure.

    This script however gives me the following error.

    'The maximum number of objects created for the object type '0' was exceeded during the execution of a script.'

    I want to create an additional document when a document is added to m-files.

    I am therefore using the "AfterCreateNewObjectFinalise" which I beleive is the correct event.

    Ahhhhh...

    I just realised what is happening. Im creating a nasty loop. When my script document is created it fires the same script trying to create a new document again, and again.

    Any ideas on how i can catch this/prevent this loop.


Reply
  • Former Member
    Former Member
    Thankyou for reply Samppa,

    This gives me a better Idea of how to structure.

    This script however gives me the following error.

    'The maximum number of objects created for the object type '0' was exceeded during the execution of a script.'

    I want to create an additional document when a document is added to m-files.

    I am therefore using the "AfterCreateNewObjectFinalise" which I beleive is the correct event.

    Ahhhhh...

    I just realised what is happening. Im creating a nasty loop. When my script document is created it fires the same script trying to create a new document again, and again.

    Any ideas on how i can catch this/prevent this loop.


Children
No Data