Search code examples
javascriptmobiledynamics-crm

How to Get current form propety in Mobile CRM by Resco in JS Bridge?


I created a custom offline HTML and need to getProperty from current record Form. For example, when I click on an "appointment" record, I need to catch "new_address_latitude" property that is loaded in "this" form. I need a full example to get property from current record and relations. thank you


Solution

  • These are links from Resco JSBridge support pages. You can find many examples in reference page.

    Reference page: Reference page with examples

    Short JSBridge guide: pdf short JSbridge guide

    About this scenario, it requires to register handler what will be fired during onload of html page. How to do it, you can find in attached link to JSBridge short guide.

    But code looks like this

    window.onload = function () {
            //register this during onload
                MobileCRM.UI.EntityForm.requestObject(
                function (entityForm) {
                    /// <param name="entityForm" type="MobileCRM.UI.EntityForm"/>
                    // Get the MobileCRM.DynamicEntity which is being edited on this form
                    var entity = entityForm.entity;
                    // get specific porperty of entity object.
                    var newAddresLatitude = entity.properties.new_address_latitude;
    
                    return true;
                },
                function (err) {
                    MobileCRM.bridge.alert("An error occurred: " + err);
                },null);
        }