Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

Extending User Properties with multifield xtype is not saving

Avatar

Level 2

Hi All,

I am trying to Extend User properties, I have created a client lib, like the below

CQ.Ext.ns("CustomUserProperties"); CustomUserProperties.UserAdmin = { addCustomUserProperties: function(propPanel){ var userForm = propPanel.userForm; userForm.setAutoScroll(true); var locations = { "xtype":"multifield", "fieldLabel": "Locations", "anchor":"100%", "name":"locations" }; userForm.insert(userForm.items.length + 1, locations); userForm.doLayout(); } }; (function(){ if(window.location.pathname == "/useradmin"){ var fields = CQ.security.data.AuthRecord.FIELDS; fields.push({"name": "locations"}); var UA_INTERVAL = setInterval(function(){ var userAdmin = CQ.Ext.getCmp("cq-useradmin"); if(userAdmin && userAdmin.userProperties){ clearInterval(UA_INTERVAL); CustomUserProperties.UserAdmin.addCustomUserProperties(userAdmin.userProperties); } }, 250); } })();

I can able to see multifield and can able to add locations but when I save it its not saving complete array to /home/users, just saving only one row of the locations field value.

How can I setup/configure to save multifield variables?

Is there any alternative way to use multifield xtype ? 

 

 

Thank you,

Krishna

3 Replies

Avatar

Administrator

Hi 

Look at this community article:-

Link:- http://experience-aem.blogspot.ch/2014/01/aem-cq-56-extend-useradmin-add-new-user.html

//AEM - Extend UserAdmin, add new User Properties

Here two solutions are provided, first one is preferred.

Solution - 1


1) Create a cq:ClientLibraryFolder /apps/myclientlib and add property categories cq.security of type String

2) Create /apps/myclientlib/js.txt of type nt:file and add the following

                  UserProperties.js

3) Create /apps/myclientlib/UserProperties.js of type nt:file and add the following code

CQ.Ext.ns("MyClientLib");
 
MyClientLib.UserAdmin = {
    addSecondEmail: function(propPanel){
        var userForm = propPanel.userForm;
        var emailComp = userForm.find('name', 'email');
 
        var secondEmailComp = {
            "xtype":"textfield",
            "fieldLabel": "Second Email",
            "anchor":"100%",
            "name":"secondEmail"
        };
 
        userForm.insert(userForm.items.indexOf(emailComp[0]) + 1, secondEmailComp);
        userForm.doLayout();
    }
};
 
(function(){
    if(window.location.pathname == "/useradmin"){
        var fields = CQ.security.data.AuthRecord.FIELDS;
        fields.push({"name": "secondEmail"});
 
        var UA_INTERVAL = setInterval(function(){
            var userAdmin = CQ.Ext.getCmp("cq-useradmin");
 
            if(userAdmin && userAdmin.userProperties){
                clearInterval(UA_INTERVAL);
                MyClientLib.UserAdmin.addSecondEmail(userAdmin.userProperties);
            }
        }, 250);
    }
})();

Another reference article:- http://experience-aem.blogspot.com/2014/01/aem-cq-56-extend-useradmin-add-new-user.html?showComment=...

I hope this would be helpful to you.

Thanks and Regards

Kautuk Sahni



Kautuk Sahni

Avatar

Level 2

@Kautuk,

Yes I took it from the web, but my question is

How can I setup/configure to save multifield variables?

Is that possible are not?

Regards,

Krishna

Avatar

Level 7

Yes Krishna,

You can save multifield variables. have you tried Kautuk's approach?

Thanks

Tuhin