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

I need to get the users ID using the username information through VBScript

I'm creating a user via vbscript below:

"Option Explicit

Dim oServerApp: set oServerApp = CreateObject("MFilesAPI.MFilesServerApplication")
oServerApp.Connect 2, "user", "password", "SERVERNAME", "ncacn_ip_tcp", "localhost", "2266", "DEMO VAULT NAME", false
Dim oVault: Set oVault = oServerApp.LogInToVaultAdministrative(VaultGUID)

Dim oEmail: oEmail = PropertyValues.SearchForProperty(1089).TypedValue.DisplayValue

Dim oLoginAccount: Set oLoginAccount = CreateObject("MFilesAPI.LoginAccount")
Dim oUserAccount: Set oUserAccount = CreateObject("MFilesAPI.UserAccount")


oLoginAccount.AccountType = MFLoginAccountTypeMFiles
oLoginAccount.LicenseType = MFLicenseTypeConcurrentUserLicense
oLoginAccount.EmailAddress = oEmail
oLoginAccount.Enabled = True
oLoginAccount.UserName = "user-" & oEmail


oServerApp.LoginAccountOperations.AddLoginAccount oLoginAccount, "Testepassword"

oUserAccount.Enabled = true
oUserAccount.InternalUser = true
oUserAccount.LoginName = "omega-" & oEmail


'oVault.UserOperations.ModifyUserAccount oUserAccount
oVault.UserOperations.AddUserAccount oUserAccount

oServerApp.Disconnect()"

Now you need to set this user created on a property of type list that points to M-files users.

Dim oPropVal : Set oPropVal = CreateObject("MFilesAPI.PropertyValue")
oPropVal.PropertyDef = 1150
oPropVal.TypedValue.SetValue MFDatatypeLookup, ??????
Vault.ObjectPropertyOperations.SetProperty ObjVer, oPropVal

I know the "MFDatatypeLookup" requires the ID.

How to get the userid I created?

Can anyone provide a code example?

Parents Reply
  • well in what vault you wanted to create the user? in oVault or in Vault?

    Resp: In oVault.

    Where do you set the id of user?

    Resp: With this part of the script:

    Dim oPropVal : Set oPropVal = CreateObject("MFilesAPI.PropertyValue")
    oPropVal.PropertyDef = 1150
    oPropVal.TypedValue.SetValue MFDatatypeLookup, userid.ID
    oVault.ObjectPropertyOperations.SetProperty ObjVer, oPropVal

    Include your last suggestion (oVault.ObjectPropertyOperations.SetProperty ObjVer, oPropVal) and different error occurred:

    (0057) (0x80040001)
    New Client, StateAction, 31, Object is locked. Try later. Object: 111-34

Children
  • So you are trying to set on oVault, an ObjVer that it is in Vault.

    You need to search for the ObjVer from the oVault, than update the oVault.ObjectPropertyOperations.SetProperty ObjVer, oPropVal with the proper ObjVer.

  • Not really, the property is in the same Vault (oVault), correct the line by putting "oVault.ObjectPropertyOperations.SetProperty ObjVer, oPropVal" and this error occurred:

    RPCDocumentOperationsHelperPrivate.h, 2348, O objeto esta bloqueado. Tente mais tarde. Object: 111-34 (0x80040041)
    RPCDocumentOperationsHelperPrivate.cpp, 17940, O objeto esta bloqueado. Tente mais tarde. Object: 111-34 (0x80040041)
    (M-Files 21.6.10322.8)

    (0057) (0x80040001)
    (M-Files 21.6.10322.8)

  • oVault.ObjectPropertyOperations.SetProperty ObjVer, oPropVal

    The ObjVer in this statements is the current ObjVer of the document in your Vault.

    You need to find the ObjVer in oVault.

  • Radu Moca, thank you very much for your help and patience, but I couldn't write the script to find ObjVer in oVault.