-
Notifications
You must be signed in to change notification settings - Fork 26
MobileCRM.UI.EntityForm.onCanExecuteCommand
rescocrm edited this page May 15, 2023
·
10 revisions
Binds or unbinds the handler called when the EntityForm needs to find out whether the command can be executed (is enabled).
Argument | Type | Description |
---|---|---|
command | String | The name of the EntityForm command. Optionally can contain the param value separated by slash (e.g. ChangeStatus/5). |
handler | function(entityForm) | The handler function that has to be bound or unbound. Handler's return value indicates whether the command is enabled (true/false). |
bind | Boolean | Determines whether to bind or unbind the handler. |
scope | Object | The scope for handler calls. |
This example demonstrates how to control the visibility of the custom command "Scanner". It can be used for any product entity having the field "productnumber" empty. The custom command can be added onto the form via Woodford or Resco CRM.
MobileCRM.UI.EntityForm.onCanExecuteCommand("custom_Scanner", function (entityForm) {
var entity = entityForm.entity;
return !entity.properties["productnumber"];
}, true);
This example demonstrates how to control the visibility of the command with parameter. In our case it is standard "ChangeStatus" command on the Lead form. Following code disables this command for specific status "Disqualified - Cannot Contact".
MobileCRM.UI.EntityForm.onCanExecuteCommand("ChangeStatus/5", // The value "5" is the status code for "Disqualified - Cannot Contact" status on Lead entity
function (entityForm) {
return false;
}, true);