Skip to main content

Notifications

Announcements

No record found.

Customer experience | Sales, Customer Insights,...
Suggested answer

How to populate data from CRM to HTML page

Posted on by 5

I have one entity Student with field name as Name, Age, Id etc. in CRM.

Now I have created a custom HTML page, where I have dropdown for Student name.

So please tell me how can I fetch the Student name from the CRM and show it in the dropdown.

I have went through lot of resources, but had no luck. Kindly help me in this.

You can help me with some demo codes as well, that will be really very helpful.

Thanks in advance

  • Suggested answer
    Abdul Wahab Profile Picture
    Abdul Wahab 12,070 Super User 2024 Season 1 on at
    RE: How to populate data from CRM to HTML page

    Hi sillydeveloper,

    It is better to show them as a lookup by using below similar code

    HTML

    <br><br>
    <div id="Update" style="color:brown">
    Record 1 (Update) : Source Fund : <input type="text" id="sourceFundName" readonly=""><input type="button" onclick="showFundLookupDialog()" id="btnFund" value="Select"><input type="text" id="sourceFundId" hidden="">
    <!--Source Amount (Inc GST) : <input type="text" id="sourceAmountIcludingGST" readonly=""><input type="number" id="P_SourceAmountIcludingGST" value="100" readonly="" hidden="">-->
    <label for="sourceAmountIcludingGST" id="sourceAmountIcludingGSTId">% of Source Amount (Inc GST) :</label>
    <input type="text" id="sourceAmountIcludingGST" readonly="" hidden=""><input type="number" id="P_SourceAmountIcludingGST" value="100" readonly="">
    </div>

    JS

    function showFundLookupDialog() {
    try {
    var lookupParameters = {};
    lookupParameters.entityTypes = ["ecs_fund"];
    lookupParameters.defaultEntityType = "ecs_fund";
    lookupParameters.defaultViewId = "{F0B85996-2784-4511-BFE2-3BBE840F609E}";
    lookupParameters.allowMultiSelect = false;
    lookupParameters.disableMru = true;
    parent.Xrm.Utility.lookupObjects(lookupParameters).then(DisplaySelectedFund, null);
    } catch (e) {
    alert("Error in showFundLookupDialog1: " + e.messagee);
    }
    }

    You can still use dropdown by following the below similar code

    HTML:

    <div class='col'>
    <label class="lbl">Campaign</label>
    <select style="font-weight:500; background-color: antiquewhite;" class='form-select' id='originalCampaign' onchange="OnchangeCampaign('originalCampaign')"></select>
    </div>

    JS

    function RetrieveDropdowns() {
    try {

    //Retrieve Active Campaigns
    var fetchXmlCampaign = [
    "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>",
    " <entity name='campaign'>",
    " <attribute name='campaignid'/>",
    " <attribute name='name'/>",
    " <order attribute='name' descending='false'/>",
    " <filter type='and'>",
    " <condition attribute='statecode' operator = 'eq' value = '0' />",
    " </filter>",
    " </entity>",
    "</fetch>"
    ].join("");
    RetrievewithResults("campaigns", fetchXmlCampaign, "Results1");
    } catch (e) {
    alert("Error in retrieveDonationDetail: " + e.messagee);
    }
    return true;
    }

    function Dropdowns() {
    try {

    document.getElementById("originalCampaign").innerHTML = "";
    campaign: globalVariables.Results[0]["_maa_campaign_value"],

    optionsetValues.campaignId = globalVariables.Results1[k]["campaignid"];
    optionsetValues.campaignName = globalVariables.Results1[k]["name"];
    document.getElementById("originalCampaign").innerHTML += "<option value='" + optionsetValues.campaignId + "'> " + optionsetValues.campaignName + "</option></select>";

    document.getElementById("originalCampaign").value = orgvalues.campaign;

    document.getElementById("OptionsetCampaign" + a).value = orgvalues.campaign;

    } catch (e) {
    alert("Error in Dropdown: " + e.messagee);
    }
    }

  • Suggested answer
    a33ik Profile Picture
    a33ik 84,323 Most Valuable Professional on at
    RE: How to populate data from CRM to HTML page

    Hello,

    You should use WebApi to query the data - docs.microsoft.com/.../query-data-web-api

    In order to build queries in an easier way, you can use DataVerse RestBuilder - github.com/.../DRB

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans