Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't save Accounts_CustomFields in ./packages/rocketchat-lib/server/startup/settings.js #9763

Closed
renxuqiang opened this issue Feb 18, 2018 · 4 comments

Comments

@renxuqiang
Copy link

renxuqiang commented Feb 18, 2018

Description:

I'm new to Rocket.Chat and I can not sure whether it is a bug, I'm debugging for this problem 2 days, can anyone please help?
I want to add some CustomFields in user's account, so I modify the setting in ./packages/rocketchat-lib/server/startup/settings.js

this.add('Accounts_CustomFields', '[HERE IS MY CUSTOM VALUE]', {
type: 'code',
'public': true,
i18nLabel: 'Custom_Fields'
});

and then I start the server in debug mode, I try to reg a new account throw REST API, in the file
./server/methods/registerUser.js there is a method call:
RocketChat.saveCustomFields(userId, formData); -->
if (s.trim(RocketChat.settings.get('Accounts_CustomFields')) !== '')
and the if test always return false because RocketChat.settings.get('Accounts_CustomFields') always return '' (empty string)

it seems the code in server/startup/settings.js just did not work, and i don't know why, can any one help me to figure out the problem? thanks

Server Setup Information:

  • Version of Rocket.Chat Server: 0.61.0-develop
  • Operating System: macOS High Sierra 10.13.3
  • Deployment Method(snap/docker/tar/etc): tar
  • Number of Running Instances: 1
  • DB Replicaset Oplog:
  • Node Version:8.9.3 - x64

Steps to Reproduce:

  1. modify ./packages/rocketchat-lib/server/startup/settings.js,
    this.add('Accounts_CustomFields', '[HERE IS MY CUSTOM VALUE]', {...}
    you can just type a 'test' string
  2. modify ./packages/rocketchat-lib/server/functions/saveCustomFields.js, add
    let value = RocketChat.settings.get('Accounts_CustomFields');
    console.log(value);
    debugger;
    in the saveCustomFields function, before the if test
  3. reg a user from web or REST API

Expected behavior:

in the log (or breakpoint) , the value of RocketChat.settings.get('Accounts_CustomFields');
show be test, not ''(empty string)

Actual behavior:

in the log (or breakpoint) , the value of RocketChat.settings.get('Accounts_CustomFields');
is alway ''(empty string), and the if test will fail, and can't save the CustomFields

@kaiiiiiiiii
Copy link
Contributor

kaiiiiiiiii commented Feb 18, 2018

You can actually set custom fields through the admin interface, no need to touch the code ;)

Example:
Administration -> Accounts -> Custom Fields to Show in User Info

[{"Company":"#{Company}"}, {"Position":"#{Position}"}]

screen shot 2018-02-18 at 19 36 29

Administration -> Accounts -> Registration -> Custom Fields

{ "Company": { "type": "text", "required": true, "minLength": 2, "maxLength": 100 }, "Position": { "type": "text", "required": true, "minLength": 5, "maxLength": 100 } }

screen shot 2018-02-18 at 19 36 17

Currently there's a bug in the Rocket.Chat User Info UI, which prevents custom fields to be shown. I already opened a PR (#9646) for that, so it should be fix with the next release.

@renxuqiang
Copy link
Author

thanks for your help~
I tried set the custom fields from "Administration -> Accounts -> Custom Fields" page , and it worked!

thank you very much 👍
I'll close the issue

@apo-j
Copy link

apo-j commented Mar 12, 2018

Can other user who is not admin see the custom fields ? I also tried to call the rest api /api/v1/users.info?userId=xxx, il returns customFields only when called by admin user

@asadi110
Copy link

asadi110 commented Aug 8, 2018

@kaiiiiiiiii Hi,
1-how I can edit Users custom fields from administration.
2- also in create user from administration not showing custom fields.
3- how add custom field from administration that read-only for users.
4- how add custom field from administration that private for user and other users can't see that.
tanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants