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 :
Power Platform Community / Forums / Power Apps / Triggering PCF Control...
Power Apps
Unanswered

Triggering PCF Control load after lookup field has been populated with javascript

(0) ShareShare
ReportReport
Posted on by 8

Hi,

 

I have created a PCF control which will show all connection records name field in a drop down. This PCF control is dependent on a lookup on the form being populated with JS, so when you create a new opportunity, the pcf control doesn't show up. It is only when you save it and refresh the page that the drop down shows. You can't attach my pcf control to lookup fields...

Is there any way to get my control to show regardless of if its a create/update? 

 

Thanks!

I have the same question (0)
  • Diana Birkelbach Profile Picture
    3,072 Most Valuable Professional on at

    Hi @mildseven , 

     

    I would need a little more information.

    Did you made a field-pcf or a dataset pcf?
    I couldn't understand why the pcf is not shown in the create mode. There must be something else there.


    In case it's a field-PCF, you cannot bind the PCF to lookups for now, but you could bind it to a string property, and change it's value using from scripting (for instance with the id of the lookup). Then the updateView of your PCF will be called, and you can refresh the pcf.
    For a dataset might be a little different, since a dataset cannot accept farther bound properties (only input properties, and they don't change when the lookup changes). But I think you could use form scripting to refresh the subgrid, when the lookup is filled in.

    Hope this helps!

    Kind regards,

    Diana

     

  • mildseven Profile Picture
    8 on at

    It is registered on a string field(LocationName), which is populated when the lookup field (prod_billingaddressid)is populated on the form. When you add a new opportunity record via the opportunities tab in account, it will pop up a new "create form". Because the record doesn't exist yet, we need to populate fields with JS. Once the record is saved, the pcf control shows up no issue. (After you refresh the form)

  • Diana Birkelbach Profile Picture
    3,072 Most Valuable Professional on at

    @mildseven  So you have a script on the opportunity form registered:

    - OnChange of prod_billingaddressid, where you update the LocationName

    - OnLoad where you set the LocatioName based on prod_billingaddressid

    If you did it like this, then the PCF (seems that you have a field-type pcf) should be shown directly (no need to save  or refresh the form).

    You could check on thing:

    You have probably more properties in your manifest. Please double check the the property bound to LocationName is a "bound" one.

    <property of-type="SingleLine.Text" usage="bound" .../>

    Hope this helps!

     

    Kind regards,

    Diana

  • mildseven Profile Picture
    8 on at

    yes it is a bound control-- to the location name which is populated with JS.

  • Diana Birkelbach Profile Picture
    3,072 Most Valuable Professional on at

    Hi @mildseven ,

    In that case maybe it's an issue with the PCF itself.

    Can you please check (with a console.log or using the debugger) if the updateView method of your PCF is called, when the LocaltionName is changed. This should be called, and there your code should refresh the container.


    Hope this helps!

    Kind regards,

    Diana

  • cchannon Profile Picture
    4,702 Moderator on at

    I would bet @DianaBirkelbach just hit the answer there, but just in case your problem is not code that should be in the updateView function and isn't...

     

    The next thing I would look at is the chain of events that leads to your string field getting populated. Are you certain it is getting a value? For instance, if you are populating the lookup on save with script, but you aren't firing the onChange event, then the string wouldn't get a value, even if you have an onChange event associated to the field. Make sure you are getting a value in that string, and if you aren't, consider whether you should be using the fireOnChange message from the clientAPI.

  • mildseven Profile Picture
    8 on at

    Hi,

     

    Diana, It is bound to a  field pcf. it has 2 additional bound properties which are bound to lookups through editing the formXML using formXML Builder in XrmToolBox.

     

    Strangely, it works around 50% of the time. It seems to always have the id's correct in the query i send out, but sometimes it returns 0 records. If it does, saving and refreshing fixes it.

     

    Mystery to me..

  • Diana Birkelbach Profile Picture
    3,072 Most Valuable Professional on at

    Hi @mildseven , 

     

    So it seems you're unsupported, but if you get the ids right, this doesn't seem to be the issue.

    But then I don't understand: since you don't have a dataset PCF, and you make the requests by yourself, then it cannot be an issue with the PCF framework.
    So it's rather an implementation issue. Since you make the requests by yourself, you can log the response on the console. Maybe the rendering doesn't wait until the response is back? Or something similar...

     

     

    Kind regards,

    Diana

     

  • mildseven Profile Picture
    8 on at

    I do log responses. That's how I know sometimes my query returns 0 entities. I think my implementation is fine, as it works 50% of the time on new forms. it works 100% of the time when the record already exists(after save).

  • Diana Birkelbach Profile Picture
    3,072 Most Valuable Professional on at

    Hi @mildseven , 

    You can track the requests in the network protocol, and check which ids are sent when there are no records returned?  If you have the right ids for the request, it cannot be that the number of returned records are not always the same. So maybe sometimes the ids are not the right ones.

    Kind regards,

    Diana

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 534

#2
WarrenBelz Profile Picture

WarrenBelz 416 Most Valuable Professional

#3
Valantis Profile Picture

Valantis 306

Last 30 days Overall leaderboard