Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Pages - Power Apps Portals
Answered

Dynamics 365 Portal - Entity list set lookup value on create mode

Like (0) ShareShare
ReportReport
Posted on 22 Jul 2020 12:11:46 by 120

 

Hi,

 

We have 1-M relationship between Contact and Resource Entity. When click "Create" on "Resource Forecast" entity list page, the contact gets set to the login user however we also want to be able to by default set equivalent resource lookup value. Every portal contact is also set as Resource in CRM.

 

I wonder if we need FetchXML or WebAPI call in Entity list to only execute when "Create" is clicked therefore pass contact guid and retrieve equivalent Resource record from CRM and set the lookup value here (screenshto attached)?

 

SetResource.png

 

  • Verified answer
    UmerJaved Profile Picture
    120 on 29 Sep 2021 at 16:58:47
    Re: Dynamics 365 Portal - Entity list set lookup value on create mode

    Hi @bobf,

     

    Yes it did work eventually. I had to use fetchxml in a template to retrieve the resource record.  Then in my entity form I had to use Javascript make fetchml call by passing login contact id. The following article helped me to achieve the desired results.

     

    https://www.dancingwithcrm.com/custom-lookup-filtering-powerapps-portal/

     

     

  • oliver.rodrigues Profile Picture
    9,315 Most Valuable Professional on 06 Sep 2021 at 20:15:50
    Re: Dynamics 365 Portal - Entity list set lookup value on create mode

    @bobf this seems to be an old thread, can you please create a new one and give more details of your issue? 

  • MRCBob Profile Picture
    2 on 06 Sep 2021 at 12:58:05
    Re: Dynamics 365 Portal - Entity list set lookup value on create mode

    Did you ever get around this, I am trying to get exactly the same up and running.

  • UmerJaved Profile Picture
    120 on 24 Jul 2020 at 05:44:04
    Re: Dynamics 365 Portal - Entity list set lookup value on create mode

    Hi @hardikv  and @OliverRodrigues 

     

    I managed to tidyup the JavaScript and liquid into the correct format therefore added into Custom JavaScript section of my Entity form. However the lookup value still doesn't seem to be set. I am wondering if we need to make explicit WebAPI call here? 

     

     

     

    $(document).ready(function()
    {
    '{% fetchxml get_resource_query %}'

    "<fetch distinct='false' output-format = 'xml-platform' mapping='logical'>"+
    "   <entity name='bookableresource'>"+
    "      <attribute name='name' />"+
    "      <attribute name='createdon' />"+
    "      <attribute name='resourcetype' />"+
    "      <attribute name='bookableresourceid' />"+
    "      <order attribute='name' descending='false' />"+
    "      <filter type='and'>"+
    "         <condition attribute='contactid' operator='eq' value='{{user.id}}' />"+
    "      </filter>"+
    "   </entity>"+
    "</fetch>"

    '{% endfetchxml %}'
    '{% assign contact_result=get_resource_query.results.entities %}'
    '{% for result in contact_result %}'
    $("#ao_bookableresource_name").val('{{result.name}}');
    $("#ao_bookableresource").val('{{result.id}}');
    $("#ao_bookableresource_entityname").val('bookableresource');
    '{% endfor %}'
    });
  • UmerJaved Profile Picture
    120 on 23 Jul 2020 at 16:25:49
    Re: Dynamics 365 Portal - Entity list set lookup value on create mode

    Thanks @hardikv . It is Entityform(insert mode) in my scenario when create is clicked from entity list. Can I add javascript and liquid both in custom javascript section under "Additional Settings" in entityform therefore set my lookup? Apparently liquid tags don't seem to be recognised here and I get expression errors:

     

    Liquid.PNG

     

     

  • H V Profile Picture
    1,510 on 23 Jul 2020 at 14:54:49
    Re: Dynamics 365 Portal - Entity list set lookup value on create mode

    Hi @UmerJaved 

    If you want to put javascript then you have to put javascript in Web Page's localized content page for your requirement.

     

    It seems that you are adding javascript in Entity List, that is wrong place to put javascript for your requirement.

     

    If you have created a Web Page for create a record, then put javascript in localized content of webpage.

    If you have created a Web Form for create a record, then put javascript in Entity Form record(Additional Settings Tab -> Custom JavaScript).

     

  • UmerJaved Profile Picture
    120 on 23 Jul 2020 at 14:43:56
    Re: Dynamics 365 Portal - Entity list set lookup value on create mode

    Hi @OliverRodrigues 

     

    I guess it is moreover setting a value on load of the create form instead of submit of the form.  Can we use custom javascript section in entity list form therefore use Fetchxml query/liquid and checking if the create button is clicked therefore set the lookup value?  Screenshot attached.Capture.PNG

  • oliver.rodrigues Profile Picture
    9,315 Most Valuable Professional on 23 Jul 2020 at 07:50:26
    Re: Dynamics 365 Portal - Entity list set lookup value on create mode

    you can add custom code to validate fields on the submit button.. I guess that's the best place to put your logic

     

    https://docs.microsoft.com/en-us/powerapps/maker/portals/configure/add-custom-javascript#additional-client-side-field-validation

     

  • H V Profile Picture
    1,510 on 22 Jul 2020 at 19:56:00
    Re: Dynamics 365 Portal - Entity list set lookup value on create mode

    Hi @UmerJaved

    You have to put liquid code in single quotein javascript.

    $("#ao_fieldname").val('{{result.name}}');

  • UmerJaved Profile Picture
    120 on 22 Jul 2020 at 16:25:28
    Re: Dynamics 365 Portal - Entity list set lookup value on create mode

    Hi @OliverRodrigues 

     

     

    I'll look into the option you suggested. However I have written FetchXML in a web template therefore able to retrieve the Guid from the resource record (attached screenshot).

     

    Now the question how do I setup the resource lookup value on the create form so it is only set when "Create" is clicked from the entity list web page?   I tried to setup the lookup value in web template within Fetch XML result however it didn't work.Lookup.PNG

     

    ResourceDetail.PNGCreateForm.PNG

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

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Leaderboard > Power Pages - Power Apps Portals

#1
stampcoin Profile Picture

stampcoin 11

#2
Muzammil Nawaz Profile Picture

Muzammil Nawaz 8

#2
Ajlan Profile Picture

Ajlan 8

Overall leaderboard
Loading started