Update property in VaultExtensionMethod

Hi,

i have a problem with updating property in VAF extension method.
Method was called from UIX, call is not a problem, but if i use this code, nothing happens. Property 1021 still has same value Disappointed

      [VaultExtensionMethod("VaultExtensionMethod_VAF", RequiredVaultAccess = MFVaultAccess.MFVaultAccessEditAllDocs)]
        private string TestVaultExtensionMethod(EventHandlerEnvironment env)
        {           
            var PV = new PropertyValue();
            PV.PropertyDef = 1021;
            PV.TypedValue.SetValue(MFDataType.MFDatatypeText, "Change test 123");
            var oCheckedOutObj = env.Vault.ObjectOperations.CheckOut(env.ObjVer.ObjID);
            env.Vault.ObjectPropertyOperations.SetProperty(oCheckedOutObj.ObjVer, PV);
            env.Vault.ObjectOperations.CheckIn(oCheckedOutObj.ObjVer);
            return "out of VAF";    

Any help appreciated.

Thanks

Marwin

  • With Attach to VAF process and Debuging i have found this:

    ObjVer is null, why? env should be filled, right?

    Found another one error:
    Cant parse input parametrer what i send from main.js

    InnerException : {"Unexpected character encountered while parsing value: A. Path '', line 0, position 0."} : System.Exception {Newtonsoft.Json.JsonReaderException}
    Message    "Failed to parse the input string.\r\n\r\nABC123456\r\n\r\n    "

        shellFrame.ShellUI.Vault.Async.ExtensionMethodOperations.ExecuteVaultExtensionMethod(
            VAFVaultExtensionName, // The name of the extension method to execute.
            "ABC123456",
            function (response) {
                // The output (string) will be in response; show it.
                shellFrame.ShowMessage(response);
    

  • "env.ObjVer" and "env.ObjVerEx" refer to the object that caused the event or workflow state action to fire.

    In the case of a vault extension method there is no such context. You will need to read the value of "env.Input" and load the object you need. 

  • Ah so, thanks Craig.
    And what format is input? I tryed JSON in the input and still wrote me parse errors :( Even regullar
    {"Something" : "anything"}

  • The input itself is simply a string; what you pass in will be available in "env.Input".

    So, let's take your example.  Let's say that I have this in my UIX application:

     shellFrame.ShellUI.Vault.Async.ExtensionMethodOperations.ExecuteVaultExtensionMethod(
            VAFVaultExtensionName, // The name of the extension method to execute.
            '{ "Name": "Craig" }',
            function (response) {
                // The output (string) will be in response; show it.
                shellFrame.ShowMessage(response);
            });

    This passes a simple JSON string to the extension method.  I could then read it and action it as below.

    [VaultExtensionMethod("VaultExtensionMethod_VAF", RequiredVaultAccess = MFVaultAccess.MFVaultAccessEditAllDocs)]
    private string TestVaultExtensionMethod(EventHandlerEnvironment env)
    {           
        var input = env.Input;
        var parsed = (dynamic)JsonConvert.Deserialize(input);
        return $"Hello {parsed.Name}!";
    }

    Note: you should be using "env.Input", not "env.InputParams" as you are in your screenshot.

    Regards,

    Craig.

  • Thanks Craig u send my in right direction Slight smile I tryed it, now i send ID,ObjVer and Version to VAF,

    but still got a problem Disappointed

    When i SetIDS to right values and try to SetProperty, exeption pop up:

    oObjVer.SetIDs ( pInput.Type,  pInput.ID, pInput.Version);
    env.Vault.ObjectPropertyOperations.SetProperty(oObjVer, PV);

    Exeption:
    The object is locked. Try again later.

    The object is locked. Try again later. Object: 1
    
    CoVaultObjectPropertyOperations.cpp, 586, The object is locked. Try again later. Object: 1 (0x80040041)
    ServerVaultObjectPropertyOperationsHelper.cpp, 49, The object is locked. Try again later. Object: 1 (0x80040041)
    CoRPCOverCOM.cpp, 6451, The object is locked. Try again later. Object: 1 (0x80040041)
    RPCDocumentOperations.cpp, 7560, The object is locked. Try again later. Object: 1 (0x80040041)
    MCallInLoop.h, 605, The object is locked. Try again later. Object: 1 (0x80040041)
    RPCDocumentOperationsHelper.cpp, 4412, The object is locked. Try again later. Object: 1 (0x80040041)
    RPCDocumentOperationsHelper.cpp, 18987, The object is locked. Try again later. Object: 1 (0x80040041)
    RPCDocumentOperationsHelper.cpp, 18384, The object is locked. Try again later. Object: 1 (0x80040041)
    RPCDocumentOperationsHelperPrivate.cpp, 17621, The object is locked. Try again later. Object: 1 (0x80040041)
    RPCDocumentOperationsHelperPrivate.h, 2329, The object is locked. Try again later. Object: 1 (0x80040041)
    RPCDocumentOperationsHelperPrivate.cpp, 17828, The object is locked. Try again later. Object: 1 (0x80040041)
    (M-Files 21.5.10227.3)
    
    <bin>
    AgAAAAsA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ByAGEAdABp
    AG8AbgBzAEgAZQBsAHAAZQByAC4AYwBwAHAAAABBAASAARYAAAAgAE8AYgBqAGUAYwB0ADoAIAAx
    AAAAAQAAAB+qqRSdAtNWkOOQaq/We8ABCAAAADYAMAA1AAAAHAAAAE0AQwBhAGwAbABJAG4ATABv
    AG8AcAAuAGgAAABBAASAARYAAAAgAE8AYgBqAGUAYwB0ADoAIAAxAAAAAQAAAB+qqRSdAtNWkOOQ
    aq/We8ABCgAAADcANQA2ADAAAAA0AAAAUgBQAEMARABvAGMAdQBtAGUAbgB0AE8AcABlAHIAYQB0
    AGkAbwBuAHMALgBjAHAAcAAAAEEABIABFgAAACAATwBiAGoAZQBjAHQAOgAgADEAAAABAAAAH6qp
    FJ0C01aQ45Bqr9Z7wAEKAAAANgA0ADUAMQAAACIAAABDAG8AUgBQAEMATwB2AGUAcgBDAE8ATQAu
    AGMAcABwAAAAQQAEgAEWAAAAIABPAGIAagBlAGMAdAA6ACAAMQAAAAEAAAAfqqkUnQLTVpDjkGqv
    1nvAAQYAAAA0ADkAAABcAAAAUwBlAHIAdgBlAHIAVgBhAHUAbAB0AE8AYgBqAGUAYwB0AFAAcgBv
    AHAAZQByAHQAeQBPAHAAZQByAGEAdABpAG8AbgBzAEgAZQBsAHAAZQByAC4AYwBwAHAAAABBAASA
    ARYAAAAgAE8AYgBqAGUAYwB0ADoAIAAxAAAAAQAAAB+qqRSdAtNWkOOQaq/We8ABCAAAADUAOAA2
    AAAASAAAAEMAbwBWAGEAdQBsAHQATwBiAGoAZQBjAHQAUAByAG8AcABlAHIAdAB5AE8AcABlAHIA
    YQB0AGkAbwBuAHMALgBjAHAAcAAAAEEABIABFgAAACAATwBiAGoAZQBjAHQAOgAgADEAAAAAAAAA
    AQ==
    </bin>
    
    (0053)

  • Interesting.  Someone else had a similar issue recently (they too were selecting an object in a UIX, then calling an extension method to try and work on the object), but I couldn't replicate it.

    Have you configured your AV in line with M-Files' recommendations?

    Regards,

    Craig.

  • Got AV configured by it.
    But looks like, complete disabling AV did the trick, i do some test more.
    Thanks to send me to right direction Slight smile