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

how to create an object type (in VB) on workflow state transition

Hello,

I am trying to create an object type when the workflow is in the final stage. The object type is connected over an external source through API.
The idea is to notify some external system through object type creation.

on the workflow transition, I have added the following code in the workflow state PreConditions:


option explicit


Dim publishedReportObjectTypeAdmin
Set publishedReportObjectTypeAdmin = CreateObject("MFilesAPI.ObjTypeAdmin")


Dim publishedReportObjectType
Set publishedReportObjectType = CreateObject("MFilesAPI.ObjType")
publishedReportObjectType.ID = 129
publishedReportObjectType.AllowAdding = true

publishedReportObjectTypeAdmin.ObjectType = publishedReportObjectType
publishedReportObjectTypeAdmin.ConnectionString = "M-Files Extension={5417ed7c-d1a0-43bf-bbae-e84b398e6059};type=publishedreport"

'currently the values are hardcoded here just to test if it is working
publishedReportObjectTypeAdmin.InsertIntoStatement="INSERT INTO  ( DocumentName, DocumentDate, DocumentCreator ) VALUES( 'testDoc', '12-04-2020', 'workflow' )"

Vault.ObjectTypeOperations.AddObjectTypeAdmin(publishedReportObjectTypeAdmin)


I get this error :
Incompatible isolation levels: "65536 -> 1048576".

How can I achieve the creation of object type on state transition ?


  • Why are you trying to create an object type on a workflow precondition? That sounds wrong. Vault structure is typically static, defined as part of the initial vault configuration. Creating a new object type on demand due to vault interaction sounds like it could cause all sorts of issues in the long term.

    Are you sure that you don't want to create an object, rather than an object type? Can you give some information on what you're trying to achieve?

    Regards,

    Craig.
  • Hi Craig,

    Thanks for the response.

    What I want to achieve is :

    There's a SYSTEM A which is connected to M-files through ODBC over REST API.
    We have an object Type called : 'Published Reports for SYSTEM A' which basically contains the following properties :

    • Document Name

    • Published Date

    • Published By



    I am able to create/read/update the object types manually over the rest API.


    Now, there's a SYSTEM B which is also connected to M-files through ODBC over REST API.
    We have an object Type called : 'Published Reports for SYSTEM B' which basically contains the following properties :

    • Source Department

    • Target Department

    • Document Name

    • Published Date

    • Published By

    • Signed By



    Manually I am able to create/update/get object types of this over the REST API

    The Usecase :
    In my workflow when the document is published, I want SYSTEM A and SYSTEM B to be notified through object type creation. So I try to create the object types in the PreConditions.

    If that's not the right place to create the object types, can you please suggest me how can I do so programatically ?

    Regards,
    Shoeb
  • I am unsure why you want to create an "object type", though. Surely these are simply objects of type "Published Reports for SYSTEM B", rather than new object types?

    You say this:
    Manually I am able to create/update/get object types of this over the REST API

    You are certainly not able to create object types over the REST API. It does not support this. You can create objects, which is what I think you want to do.

    I would not try and modify the vault structure during any operation like this (it seems that the vault instance you have does not have the ability to anyway).

    Regards,

    Craig.
  • Hi Craig,

    The object types I create manually on m-files basically fires an insert query over ODBC, which actually makes a POST Api call. The POST API call results on creation of object on the other system.

    My concern is :

    How do I pass data to other systems (from m-files), so that they can have the objects created on their end

    Is there some way to achieve this ?
  • Hi Shoeb,

    There are a few ways to do this.


    • If both systems are M-Files then you probably want to look at replication.

    • If not then one option would be to set up the objects in system A as an external object; those can automatically execute a SQL insert statement when objects are created.

    • An event handler or state action could execute your SQL statement.



    It's possibly best to work with your M-Files reseller or account manager to scope out the various options and to understand the pros and cons prior to implementing any code.

    Regards,

    Craig.
  • If not then one option would be to set up the objects in system A as an external object; those can automatically execute a SQL insert statement when objects are created.


    is there any example which does it. How can I create object type ?
  • is there any example which does it.

    www.m-files.com/.../Connection_to_external_database.html

    Please note though that these create objects, not object types. If you truly do want to create object types then you will need a different approach, but from everything you've said I believe that you wish to create objects. You need to make sure that you're using the correct term.

    I would highly recommend that you engage with your M-Files reseller to get some guidance on how to do this, as the approach needed will depend significantly on the nuances of what you want to achieve.

    Regards,

    Craig.