Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

How to open a pre-populated form to create a record in Crm 2011 using Javascript

Posted on by Microsoft Employee

Hi,

I have a requirement where on save of an Account record, a new  Account form should open in a new window to create a new Account record and when the form opens its fields should be pre populated with values on the previous form(i.e the record we created before this form opened) using Javascript. How can I do that ? 

Can someone help me with a piece of code?

Thanks

*This post is locked for comments

  • Suggested answer
    a33ik Profile Picture
    a33ik 84,323 Most Valuable Professional on at
    RE: How to open a pre-populated form to create a record in Crm 2011 using Javascript

    Goutam,

    I don't think that any of Xrm.Page.data.save() or Xrm.Utility.openEntityForm() were available in CRM 2011. Correct me if I'm wrong.

  • Verified answer
    gdas Profile Picture
    gdas 50,085 on at
    RE: How to open a pre-populated form to create a record in Crm 2011 using Javascript

    Hello Bob,

    Here is sample code , you need to registered the function "OnSaveAccount" in Account entity onsave event.

            function OnSaveAccount() {  
                Xrm.Page.data.save().then(successSubmitCallback, errorSubmitCallback);
            }
            function successSubmitCallback() {
                var parameters = {};
                var windowOptions = {
                    openInNewWindow: false // You can open in a new window . False means its just redrect to new form
                };
    
                parameters["name"] = Xrm.Page.getAttribute("name").getValue(); // pass parameter getting from current account attribute
                parameters["accountnumber"] = Xrm.Page.getAttribute("accountnumber").getValue();// pass parameter getting from current account attribute
    
                window.parent.Xrm.Utility.openEntityForm("account", null, parameters, windowOptions); // Open new creation form
            }
            function errorSubmitCallback() {
                alert('Error Occurred');
            }


  • Verified answer
    a33ik Profile Picture
    a33ik 84,323 Most Valuable Professional on at
    RE: How to open a pre-populated form to create a record in Crm 2011 using Javascript

    Hello Bob,

    Here is MSDN article that describes feature you want to implement - msdn.microsoft.com/.../gg334375.aspx

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