locked
How to show opportunity field values in html webresource in crm 2013 RRS feed

  • Question

  • Hi,

    I have a requirement that show form field values in html page in Iframe. Please tell me how to show field values in html page as a label

    like I want to show opportunity name in html page as a label in Iframe
    • Edited by Aamir Hijazi Wednesday, January 21, 2015 8:09 AM
    Wednesday, January 21, 2015 8:08 AM

All replies

  • You should be able to use following code to fetch value from parent record.

            var OpportunityName = document.parentWindow.parent.Xrm.Page.getAttribute("field_name").getValue();


    Hope this helps.
     
    -----------------------------------------------------------------------
    Minal Dahiya
    blog : http://minaldahiya.blogspot.com.au/

     
    If this post answers your question, please click "Mark As Answer" on the post and "Vote as Helpful"

    • Proposed as answer by Minal Dahiya Wednesday, January 21, 2015 8:50 AM
    Wednesday, January 21, 2015 8:50 AM
  • If you want to show the Opportunity Values in a IFRAME inside Opportunity form then Minal's method will work, Where as if you have to show the Opportunity records in Another record you can use XRM Service Toolkit to retrieve records with required fields and add the values to HTML pages using javascripts

    If my response answered your question, please "mark the response as an answer" and also "vote as helpful". Regards, Hari. www.crm2011byhari.blogspot.com

    Wednesday, January 21, 2015 9:05 AM
  • Hi,

    I don't know about static web resource.

    I make small web resources (Buttons and text fields) dynamically in JS:

    //Make a text field function
    createTextField: function (text, WebResource, id) {
        var ctrl = document.getElementById(WebResource + '_d');
        var TextField = "<table border='0' cellspacing='0' cellpadding='0'>" +
            "<tr><td>" +
            "<input type='text' value='" + text +
            "' id='" + id + "'/></td></tr></table>";
        ctrl.innerHTML = TextField;
    }
    
    //Create insted WebResource_Text1 a text field with Id: TextFieldId
    createTextField("",'WebResource_Text1',"TextFieldId");
    //Place text InputValue into a textField with Id: TextFieldId
    document.getElementById("TextFieldId").value = "InputValue";

    I just tried with static web resource and on_load function, but my trick failed, because web resource load after on_load function calls. But it should work, when web resource is loaded.

    Wednesday, January 21, 2015 9:08 AM
  • Hi,

         Here is the sample to call Google maps from HTML. This has sample to call parent with ID and field value.

    <html>
    <head>
        <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
        <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
        <title>Map integration</title>
        <script src="ClientGlobalContext.js.aspx"></script>
        <script type="text/javascript" src="jquery172min"></script>
        <script type="text/javascript" src="</script">http://maps.google.com/maps/api/js?sensor=false"></script>
        <script type="text/javascript">
            var entityId = document.parentWindow.parent.Xrm.Page.data.entity.getId();

            var addressValue = document.parentWindow.parent.Xrm.Page.getAttribute("name").getValue();

            function getAllData() {
                var serverUrl;
                var ODataPath;
                var userid;
                var userRole;
                var OrgName;
                var context = GetGlobalContext();
                serverUrl = context.getServerUrl();
                ODataPath = serverUrl + "/XRMServices/2011/OrganizationData.svc";
                userid = context.getUserId();
                userRole = context.getUserRoles();
                OrgName = context.getOrgUniqueName();

            }

        
         var geocoder; 
         var map;
         function initialize() {
            getAllData();
            geocoder = new google.maps.Geocoder();
            var latlng = new google.maps.LatLng(-34.397, 150.644);
            var myOptions = { zoom: 15, center: latlng, mapTypeId: google.maps.MapTypeId.ROADMAP };
            map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
            var address = location.search;
            //address = addressValue;
            if (addressValue != null && addressValue != "") {
                codeAddress(addressValue);
            }
        }
       
        function codeAddress(address) {
            if (geocoder) {
                geocoder.geocode({ 'address': address }, function (results, status) { if (status == google.maps.GeocoderStatus.OK) { map.setCenter(results[0].geometry.location); var marker = new google.maps.Marker({ map: map, [0].geometry.location }); } else { alert("Geocode was not successful for the following reason: " + status); } });
            }
        }
        
         </script>
    </head>
    <body style="margin: 0px; padding: 0px;" onload="initialize()">
        <div id="map_canvas" style="width: 100%; height: 100%">
        </div>
    </body>
    </html>

    Hope this helps.
     
    -----------------------------------------------------------------------
    Minal Dahiya
    blog : http://minaldahiya.blogspot.com.au/


    If this post answers your question, please click "Mark As Answer" on the post and "Vote as Helpful"


    • Edited by Minal Dahiya Wednesday, January 21, 2015 10:17 AM hit submit in error
    Wednesday, January 21, 2015 10:16 AM