Showing results for 
Search instead for 
Did you mean: 
Helper IV
Helper IV

Set Lookup Field Value from PCF

Hi Everyone,


I hope I have posted this in the correct place and hopefully this will be a simple thing for most. I am *very* new to PCF development (there is nobody else in our company to do it) and I'm looking to use a component to solve our addressing issues (seems to be a common theme too). I have used another component from the PCF Gallery to get the addressing details, but now I need to set the value of a couple of lookups (State and Country) to the values returned from the API. 


I've seen a lot of posts about creating custom lookup components, but I can't seem to find anything that relates to this slightly simpler task (or it seems simpler). Can anyone point me at any resources that might help me walk through this?



Super User
Super User

Hi @Serviced2000 , 


You can have a look to the Lookup PCF example: There is a link to the source code.


If you have a more specific question, please let us know.


Hope this helps!


Kind regards,


Kind regards,
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."
Super User
Super User

OK, to set a Lookup Value from a PCF (assuming your PCF isn't Bound to that lookup) you will need to use the WebApi in your PCF. First, uncomment the use of WebApi from the manifest file and rebuild your control. This will give you a context.webapi object in typescript you can use to perform various actions.


Next, you will need to put an update in the correct place in your code. Here is a reference page on the PCF webapi update syntax, but it doesn't have any examples, so check out the the client script api reference page for examples (the syntax is basically identical).


What you'll see is that when updating a lookup value you need to use this odata syntax to bind the guid input you're providing to a specific table.

var data =
        "primarycontactid@odata.bind": "/contacts(61a0e5b9-88df-e311-b8e5-6c3be5a8b200)"

So your data object will contain a row that references:

"{fieldname of your lookup}@odata.bind" :  "/{plural form of the lookup table name}({record guid})"

Super User
Super User

Hi @cchannon , Hi @Serviced2000 


When I think to an address-autocomplete, usually I have a service which retrieves the data. Usually strings. 

An adress-autocomplete can be bound to several properties like street, city. There we can add the lookup bound properties country and state too.
After the service returns the suggestions, and one of them is chosen, I would add the webAPI request in order to get the corresponding lookups, and set it together with the other propeties through getOutputs.

This way, the data is consistent: the user saves all address-fields or nothing.


Kind regards,




Kind regards,
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

Also, you can use my toolkit that already contains autocomplete that supports lookup fields for country/state -

Advocate II
Advocate II

I just need the value of a lookup.


How can I just get the lookup entity reference as value?



        <property name="LookupProperty" display-name-key="Lookup" description-key="Lookup" of-type="Lookup.Simple" usage="bound" required="true" />


 Setting the property usage to "input" or "bound" lets me choose it in the form editor for the pcf control but then the pcf is not working anymore and removing the selected lookup from the component options isn't possible. The pcf is not showing as component anymore.

Features like utility and webapi are already enabled.

Can you please provide your full manifest file?

<?xml version="1.0" encoding="utf-8" ?>
    <control namespace="tvd" constructor="Griddy" version="0.0.5" display-name-key="Griddy" description-key="Griddy description" control-type="standard">
        <data-set name="griddy" display-name-key="griddy subgrid" cds-data-set-options="displayCommandBar:true;displayViewSelector:true;displayQuickFindSearch:true">
        <property name="somePhase" display-name-key="Some phase" description-key="Some phase" of-type="OptionSet" usage="input" required="true" />
        <property name="Lookup" display-name-key="Lookup" description-key="Lookup" of-type="Lookup.Simple" usage="bound" required="true" />
            <css path="css/Griddy.css" order="1" />
            <code path="index.ts" order="2"/>
            <resx path="strings/Griddy.1033.resx" version="1.0.0" />
      <uses-feature name="Utility" required="true" />
      <uses-feature name="WebAPI" required="true" />

It seems that your PCF control is of "Dataset" type. How do you plan to use that lookup and what do you plan to bind it to?

I plan to bind a custom entity lookup to it so I can read out the value in pcf for filtering the dataset. I want to avoid having a dummy field just to fill the guid of the lookup and listen to this dummy control.

Helpful resources

Power Platform Call June 2022 768x460.png

Power Platform Community Call

Join us for the next call on August 17, 2022 at 8am PDT.

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Users online (2,091)