Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Get the value from MS CRM Record and Set the value in input textbox of a HTML page

(0) ShareShare
ReportReport
Posted on by 10
Hi All,
I am using this sample code to get value from MS CRM Contact Record and Set value in text box of a HTML Page. But this code is not working, I want to set the values On Load of the HTML page.
<html> 
<head>
 
</head>
<body onload="retrieveAccount()" style="word-wrap: break-word;">
    <script src="ClientGlobalContext.js.aspx" type="text/javascript" ></script>
    <script type="text/javascript"></script>
    <script>
        function retrieveContact() {
            var fullname = window.parent.Xrm.Page.getAttribute("fullname").getValue();
            var jobtitle = window.parent.Xrm.Page.getAttribute("jobtitle").getValue();
            document.getElementById("name").value = fullname;
            document.getElementById("role").value = jobtitle;
        }
    </script>
    <form>
        <p>
            <label>Fullname</label>
            <input type="text" id="name" onload="retrieveContact()">
        </p>
        <p>
            <label>Jobtitle</label>
            <input type="text" id="role" onload="retrieveContact()">
        </p>
    </form>
</body>
</html>

*This post is locked for comments

  • harish reddy Profile Picture
    harish reddy 10 on at
    RE: Get the value from MS CRM Record and Set the value in input textbox of a HTML page

    Hi Goutam,

    Thanks for your reply, the code works successfully.

    Thankyou,

    Harish

  • Verified answer
    gdas Profile Picture
    gdas 50,085 on at
    RE: Get the value from MS CRM Record and Set the value in input textbox of a HTML page

    Hi Harish,

    If you are opening HTML page in a popup window you can try with this -

            function retrieveContact() {
                var fullname = window.parent.opener.Xrm.Page.getAttribute("fullname").getValue();
                var jobtitle = window.parent.opener.Xrm.Page.getAttribute("jobtitle").getValue();
                document.getElementById("name").value = fullname;
                document.getElementById("role").value = jobtitle;
            }


    If you are opening the HTML web resource in an Iframe you can try with adding additional parent .

    Hope this helps.

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,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans