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.
Announcement
Collapse
No announcement yet.
Role for Convert Lead to Contact Button
Collapse
X
-
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!
- Likes 2
-
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:
The section I want to highlight is probably near the end for you: 3.13 Require Coding - Tutorials and Guide
-
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.
-
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', }); }
- Likes 2
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 databaseLast edited by JosNas; 10-12-2021, 10:21 AM.
-
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.
- Likes 1
Comment
Comment