-
Notifications
You must be signed in to change notification settings - Fork 26
MobileCRM.UI.EntityForm.onCommand
rescocrm edited this page May 15, 2023
·
9 revisions
Binds or unbinds the handler for EntityForm command.
Argument | Type | Description |
---|---|---|
command | String | The name of the EntityForm command. |
handler | function(entityForm) | The handler function that has to be bound or unbound. |
bind | Boolean | Determines whether to bind or unbind the handler. |
scope | Object | The scope for handler calls. |
This example demonstrates how to handle custom command "Scanner" to start the barcode scanner and store the result into currently edited "product" entity. The custom command can be added on the form via Woodford/Resco CRM.
MobileCRM.UI.EntityForm.onCommand("custom_Scanner", function (entityForm) {
var entity = entityForm.entity;
MobileCRM.Platform.scanBarCode(function (res) {
if (!res || res.length <= 0) {
sayError("No barcode");
}
else {
storeBarCode(res[0]);
}
}, function (err) { sayError(err); });
}, true);
function storeBarCode(code) {
MobileCRM.UI.EntityForm.requestObject(function (entityForm) {
entityForm.entity.properties["productnumber"] = code;
}, function (err) { sayError(err); });
}