Skip to main content

Notifications

Microsoft Dynamics CRM (Archived)

prepopulating Lookup on Custom Entity form using Dynamics CRM 365 Customer Portal.

Posted on by Microsoft Employee

I want to open Create a form of a custom entity with prepopulating Lookup(Opportunity) value fill when the form opens using Dynamics CRM 365 customer Portal.

*This post is locked for comments

  • Verified answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: prepopulating Lookup on Custom Entity form using Dynamics CRM 365 Customer Portal.

    Finally Solved the issue. below script is working.

    {% extends 'Layout 1 Column' %}
    {% block main %}
    {% include 'Page Copy' %}
    <div class="form" data-cancel-label="{{ snippets['CustomerService/Case/Resolved'] | default: resx['Editable_Cancel_Label'] | h }}" data-case-deflection-pagesize="5" data-case-deflection-logicalnames="knowledgearticle,incident,adx_issue,adx_webpage,adx_communityforumthread,adx_communityforumpost,kbarticle" data-case-deflection-query="" data-case-deflection-filter="">
    {% entityform id:page.adx_entityform.id %}
    </div>

    {% fetchxml Opportunityy %}
    <fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">
    <entity name="opportunity">
    <attribute name="name" />
    <attribute name="customerid" />
    <attribute name="opportunityid" />
    <order attribute="name" descending="false" />
    <filter type="and">
    <condition attribute="opportunityid" operator="eq" value="{{request.params['id'] }}" />
    </filter>
    </entity>
    </fetch>
    {% endfetchxml %}
    {% if Opportunityy.results.entities.size > 0 %}
    {% assign opportunityid = Opportunityy.results.entities[0].opportunityid %}
    {% assign opportunityname = Opportunityy.results.entities[0].name %}

    <script type="text/javascript">

    $("#new_opportunityid_name").val('{{opportunityname}}');
    $("#new_opportunityid").val('{{opportunityid}}');
    $("#new_opportunityid_entityname").val("opportunity");
    </script>

    {% endif %}


    {% endblock %}

     

  • Suggested answer
    RaviKashyap Profile Picture
    RaviKashyap 55,410 on at
    RE: prepopulating Lookup on Custom Entity form using Dynamics CRM 365 Customer Portal.

    Hi,

    The error you are getting is because eventName is a liquid variable which contains the new_name field value hweras alert uses the string. To use the liquid paramters, you need to use braces just like you are already using {{name}}.

    What happens when you comment out the alert?

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: prepopulating Lookup on Custom Entity form using Dynamics CRM 365 Customer Portal.
    {% fetchxml Opportunityy %}
    <fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">
    <entity name="opportunity">
    <attribute name="name" />
    <attribute name="customerid" />
    <attribute name="opportunityid" />
    <order attribute="name" descending="false" />
    <filter type="and">
    <condition attribute="opportunityid" operator="eq" value="{{request.params['id']}}" />
    </filter>
    </entity>
    </fetch>
    {% endfetchxml %}
    {% if Opportunityy.results.entities.size > 0 %}
    console.log("This is");
    {% assign eventName = Opportunityy.results.entities[0].new_name %}
    <script>
    $(document).ready(function() {
    alert("before set ");
    console.log("This is function");
    alert(eventName);
    $("#new_opportunityid_name").attr("value", {{name}});
    $("#new_opportunityid").attr("value", {{opportunityid}});
    $("#new_opportunityid_entityname").attr("value", "opportunity");

    alert("after set");
    });
    </script>
    {% endif %}
    I am using the above code. while trying to alert value getting the error.
    "eventName is not defined".
    Thanks in Advance.
  • Suggested answer
    RaviKashyap Profile Picture
    RaviKashyap 55,410 on at
    RE: prepopulating Lookup on Custom Entity form using Dynamics CRM 365 Customer Portal.

    Hi,

    There is no standard configuration in portal. You need to use JavaScript/ JQuery to populate the values. You can refer the below blog to achieve the same-

    arpitmscrmhunt.blogspot.com/.../adxstudio-set-values-in-lookup-fields.html

    Hope this helps.

  • Suggested answer
    Dynamics365 Rocker Profile Picture
    Dynamics365 Rocker 7,755 on at
    RE: prepopulating Lookup on Custom Entity form using Dynamics CRM 365 Customer Portal.

    Please go through below link, hope it helps you.

    community.dynamics.com/.../255274

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!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,149 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans