Announcement

Collapse
No announcement yet.

Created Custom Entity called "Own employed" and like connect for portalUser Creation

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Kharg
    replied
    I am glad I could help you.
    Don't hesitate to ask if you need more help

    Leave a comment:


  • biocronic
    replied
    Yes it does. And it should work like you said before! The 404 Error was because my eyes are so damaged. I cannot see like I should. I ordered new glasses two weeks ago.
    The file was named select-for-portal-users.js with an EXTRA s at the end instead of select-for-portal-user.js .... so THANK you very much.

    Leave a comment:


  • Kharg
    commented on 's reply
    Let me know if it works!

  • biocronic
    commented on 's reply
    Thank you very much. Your help is awesome. I will try it and let you know.

  • biocronic
    commented on 's reply
    Thank you very much! That very helpful.

  • Kharg
    replied
    biocronic tested and working.

    Just a few things, you need a custom filter so it doesn't show Users already created and you need to make it link the correct entity in the portal user page, as it tries to link the contact entity.
    Click image for larger version  Name:	image.png Views:	0 Size:	13.9 KB ID:	89603
    Click image for larger version  Name:	image.png Views:	0 Size:	41.4 KB ID:	89602

    Edit: Version 1.1.0 has filters and links the correct Angestellte, be aware that your entity has to be names "Angestellte" with a capital "A".​ (if you have already built relationships it may conflict so download 1.0.0 and build a version that works for you by checking the differences)

    Both versions have to be installed from the extensions panel.
    Attached Files
    Last edited by Kharg; 03-17-2023, 11:51 PM.

    Leave a comment:


  • Kharg
    replied
    Can you check the browser console to see what's the error?

    It should tell you the path of the missing view.
    Last edited by Kharg; 03-17-2023, 05:57 PM.

    Leave a comment:


  • biocronic
    replied
    Hi. I did like you told me. Now I have Error 404: Not found again.

    Made file with this content: PortalUser.json
    PHP Code:
    {
        
    "views": {
            
    "list""custom:views/angestellte/list"
        
    }
    }
    ​  ​ 
    removed this line: : primaryFilterName: 'notPortalUsers', .... in list view.

    I am looking forward your solution. Thank you very much.

    Leave a comment:


  • Kharg
    replied
    Hi,

    Did you define your custom views in PortalUser.json?

    Create a new file in custom/Espo/Custom/Resources/metadata/clientDefs/ called PortalUser.json
    with the following content
    PHP Code:
    {
        
    "views": {
            
    "list""custom:views/angestellte/list"
        
    }
    }
    ​ 
    Rebuild and check if it works.

    Be aware that you should remove this line: primaryFilterName: 'notPortalUsers', from your custom view as you didn't create a filter for it yet.
    Last edited by Kharg; 03-17-2023, 03:45 PM.

    Leave a comment:


  • biocronic
    replied
    Hello Ladies and Gentlemen!

    Somehow I destroyed my entity, so I created an new one and read the documentation and your advices again and again.
    This is where I ended now. Now I do not have any error messages but did not achieve yet what I wanted to.
    I want to explain it in detail again because I think some things might be unclear.

    First I explain what I want to achieve:
    On the Admin-Page: Portal Users
    URL: .../espocrm/#Admin/portalUsers

    There is an Add Portal User Button.
    Click image for larger version

Name:	grafik.png
Views:	251
Size:	10.2 KB
ID:	89569
    After clicking ... opening....

    Click image for larger version

Name:	grafik.png
Views:	261
Size:	13.1 KB
ID:	89570

    Here we see the Contacts Entity loaded. Instead of this Contact list, I like to load my new Entity "Angestellte".

    Click image for larger version

