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

Put a default value list value based on the current users

Hi!
I've search all over the community but did not find the answer.

Here's the context :

I have an Object named Employee, for who I know his Office and his name.
Each M-files users is automaticaly created from this list.

When a user creates a new object named Assignement using a specific class, this class has also a property named Office.
By default, I would like to put the Employee's office as the default value. But the value could be modified if it's not the correct one for the user.

Automatic value of the property definition does not allow the user to change the value while he is creating the object.

So I'm not sure how to do this?

Thanks for your help!
  • Hi mturner,

    I think I might have a solution for you :)



    Thank you! This got me closer but I have a roadblock. I created dynamic placeholder. Then when setting the "member user" value list property to the "%CurrentUserPersonObject.PROPERTY_{M-Files.AdvancedNotifications.EmailAddress}%" I get error because I am trying to set a text value to a value list item. The "member user" property is a value list item.

    I created a new email property on the class as a text box and that worked. But is not what I need.

    The member user object is a subtype of the Member object.
    The test class has a "Member User" value list property and a "Member" value list property.

    If I upload a document and manually choose the "member User", the "member" property is automatically entered by mfiles. The "member" list has automatic permissions applied so when the mfiles user uploads a file, any user of that same member gets permission to view the document.
    When i click the "member user" value list on the class, I see a list of email addresses.

    This is my goal. I want to automate the choosing of the "member user" email address to the current user, which applies the member automatic permission to the document.








    41382.zip


  • "%CurrentUserPersonObject.PROPERTY_{M-Files.AdvancedNotifications.EmailAddress}%" I get error because I am trying to set a text value to a value list item.


    I think the second property here is the problem (this part: {M-Files.AdvancedNotifications.EmailAddress}). I would not use the advanced notif email property but a normal email property that you also use on your person, employee, or whatever object metadata card. Just make sure that both the property you want to populate and your concatenated placeholder (CustomPlaceholder.NormalEmailProperty) select from the same value list (see attachment).

    Regards, Pascal
  • I understand.

    My goal is to set the member value list to the same member the current user works for. Then the automatic permission of the selected member will restrict the permission of the document.

    Is there a different way to accomplish this goal?


    The trick is to link the mfiles current user to my Member User object so I can tell which company the active user works for and set permissions accordingly.

    I added User Account to the member user object and test class. But somehow I have to update the value of the User Account in the Member User object to the User Account in the Person object. How can this be done?




  • Is there a different way to accomplish this goal?

    If I understand you correctly, you don't need the Person object to achieve your goal. You don't even need a concatenated placeholder, either.
    With the configuration shown in your screenshots and what you want to achieve I would proceed in the following way:

    1.) in M-Files Admin, add the property called "M-Files user" to your "Member User" Class
    2.) in M-Files desktop, populate this newly created property for all "Member User" objects manually (don't know if there is any automation procedure for that, I did it manually since we are a very small company). Alternatively - for testing purposes - populate only a few.
    You now have created a connection between two technically entirely different levels - an Object in M-Files and the corresponding M-Files user, simply by adding the M-Files user as a property to your "Member User" Object.
    3.) in M-Files Admin/ Metadata Card Configuration, you now have to create a Custom Placeholder called, for example, CurrentUserMemberUserObject. (go about just as you did before, but your reference should not be the Person object, but the MemberUser object). Configuration should then be:
    Name = CurrentUserMemberUserObject
    Object = Member User
    Property = M-Files User
    Mode = Static Value
    Static Value = (Current User)
    4.) Still in Metadata Card Config, populate the property "Member User" within "Test Class" with a dynamic value. The placeholder to choose is the one created in step 3. No concatenation nor anything else needed. Just the placeholder.

    This should do the job. Now if you create a new object belonging to Test Class, the "Member User" property should default to the current user. If I got you correctly, this in turn will automatically fill your "Member" property, which, in turn, will set the right permissions.
    Feel free to ask if anything remains unclear.
  • Almost there!

    I made changes you suggested and now it does set the "Member User" property on the class. But, the "Member" property does not automatically populate to the member the user works for.

    If I turn off the rule and manually enter the Member User, then the Member property is set correctly.

    It seems that the rule does not trigger the member property to update. :(

    If I can get the rule to work, then I will need to write code to update the m-files user property on the member user object when a new mfiles account is created. I have over 600 users so this cannot be a manual process.

    Thank you for all your help.

    If i can get the member property to update correctly, I will be 90% towards the goal.


    41404.zip

  • Almost there!

    I made changes you suggested and now it does set the "Member User" property on the class. But, the "Member" property does not automatically populate to the member the user works for.

    If I turn off the rule and manually enter the Member User, then the Member property is set correctly.

    It seems that the rule does not trigger the member property to update. :(


    I think we can get you there. I reconstructed your problem and in my case it also broke the automation that was there before. However, we can make advantage of the fact that Member User is a subtype of Member in your scenario. So what you could try is to add the "Member" property to your rule and give it a dynamic value. This time it has to be a concatenated one: The first element being the Custom Placeholder you created, the second one being the "owner" property. I tested this and it worked.


    If I can get the rule to work, then I will need to write code to update the m-files user property on the member user object when a new mfiles account is created. I have over 600 users so this cannot be a manual process.

    Maybe you can avoid this. I only suggested the "M-Files User" property because I knew for sure that it works because I used it myself. However, you could use any other property to achieve your goal that makes reference to the same pool of M-Files users that this prop makes. If you already have one of these props on your Member User class that is populated, you could also use that one (for instance, I'm not sure about your "User Account" property - what does it select from? Wouldn't that be a suitable candidate?)
  • bpascal, you are a genius!!

    Now the member property is set correctly after the rule updates the member user property.


    The User Account property is part of the person object and was created by the compliance kit. it is "choose from list users". So, i think i have to use event code to bind the member user to the mfiles user on account creation.

    Thanks so much for all your help! I have been struggling with how to do this for months.



  • bpascal, you are a genius!!

    Thanks so much for all your help! I have been struggling with how to do this for months.

    You're welcome :) glad I could help
  • I have one other issue I hope you can help with.

    Up to now, I have been testing this class using internal user who has permission-change access. I tested with an external user and I get the attached warning message:

    "With the selected permissions, you may lose permission-change access to this object."

    I do not want external users to be able to change permissions on documents they upload. The automatic permissions are correct (delete, edit, read, but no change permission).

    How do I suppress this warning message?





  • I have one other issue I hope you can help with.

    Up to now, I have been testing this class using internal user who has permission-change access. I tested with an external user and I get the attached warning message:

    "With the selected permissions, you may lose permission-change access to this object."

    I do not want external users to be able to change permissions on documents they upload. The automatic permissions are correct (delete, edit, read, but no change permission).

    How do I suppress this warning message?

    Sorry, can't help with that :( In the past I sometimes also wondered how to suppress certain M-Files messages, but did not find any related settings...maybe VBA code is needed, I have no idea. You might want to open a new thread for that issue