web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
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

I have the same question (0)
  • Verified answer
    gdas Profile Picture
    50,091 Moderator on at

    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.

  • harish reddy Profile Picture
    10 on at

    Hi Goutam,

    Thanks for your reply, the code works successfully.

    Thankyou,

    Harish

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans