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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Open Entity Form In ( create record mode)

(0) ShareShare
ReportReport
Posted on by 1,434

Hi ,

I want to open Entity Form In ( create record mode) and set lookup value in the opened entity form using java scripts and java scripts is written in aspx page and aspx show in crm through IFrame.

also open entity form in the pop up not same window.

Thanks & Regards,

Abhishek Srivastava

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Royal King Profile Picture
    27,686 on at

    you can open new record with look value populated by passing querystring param in the url

    something like below should work . Below url opens new lead record with owner lookup value populated

    /main.aspx?etn=lead&pagetype=entityrecord&extraqs=ownerid%3D%7bB8C6E040-656E-DF11-B414-00155DB1891A%7d%26owneridname%3DMark%20Folkerts%26owneridtype%3Dsystemuser

    \

    if you need more info on this check the below documentation on this topic

    msdn.microsoft.com/.../gg334375.aspx

  • Suggested answer
    Community Member Profile Picture
    on at

    Hi Abhishek,

    You can use openEntityForm also to open form as described below :

    Opens an entity form for a new or existing entity record using the options you set as parameters.

    Xrm.Utility.openEntityForm(name,id,parameters,windowOptions)

    Parameters :

    Name

    Type

    Required

    Description

    name

    String

    Yes

    The logical name of the entity.

    id

    String

    No

    The string representation of a unique identifier or the record to open in the form. If not set, a form to create a new record is opened.

    parameters

    Object

    No

    A dictionary object that passes extra parameters to the form. Invalid parameters will cause an error.

    Valid extra query string parameters are:

    windowOptions

    Object

    No

    For Microsoft Dynamics CRM Online 2015 Update 1 or later use this optional parameter in the web application to control how the form opens. You can choose to open a form in a new window by passing a dictionary object with a Boolean openInNewWindow property set to true.

    This parameter is ignored in CRM for tablets and CRM for phones.

     

     

    Sample Code :

    function CloneRecord() {

      

           if (Xrm.Page.data.entity.attributes.get("parentaccountid").getValue() != null) // lookup to Account

           {

               var _accountId = Xrm.Page.data.entity.attributes.get("parentaccountid").getValue()[0].id;
               var _accountName = Xrm.Page.data.entity.attributes.get("parentaccountid").getValue()[0].name;
               var _accountType = Xrm.Page.data.entity.attributes.get("parentaccountid").getValue()[0].entityType;

           }

            if (Xrm.Page.data.entity.attributes.get("parentcontactid").getValue() != null) // lookup to Contact

           {
             var _contactId = Xrm.Page.data.entity.attributes.get("parentcontactid").getValue()[0].id;
               var _contactName = Xrm.Page.data.entity.attributes.get("parentcontactid").getValue()[0].name;
               var _contactType = Xrm.Page.data.entity.attributes.get("parentcontactid").getValue()[0].entityType
       }

                //define default values for new record

           var parameters = {};

          if (_contactId != null && _contactName != null) // Contact

           {

               parameters["parentcontactid"] = _contactId;
               parameters["parentcontactidname"] = _contactName;

           }

           if (_accountId != null && _accountName != null) // Account

           {

               parameters["parentaccountid"] = _accountId;
               parameters["parentaccountidname"] = _accountName;

           }

           var windowOptions = {

               openInNewWindow: true

           };

           //pop opp form with default values

           Xrm.Utility.openEntityForm("opportunity", null, parameters, windowOptions);

      

    }

    Hope this Helps !! I would appreciate iy you can mark my answer as verified .!! Thanks

    Regards,

    Kamran

  • Abhishek.Srivastava Profile Picture
    1,434 on at

    open custom entity in new record mode using java scripts.

  • Verified answer
    Royal King Profile Picture
    27,686 on at

    As your script is in aspx page you can't use Xrm.Utility method. You have to use window.open .

    you can open any entity in new record mode by passing right querysting in the url.

    for example to open custom entity new window withname "new_customer" you ahve to pass query string as below

    etn = new_customer

    pagetype=entityrecord

    extraqs= pass value to set in new record like auto populating owner

    windod.open("crmbaseurl"+"main.aspx?etn=new_customer&pagetype=entityrecord&extraqs=ownerid%3D%7bB8C6E040-656E-DF11-B414-00155DB1891A%7d%26owneridname%3DMark%20Folkerts%26owneridtype%3Dsystemuser");

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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
ScottDurow Profile Picture

ScottDurow 2

#2
GJones Profile Picture

GJones 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans