MobileCRM.UI.EntityForm.onCommand - Resconet/JSBridge GitHub Wiki
Binds or unbinds the handler for EntityForm command.
Arguments
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);
});
}