Announcement

Collapse
No announcement yet.

Role for Convert Lead to Contact Button

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

  • Role for Convert Lead to Contact Button

    Can I limit the access to the convert button to a certain team. For example I want only users belonging to Team 'Board Members' to be able to convert the Lead to a Contact.

  • #2
    Yes. From JS. Try editing the detail.js file under src/views/lead/

    this.getUser() -> will give you all the attributes related to the current user.

    There maybe a better solution. I just started out with ESPO, I am not entirely familiar with it yet.

    Cheers!

    Comment


    • esforim
      esforim commented
      Editing a comment
      You seem to know code AgentT! Welcome welcome.

      You might want to read through Telecastg guide to see how EspoCRM work. There is also this resources here for other readings:

      Contribute to o-data/EspoCRM-Learning-and-Design development by creating an account on GitHub.


      The section I want to highlight is probably near the end for you: 3.13 Require Coding - Tutorials and Guide

    • JosNas
      JosNas commented
      Editing a comment
      Thank you for your reply AgentT. However I didn't really understand how this method ( this.getUser() ) which gives me the attributes of a user can help hide/disable the convert button from all teams except one or two. I think something should be edited in the convert.js instead no?
      Last edited by JosNas; 10-11-2021, 06:07 AM.

    • esforim
      esforim commented
      Editing a comment
      My guess is that you getUser() then disable button from view if it not found?

  • #3
    JosNas As mentioned by esforim you can disable the "Convert" button from the UI using this.

    this.getUser().attributes.teamsIds will get you the Team which the user belongs to.

    Then you can use this to check if the user belongs to a certain team and have the button removed.

    detail.js should look something like this:
    Code:
    if(!this.getUser().attributes.teamsIds.includes('board_members')){
        this.menu.buttons.pop({
            label: 'Convert',
            action: 'convert',
            acl: 'edit',
        });
    }
    This will disable the "Convert" button from the UI for all users who do not have the Team "board_members".

    Comment


    • JosNas
      JosNas commented
      Editing a comment
      It partially worked because it did disable (pop) the convert button. However, it also removed it from team board_members. I think the problem has to do with the team ID I entered. Where can I get the team's ID from? I got it from the database (table team column id) but I don't think the team ID you're talking about is the same as the one in the database
      Last edited by JosNas; 10-12-2021, 10:21 AM.

    • esforim
      esforim commented
      Editing a comment
      i think it would be the same; here is an example URL

      espocrm.com//#Team/view/5e44.....

      that 5e44 would be the ID

    • AgentT
      AgentT commented
      Editing a comment
      JosNas you can debug the values of this.getUser().attributes.teamsIds from the console to verify the current user Team ID is present.

      The ID from the database should be the same as espocrm.com/#Team/view.

  • #4
    My code in detail.js:

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

    if ((['Converted', 'Dead'].indexOf(this.model.get('status')) == -1 )&&(this.getUser().attributes.teamsIds.includes( '6 15d9a.....'))) {
    this.menu.buttons.push({
    label: 'Convert',
    action: 'convert',
    acl: 'edit',
    });
    }
    },
    ...

    The ID in between the parenthesis is the Team's ID which matches with that in the database. Also, I added the line as an AND condition in the if statement to keep the code concise of course without the ! at first. Is there a problem with the code itself?
    Please note that there is no space between the 6 and the 1 in the ID in my code, this is only appearing here for some reason.

    Comment


    • AgentT
      AgentT commented
      Editing a comment
      Yes that should be correct. I don't know what is going wrong.

      Did you clear cache and rebuild after making your changes? If not, do it and then try.

  • #5
    AgentT I did clear cache and rebuild yet it is still either hiding it from ALL teams & users or showing it to all. Did it work for you?

    Comment

    Working...
    X