Search code examples
alfrescoalfresco-sharealfresco-webscripts

How to add company name field in admin console (new user) alfresco community?


I'm using Alfresco Community 5.0.d and it does not show the fields for company info.

If I search for user then it shows all details but don't let me add company info while creating a user.

So far I came across user.js file at /Applications/alfresco-5.0.d/tomcat/webapps/share/components/console but I'm not able to add the field for new user.

    form.addValidation(parent.id + "-create-companyname", Alfresco.forms.validation.mandatory, null, "keyup");  // ADDED this but not showing in form.

    form.addValidation(parent.id + "-create-firstname", Alfresco.forms.validation.mandatory, null, "keyup");
    form.addValidation(parent.id + "-create-email", Alfresco.forms.validation.mandatory, null, "keyup");
    form.addValidation(parent.id + "-create-email", Alfresco.forms.validation.email, null, "change", parent._msg("Alfresco.forms.validation.email.message"));
    form.addValidation(parent.id + "-create-username", Alfresco.forms.validation.mandatory, null, "keyup");
    form.addValidation(parent.id + "-create-username", Alfresco.forms.validation.nodeName, null, "keyup", parent._msg("Alfresco.forms.validation.nodeName.message"));

Also I have added the key-value in personObj created in users.js as below.

var personObj =
         {
            userName: username,
            password: password,
            firstName: fnGetter("-create-firstname"),
            lastName: fnGetter("-create-lastname"),
            email: fnGetter("-create-email"),
            organization: fnGetter("-create-companyname"),
            disableAccount: Dom.get(me.id + "-create-disableaccount").checked,
            quota: quota,
            groups: groups
         };

PersonObj is:

personObj
disableAccount : false
email : "test@test.com"
firstName : "test"
groups : Array[0]
lastName : "test"
organisation : "test"   //added this key-value
password : "admin"
quota : -1
userName : "test_test"

But company name is not coming. Moreover, I have tried adding multiple user using .csv file link and it does not show the company name (column name is Company as given in guide lines) but do show like mobile number, fax, etc.

Is this is a bug with Alfresco community 5.0.d?

Screenshot of new user form for reference.

new user form

I need to add company name field in above form of new user so it could be pre-populated for those new user's.

How could I add the company name field so it gets added to new user's profile?

Thanks


Solution

  • To add a field which is already a property of user model.

    In case of adding company field, follow below steps:

    1. In users.get.properties file - Add below line.

    label.companyname=Company

    1. In users.js file - Added fields company property for not null check and getting it's value followed with clearing the value after a valid entry.

    form.addValidation(parent.id + "-create-companyname",Alfresco.forms.validation.mandatory, null, "keyup"); // Add validation organisation: fnGetter("-create-companyname"), // Get company value fnClearEl("-create-companyname"); // Clear company field

    1. In users.get.html.ftl file - Added div for company <div class="field-row"> <span class="crud-label">${msg("label.companyname")}:&nbsp;*</span> </div> <div class="field-row"> <input class="crud-input" id="${el}-create-companyname" type="text" maxlength="100" /> </div>