I have a simple text-type custom field I would like to access from inside a slash command.
The field is defined in Rocket.Chat server’s settings:
{
"Extension": {
"type": "text",
"required": false,
"public": true,
"private": false,
"sendToIntegrations": true
}
}
Custom fields’ values should be accessible (I think) via the IUser.customFields?
optional dictionary, but it seems it is not filled with anything.
public async executor(context: SlashCommandContext, read: IRead, modify: IModify, http: IHttp): Promise<void> {
console.log(context.getSender());
console.log(context.getSender().customFields?.['Extension']);
}
produces
rocketchat_1 | {
rocketchat_1 | id: '3Gg7KDwQiGeY9Yp2w',
rocketchat_1 | username: 'davide',
rocketchat_1 | emails: [ { address: 'admin@example.com', verified: false } ],
rocketchat_1 | type: 'user',
rocketchat_1 | isEnabled: true,
rocketchat_1 | name: 'Davide',
rocketchat_1 | roles: [ 'admin' ],
rocketchat_1 | status: 'online',
rocketchat_1 | statusConnection: 'online',
rocketchat_1 | utcOffset: 1,
rocketchat_1 | createdAt: 2020-12-07T11:05:51.516Z,
rocketchat_1 | updatedAt: 2020-12-15T10:10:26.918Z,
rocketchat_1 | lastLoginAt: 2020-12-15T09:51:42.335Z,
rocketchat_1 | appId: undefined
rocketchat_1 | }
rocketchat_1 | undefined
where no attribute customFields
is present.
Is this the right way to access custom fields?
I am using the rocketchat/rocket.chat:latest Docker image to deploy the slash command.