What i want :
On Pro 7.5.2
For a client, when a user clicks on a custom button in a Leads' record, it calls an external API.
So, basically, i want that, if the api call is successful and we don't get any errors, i want to disable editing on the Leads' record, and i want to mark it as "converted". (aka, get the convert button to turn green, and save the fact that the lead has been converted into the databases)
What i did :
I've managed to do this with the
app.api.call('GET', app.api.buildURL('myCustomEndPoint/myCustomMethod/'+this.model.get('id')), null, {
success: function(date) {
console.debug("Success!");
var acls = app.user.getAcls();
acls.Leads.edit = 'no';
app.user.set("acls", acls);
self.model.set('converted','1');
/*$('[name="edit_button"]').hide(); */
},
error:function(error){
console.debug(error);
}
});
Where i am stuck :
For the "disable edit" part, i tried to change the ACL on it -as you can see, but it does not seem to work. Do you have any idea on this?
But, well, this is not the most important question i have (really, because i can hide the "edit" button if i want to).
The most important question here is :
- How to mark the lead as Converted ? Aka : Being on record.js, how can i fill the database column "converted" with 1, and render the green button saying "Converted"
As you can see, i've tried with
this.model.set('converted','1');
but in the Firebug Console, it says that "this" is undefined, so i tried with declaring self = this before the api call. But it does not work either.
I would like it to change from 0 to 1 and to be saved in databases...
Thanks a lot for the ideas and the tips !