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.

How to add a visible to current user search condition when searching for value list items?

Hi!

Using VAF, is there a way to add a visible to current user search condition when searching for value list items? I know it's possible to add that condition when executing a normal search and I have used it successfully before like this:

var sc = new SearchCondition();

sc.Expression.SetPermissionExpression(MFPermissionsExpressionType.MFVisibleTo);
sc.ConditionType = MFConditionType.MFConditionTypeEqual;
sc.TypedValue.SetValue(MFDataType.MFDatatypeLookup, env.CurrentUserID);

However I can't find a way to do a similar thing when searching for value list items using this:

env.Vault.ValueListItemOperations.SearchForValueListItems

Is it even possible and if not, are there any workarounds?

Kind regards

Jussi

Parents
  • We are sending some initial data from VAF to UIX and that data is mainly gathered by normal searches, but there are some values that only exist as value lists. However the client has apparently made some restrictions and all value list items are not visible to all users. So in order to only show the allowed values I'd need to somehow include the user id in the value list search.

    And yeah I know this is not exactly the proper way to even use VAF, as I could fetch that initial data from UIX. I just very much prefer coding in C# with all the nice helpers etc. compared to a "bit" dated JScript.

  • I wouldn't say that this is the wrong way at all.  As you said: writing UIX code is a pain sometimes.

    There is one additional thing I'd highlight: vault extension methods can be told to run "as" the calling user:

    [VaultExtensionMethod("MyVaultExtensionMethod",
        RequiredVaultAccess = MFVaultAccess.MFVaultAccessNone,
        // The vault user identity says that the vault should
        // be connected as the current user, not the server account.
        VaultUserIdentity = EventHandlerVaultUserIdentity.User)]
    private string MyVaultExtensionMethod(EventHandlerEnvironment env)
    {
        throw new System.NotImplementedException();
    }

    I haven't tried this with the exact search you're looking at, but that'd be my first approach.

Reply
  • I wouldn't say that this is the wrong way at all.  As you said: writing UIX code is a pain sometimes.

    There is one additional thing I'd highlight: vault extension methods can be told to run "as" the calling user:

    [VaultExtensionMethod("MyVaultExtensionMethod",
        RequiredVaultAccess = MFVaultAccess.MFVaultAccessNone,
        // The vault user identity says that the vault should
        // be connected as the current user, not the server account.
        VaultUserIdentity = EventHandlerVaultUserIdentity.User)]
    private string MyVaultExtensionMethod(EventHandlerEnvironment env)
    {
        throw new System.NotImplementedException();
    }

    I haven't tried this with the exact search you're looking at, but that'd be my first approach.

Children