Name:	grafik.png
Views:	255
Size:	6.8 KB
ID:	89571
    Our Contacts exist als a child of Customers (Kunden), so we do not want display the Contacts when adding the Portal Users. so instead: Angestellte.



    Now I tell you what I have done so far:

    I created a new entity named "angestellte" as person linked to USERS from the admin backend.

    so the Clientdef here was created automaticly: /espocrm/custom/Espo/Custom/Resources/metadata/clientDefs/Angestellte,json

    Kharg ... Then you told me to clone these two first:

    EspoCRM – Open Source CRM Application. Contribute to espocrm/espocrm development by creating an account on GitHub.

    and the same with this one




    Documentation told me to put it here:

    client/custom/src/views/angestellte/list.js
    client/custom/src/views/angestellte/modals/select-for-portal-users.js

    define('custom:views/angestellte/list', 'views/list', function (Dep) {

    return Dep.extend({

    defaultOrderBy: 'createdAt',

    defaultOrder: 'desc',

    setup: function () {
    Dep.prototype.setup.call(this);
    },

    actionCreate: function () {
    var viewName = this.getMetadata().get('clientDefs.Angestellte.mod alViews.select') || 'views/modals/select-records';

    var viewName = 'custom:views/angestellte/modals/select-for-portal-user';

    this.createView('modal', viewName, {
    scope: 'Angestellte',
    primaryFilterName: 'notPortalUsers',
    createButton: false,
    mandatorySelectAttributeList: [
    'salutationName',
    'firstName',
    'lastName',
    'accountName',
    'accountId',
    'emailAddress',
    'emailAddressData',
    'phoneNumber',
    'phoneNumberData'
    ]
    }, function (view) {
    view.render();

    this.listenToOnce(view, 'select', function (model) {
    var attributes = {};

    attributes.contactId = model.id;
    attributes.contactName = model.get('name');

    if (model.get('accountId')) {
    var names = {};
    names[model.get('accountId')] = model.get('accountName');

    attributes.accountsIds = [model.get('accountId')];
    attributes.accountsNames = names;
    }

    attributes.firstName = model.get('firstName');
    attributes.lastName = model.get('lastName');
    attributes.salutationName = model.get('salutationName');

    attributes.emailAddress = model.get('emailAddress');
    attributes.emailAddressData = model.get('emailAddressData');

    attributes.phoneNumber = model.get('phoneNumber');
    attributes.phoneNumberData = model.get('phoneNumberData');

    attributes.userName = attributes.emailAddress;

    attributes.type = 'portal';

    var router = this.getRouter();

    var url = '#' + this.scope + '/create';

    router.dispatch(this.scope, 'create', {
    attributes: attributes
    });
    router.navigate(url, {trigger: false});
    }, this);

    this.listenToOnce(view, 'skip', function (model) {
    var attributes = {
    type: 'portal'
    };

    var router = this.getRouter();
    var url = '#' + this.scope + '/create';
    router.dispatch(this.scope, 'create', {
    attributes: attributes
    });
    router.navigate(url, {trigger: false});
    }, this);
    }, this);
    }

    });
    });​


    // select-for-portal-users.js

    define('custom:views/angestellte/modals/select-for-portal-user', ['views/modals/select-records'], function (Dep) {

    return Dep.extend({

    setup: function () {
    Dep.prototype.setup.call(this);

    this.buttonList.unshift({
    name: 'skip',
    text: this.translate('Proceed w/o Angestellte', 'labels', 'User')
    });
    },

    actionSkip: function () {
    this.trigger('skip');
    this.remove();
    },
    });
    });​

    So I finally did everything I found in the documentation and your adviced.

    But now there is NO RESULT. EVEN NO ERROR.

    So please give me some advice. This should be a easy task for your company so solve within your support. I only want to change the selection of Contact TO Angestellte when adding portal users as admin in the backend.

    I tried my very best to tell you exactly what is going on. But If you have more questions to investigate let me know.

    Thank you for your reading in the first place.
    Attached Files

    Leave a comment:


  • rabii
    commented on 's reply
    No hence you want to create portal users from a different entity other than Contact then it should reflect the clientDefs of your custom entity.

  • biocronic
    replied
    Another question you missed perhaps.....

    var viewName = this.getMetadata().get('clientDefs.Contact.modalVi ews.select') || 'views/modals/select-records';

    var viewName = 'crm:views/contact/modals/select-for-portal-user';​

    the first line is not necessary? RIGHT?

    Leave a comment:


  • biocronic
    replied
    Hi. Just another little question for more clearness:
    I assume that I should replace CRM with CUSTOM in the php define code:
    define('crm:views/ change to define('custom:views/ ?
    Is this right?

    Leave a comment:


  • rabii
    commented on 's reply
    I think you should create these files under custom\Espo\Custom otherwise it won't be upgrade safe.

    define('views/portal-user/list', 'views/list', function (Dep) => This is wrong as it is an existing file in the system it should something like define('views/eigenemitarbeiter-user/list', 'views/list', function (Dep)

    remember you need first to create a relationship between users and your custom entity and then start creating necessary views and implement logic. Also keep in mind that you have to implement you own custom code for Portal Roles and Permissions.

  • biocronic
    replied
    Okay. There have been more questions. You only answered one. This would be better to help me understand how this works.

    I also created this file here: client/modules/crm/src/views/eigenedateien/modals/select-for-portal-user.js

    an the other files ....

    Click image for larger version

Name:	grafik.png
Views:	407
Size:	9.2 KB
ID:	89092



    Your first advice was this just clone etc.

    so the list.js looks now like this

    Code:
    
    define('views/portal-user/list', 'views/list', function (Dep) {
    
        return Dep.extend({
    
            defaultOrderBy: 'createdAt',
    
            defaultOrder: 'desc',
    
            setup: function () {
                Dep.prototype.setup.call(this);
            },
    
            actionCreate: function () {
                var viewName = this.getMetadata().get('clientDefs.Contact.modalViews.select') || 'views/modals/select-records';
    
                var viewName = 'crm:views/contact/modals/select-for-portal-user';
    
                this.createView('modal', viewName, {
                    scope: 'Contact',
                    primaryFilterName: 'notPortalUsers',
                    createButton: false,
                    mandatorySelectAttributeList: [
                        'salutationName',
                        'firstName',
                        'lastName',
                        'accountName',
                        'accountId',
                        'emailAddress',
                        'emailAddressData',
                        'phoneNumber',
                        'phoneNumberData'
                    ]
                }, function (view) {
                    view.render();
    
                    this.listenToOnce(view, 'select', function (model) {
                        var attributes = {};
    
                        attributes.contactId = model.id;
                        attributes.contactName = model.get('name');
    
                        if (model.get('accountId')) {
                            var names = {};
                            names[model.get('accountId')] = model.get('accountName');
    
                            attributes.accountsIds = [model.get('accountId')];
                            attributes.accountsNames = names;
                        }
    
                        attributes.firstName = model.get('firstName');
                        attributes.lastName = model.get('lastName');
                        attributes.salutationName = model.get('salutationName');
    
                        attributes.emailAddress = model.get('emailAddress');
                        attributes.emailAddressData = model.get('emailAddressData');
    
                        attributes.phoneNumber = model.get('phoneNumber');
                        attributes.phoneNumberData = model.get('phoneNumberData');
    
                        attributes.userName = attributes.emailAddress;
    
                        attributes.type = 'portal';
    
                        var router = this.getRouter();
    
                        var url = '#' + this.scope + '/create';
    
                        router.dispatch(this.scope, 'create', {
                            attributes: attributes
                        });
                        router.navigate(url, {trigger: false});
                    }, this);
    
                    this.listenToOnce(view, 'skip', function (model) {
                        var attributes = {
                            type: 'portal'
                        };
    
                        var router = this.getRouter();
                        var url = '#' + this.scope + '/create';
                        router.dispatch(this.scope, 'create', {
                            attributes: attributes
                        });
                        router.navigate(url, {trigger: false});
                    }, this);
                }, this);
            }
    
        });
    });
    
    
    define('views/portal-user/list', 'views/list', function (Dep) {
    
        return Dep.extend({
    
            defaultOrderBy: 'createdAt',
    
            defaultOrder: 'desc',
    
            setup: function () {
                Dep.prototype.setup.call(this);
            },
    
            actionCreate: function () {
                var viewName = this.getMetadata().get('clientDefs.EigeneMitarbeiter.modalViews.select') || 'views/modals/select-records';
    
                var viewName = 'crm:views/eigenemitarbeiter/modals/select-for-portal-user';
    
                this.createView('modal', viewName, {
                    scope: 'EigeneMitarbeiter',
                    primaryFilterName: 'notPortalUsers',
                    createButton: false,
                    mandatorySelectAttributeList: [
                        'salutationName',
                        'firstName',
                        'lastName',
                        'accountName',
                        'accountId',
                        'emailAddress',
                        'emailAddressData',
                        'phoneNumber',
                        'phoneNumberData'
                    ]
                }, function (view) {
                    view.render();
    
                    this.listenToOnce(view, 'select', function (model) {
                        var attributes = {};
    
                        attributes.contactId = model.id;
                        attributes.contactName = model.get('name');
    
                        if (model.get('accountId')) {
                            var names = {};
                            names[model.get('accountId')] = model.get('accountName');
    
                            attributes.accountsIds = [model.get('accountId')];
                            attributes.accountsNames = names;
                        }
    
                        attributes.firstName = model.get('firstName');
                        attributes.lastName = model.get('lastName');
                        attributes.salutationName = model.get('salutationName');
    
                        attributes.emailAddress = model.get('emailAddress');
                        attributes.emailAddressData = model.get('emailAddressData');
    
                        attributes.phoneNumber = model.get('phoneNumber');
                        attributes.phoneNumberData = model.get('phoneNumberData');
    
                        attributes.userName = attributes.emailAddress;
    
                        attributes.type = 'portal';
    
                        var router = this.getRouter();
    
                        var url = '#' + this.scope + '/create';
    
                        router.dispatch(this.scope, 'create', {
                            attributes: attributes
                        });
                        router.navigate(url, {trigger: false});
                    }, this);
    
                    this.listenToOnce(view, 'skip', function (model) {
                        var attributes = {
                            type: 'portal'
                        };
    
                        var router = this.getRouter();
                        var url = '#' + this.scope + '/create';
                        router.dispatch(this.scope, 'create', {
                            attributes: attributes
                        });
                        router.navigate(url, {trigger: false});
                    }, this);
                }, this);
            }
    
        });
    });
    
    
    ​
    Last edited by biocronic; 03-09-2023, 12:29 PM.

    Leave a comment:

Working...
X