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!
  • Try Metadata card configuration. You might be able to configure a rule using indirect reference via current user - employee - office.
    If you do not force the value, then user will be able to change it.
  • Thanks!
    But I'm not sure how to do a indirect reference using 2 distinct objects in the Placeholder editor.
    I guess you means it should be done under the Behavior > Properties > Set value ?
  • That was my idea. I had not tested at the time. Have just done a brief and very limited test. It does not seem to be possible to use indirect references from CurrentUser(), sorry.
  • Metadata card configuration does not currently support indirect references, however you can use a custom placeholder to fill an Employee property by the current user if your Employee objects include the user account information. Of course this doesn't help you fill the Office property so may not be useful in this case.

    See attached image on how to set up the custom placeholder, the relevant information is in chapter 4.11 of the metadata card configuration guide.
  • Joonas - I thought it did support indirect references as I use it to auto-populate the users' department when creating a document (unless what I'm using is not classed as an indirect reference).

    I have my Department as a property on my Employee object. I then use:

     to enter the Department automatically.
  • Could be that the Employee object is the exception, I have never tried to get anything else other than the Employee object itself this way. If that's true then Stephane should be able to get the Office information, too. Thanks for pointing out!
  • No problem. For the benefit of Stephane, just to confirm, on my 'Persons' object (this could be called Employee or whatever) I have 'Department' as a metadata property so when we create a new user (done using the User Synchronisation configuration accelerator), we then have to add the Employee's Department to their Person Object.

    The screenshot I posted then adds the department to a new document object automatically, which helps users to group documents in Views etc.

    Screenshot below shows how I have the property setup to pull through the department:



    Hope this helps

  • Metadata card configuration does not currently support indirect references

    Any news here (apart from what has been pointed out in the thread, that an indirect reference including CurrentUser is possible after "baking" a corresponding Custom Placeholder)?
    If I try an indirect reference in the metadata card configuration it doesn't work - see attached screenshot (this is the case although the concatenation fits the target data type of the property. I know this for sure because if I use another placeholder with incompatible data type, the error message is different).

    Thx 4 any help! :)

    EDIT: I tried this again with other properties, and it worked. I don't know what I did wrong in the past (maybe I did not use the ID of the respective properties, but their aliases, which still does not seem to work), but it looks like at least with certain props indirect referencing works (see reply #10, for instance)
    EDIT 2: Seems like indirection only works if the first level of the chain is a custom placeholder. If I use a normal/ default property I get the error msg "Property XYZ cannot be used as an indirection level". Correct me if I'm wrong, maybe there are other exceptions!
    I guess the reason for this is that the system lacks the information where to start the fetching. If it only knew that the first level is intended to be a property that is also on the metadata card of the object that is to be created! but it seems that it doesnt get this. With a custom placeholder however it is clear for the system what the starting point is. I guess it is even possible to add one or two more indirection levels if the first one is a custom placeholder.
    EDIT 3: can't be about the starting point, since populating a property with the value of another property that is also on the same metadata card works
  • I am having a similar problem.

    I have a person object (created by the compliance Kit) and a value list of email addresses and a class with email address property.

    when a document is added using this class, i want the email address property to default to the current user's email address from the mfiles account (im guessing from the person object).

    how can i do this?



  • I am having a similar problem.

    I have a person object (created by the compliance Kit) and a value list of email addresses and a class with email address property.

    when a document is added using this class, i want the email address property to default to the current user's email address from the mfiles account (im guessing from the person object).

    how can i do this?

    Hi mturner,

    I think I might have a solution for you :)
    You can simply combine what has been suggested in reply #4 by Joonas and replies #5 & 7 by addyman. Here's a quick how-to, feel free to ask if anything remains unclear:
    1. set up a rule with a custom placeholder exactly like the one suggested in reply #4. what the custom placeholder does is that it checks for employee objects that have the current M-Files user as a value in their M-Files user property. Then the match is used as the output/ value of the custom placeholder. In other words, if you use the custom placeholder to calculate a dynamic property, the value will be an employee (namely the one that corresponds to the current M-Files user). But we don't want just the employee, but his/her email address. This is where step 2 kicks in:
    2. create an indirect reference as a dynamic value for the property you want (as shown in reply #7). The only difference should be that you do not use the Custom Placeholder "CurrentUserAccount" but "CurrentUserEmployeeObject". Make sure everything looks like in the screenshots attached - for me it did not work with the alias of the property, only with the ID, so go for References and then select the ID of the property rather than the alias!!

    You should now be good to go and the email of the employee that belongs to the current user should be fetched automatically when creating a new object.
    41378.zip