MobileCRM.UI.EntityForm.getController - Resconet/JSBridge GitHub Wiki
Returns the tab controller by its view name.
Argument | Type | Description |
---|---|---|
name | String | A name of controller's view. |
This example demonstrates how to get the controller on edit form by its view name.
function getController() {
MobileCRM.UI.EntityForm.requestObject(function (entityForm) {
/// <param name='entityForm' type='MobileCRM.UI.EntityForm'/>
var iframeController = entityForm.getController("iFrame");
}, MobileCRM.bridge.alert);
}
This example demonstrates how to force crop ratio and maximum image width after new image is set (captured/selected/pasted/...) into media tab.
ImageViewMode = {
/// <summary>Size/crop values are taken just like suggestion (e.g. for CaptureImage action).</summary>
NoEnforcement: 0,
/// <summary>Image is automatically cropped to DesiredRatio as it arrives.</summary>
AutoCrop: 1,
/// <summary>Image is automatically resized as it arrives.</summary>
AutoResize: 2,
/// <summary>Image editor is opened to resolve crop/resize actions.</summary>
OpenEditor: 0x8000,
};
MobileCRM.UI.EntityForm.requestObject(function (f) {
/// <param name="f" type="MobileCRM.UI.EntityForm"/>
var documentView;
if (f.entity.entityName == "annotation")
documentView = f.documentView; // NoteForm has "documentView" property
else {
// Other forms have media tab included in controllers array:
var documentController = f.getController("ContactImage");
documentView = documentController.view; // _DocumentController has view of type _DocumentView
}
// Further filtering can be done using relationship
// E.g. Note form opened from contact can be detected this way:
//if (f.relationship.target.entityName == "contact") {...}
// Finally, set desired image props:
documentView.maxImageWidth = 640; // limit image width to 640px
documentView.maxImageHeight = 0; // Allow any height
documentView.desiredRatio = 4 / 3; // Force image ratio 4:3
// Force automatic crop and resize after new image is captured/selected:
documentView.enforcementMode = ImageViewMode.AutoCrop | ImageViewMode.AutoResize;
// AutoCrop takes the center part of image and AutoResize will force image width at most 640px.
// Choose "ImageViewMode.OpenEditor" to let user to choose crop rectangle in image editor:
// documentView.enforcementMode = ImageViewMode.OpenEditor;
});