cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Serviced2000
Helper III
Helper III

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?

 

Thanks!

24 REPLIES 24
HemantG
Power Apps
Power Apps

This is helpful, thanks for sharing the details. 

 

So you are just using the option set and lookup as additional parameters and not trying to use the same control for both types as I thought earlier. 

 

This does seem to be a bug and we will investigate.  Seems there is some special handling for salesOrganization  property which is interfering - might be formXML treatment.

 

HemantG_0-1627418293917.png

 

Hemant 

 

 


@HemantG wrote:

So you are just using the option set and lookup as additional parameters and not trying to use the same control for both types


Exactly. I've just rechecked the behaviour and checklist is now always null while salesOrganization has the correct formatted value but many more properties only the dataset normally has like below. It's mixed up when using a lookup. Didn't try using the lookup as the first property yet.

checklist:

checklist:
attributes: {}
error: false
errorMessage: null
formatted: null
isPropertyLoading: false
raw: null
security: {}
type: null

salesOrganization:

salesOrganization: n
addColumn: ƒ ()
allowFilterOff: true
attributes: {DisplayName: "Sales Organizsation", LogicalName: "tvd_salesorganizationid", Type: "lookup", IsSecured: false, RequiredLevel: 0, …}
availableViewIds: ""
clearSelectedRecordIds: ƒ ()
columns: (2) [{…}, {…}]
dependentAttributeName: ""
dependentAttributeType: "account"
disableQuickFind: true
enableViewPicker: false
entityDisplayCollectionName: "Sales Organizations"
error: false
errorCode: undefined
errorMessage: null
executeNotifyHandlersThatEventOccurred: ƒ ()
filterRelationshipName: ""
filtering: {aliasMap: {…}, getFilter: ƒ, setFilter: ƒ, clearFilter: ƒ, canDisableRelationshipFilter: ƒ}
formatted: "Germany"
generateAdditionalAttributes: ƒ ()
getAllViews: ƒ ()
getCellImageInfo: ƒ ()
getDataSetParameter: ƒ ()
getDefaultViewId: ƒ ()
getLookupConfiguration: ƒ ()
getRecentItems: ƒ ()
getSelectedRecordIds: ƒ ()
getTargetEntityType: ()=>r
getTitle: ()=>i
getViewId: ()=>t
innerError: null
isPropertyLoading: false
linking: {addLinkedEntity: ƒ, getLinkedEntities: ƒ, clear: ƒ, removeLinkedEntity: ƒ}
loading: true
notifications: null
openDatasetItem: ƒ ()
paging: {pageNumber: 1, totalResultCount: 0, firstPageNumber: 1, lastPageNumber: 1, pageSize: 25, …}
raw: [s]
records: {}
refresh: ()=>{i(this,this.contextToken)}
runPreSearch: ()=> {…}
security: {secured: false, editable: true, readable: true}
sendLookupRequest: ƒ ()
setMyRecordsOnlyFilter: ƒ ()
setRelatedFilter: ƒ ()
setSelectedRecordIds: ƒ ()
sortedRecordIds: []
sorting: []
targetEntityType: "tvd_salesorganization"
type: "Lookup.Simple"
useMainFormDialogForCreate: undefined
useMainFormDialogForEdit: undefined

Thank you!

DianaBirkelbach
Super User
Super User

Hi @Serviced2000 , @tvd_nzi 

 

The combination of dataset and bound field PCFs doesn't work in model-driven apps. 

The combination of dataset and input field PCFs works

That means that you get the value of the input fields, but you are not notified if the value of the field changes; you get only the value in the beginning. I have an older blog where I refer to this too: https://dianabirkelbach.wordpress.com/2020/06/14/features-of-a-dataset-pcf-2/

Last year when I've tried to customize such a control on a form, I could do it but I couldn't save the form customization. Since a while we cannot even find the control in the list of controls for the form.

 

But, I've heard that the combination of the dataset and bound fields works in Canvas Apps. If that's right, I can understand that the manifest allows us to define this combination.

 

Not sure if there is a workarround for the problem for now. Maybe working with the input parameter and use form scripting to refresh the PCF if the lookup changes. 

 

Hope this helps!

 

Kind regards,

Diana

 

Kind regards,
Diana
----------
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."


@DianaBirkelbach wrote:

The combination of dataset and bound field PCFs doesn't work in model-driven apps. 

The combination of dataset and input field PCFs works.



Last year when I've tried to customize such a control on a form, I could do it but I couldn't save the form customization. Since a while we cannot even find the control in the list of controls for the form.

This is what I've observed too. OptionSet as input works, Lookup.Simple as input doesn't work, cannot register the pcf control anymore unless I change the lookup property to unbound but then the issues arise which I've documented in my last post.

Let's see what time brings.

 

Thanks for your input and best regards,

David

DianaBirkelbach
Super User
Super User

Hi @tvd_nzi , 

Another workarround (not so sure how supported that would be) could be:

 - make a separate Lookup PCF (it doesn't have to show something, it will just get the changes when the Lookup changes)

 - use window.postMessage from inside the Lookup PCF, and attach to the message from inside the dataset PCF. That way you should be able to get  notified about the change of the Lookup.

I have a blog about using postMessage to simulate events: Can PCFs communicate? – Dianamics PCF Lady (wordpress.com). It should work, because both PCFs should be on same window, but as I said, I'm not so sure if it's supported.

 

Hope this helps!

 

Kindn regards,

Diana

Kind regards,
Diana
----------
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."

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Users online (1,572)