Add `is Me` filter option for User type

For User types, I hope to add the is Me filter option.
This is similar to Assigness’s contains Me.
Could you please review if this feature can be added?
With the is Me filter option, various personalizations are possible.

The following is the case where I want to use is Me of User type.

I installed Fibery’s default template HR > Vacations.
When an employee registers for vacation, they are automatically registered in the Person field.
However, the Person field cannot use the contains Me filter option.
To provide a personalized board, they must manually register themselves in the Assigness field. This is quite inconvenient.
It would be nice if there was a function to automatically set default values, but I would like to add the is Me filter option to the User type.

3 Likes

Is it right that you are asking for two separate things:

  • the ability to set a default value (=me) for a User field
  • the ability to personalise a view so that only entities that meet the criteria “User=me” are shown

Is that correct?
If so, then I think the first is possible (with a bit of API/button work), but I think the second is only possible when using the Assignee field, but not when using another user relation field.

Here’s a quick code tip for setting the default value of a field that is a relation to the user type:

const fibery = context.getService('fibery');

await fibery.executeSingleCommand({
    "command": "fibery.schema/batch",
    "args": {
        "commands": [
            {
                "command": "schema.field/set-meta",
                "args": {
                    "holder-type": "App name/Type name",
                    "name": "App name/Field name",
                    "key": "fibery/default-value",
                    "value": { 'fibery/id': '$my-id' }
                }
            },         
             
        ]
    }
})

If you add that code to an action button, after you’ve pressed the button, the default value for any newly created entities will be set to be the user who creates the entity.
You can then delete the button :slight_smile:

(you’ll need to change the App name, Type name and Field name to what ever is needed for your case)

That’s right. I want two different functions.

  • the ability to personalize a view so that only entities that meet the criteria “User=me” are shown.
    This is the feature I strongly want.

  • the ability to set a default value (=me) for a User field.
    This is the desired function as an alternative because the first function is not available.

However, when using a button, the user must click without forgetting to click the button. This is still a little uncomfortable.

Thanks for sharing me a good way though!

No, you have misunderstood my post. You only need to create the button, click it once, and then you can the delete button again.
The admin can do this, and from then on, the default value will always be set to whichever user creates an entity.
Try it!

1 Like

Oh! I now understand.
Instead of using the HTTP API, it was conveniently set with a button!
but, I faced the last challenge.
Default values are not specified in assignments/assignees.
For other user fields, "value": {'fibery/id':'$my-id' } is well specified, but assignees are not.

I’ve tried:

const fibery = context.getService('fibery');

await fibery.executeSingleCommand({
    "command": "fibery.schema/batch",
    "args": {
        "commands": [
            {
                "command": "schema.field/set-meta",
                "args": {
                    "holder-type": "vacations/dayon",
                    "name": "assignments/assignees",
                    "key": "fibery/default-value",
                    "value": [{ "fibery/id": "$my-id" }]
                }
            },

        ]
    }
})

Both { "fibery/id": "$my-id" } and [{ "fibery/id": "$my-id" }] get an executeSingleCommand: Invalid schema error.

1 Like

I think the problem is because the code I had written assumes that the user field is set up to link to only one user. For the assignees field, it is actually a collection field, and so I think it needs to be done another way.
I’m not sure the right way to set the default value for a collection, but perhaps @Sergey_Truhtanov or @antoniokov might help out with some simple code to achieve it.