Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Power Apps Pro Dev & ISV
Answered

PCF Control Lookup field is getting update on the form

(0) ShareShare
ReportReport
Posted on by 24

Hi,

 

I am able to select an item from the lookup.  When I select an item my OnSelectItem event is working.

 

I can see the selected data to build the lookup.   But the form is not getting assigned the selected lookup.

public init(context: any, notifyOutputChanged: (value?: IOutputs) => void, state: any, container: HTMLDivElement): void {
        const onItemSelected = (selectedItem: any) => {
            console.log('onItemSelected event triggered');

            try {
                if (selectedItem) {
                    // Set the new value directly
                    const newValue: ComponentFramework.LookupValue[] = [{
                        entityType: "lfs_systemitemgroup",
                        id: selectedItem._lfs_systemitemgroupid_value,
                        name: selectedItem.lfs_systemitemgroupname
                    }];

                    notifyOutputChanged({ lfs_SystemItemGroupId: newValue });
                } else {
                    // Clear the value of the lookup field if nothing is selected
                    //context.parameters.lfs_SystemItemGroupId.raw.setValue(null);
                    notifyOutputChanged({ lfs_SystemItemGroupId: undefined });
                }
                if (selectedItem) {
                    alert("help");
                }
            } catch (error: any) {
                console.error("Error setting lookup field value:", error.message);
            }
        };
  • Verified answer
    a33ik Profile Picture
    3,304 Most Valuable Professional on at
    Re: PCF Control Lookup field is getting update on the form

    NotifyOutputChange doesn't accept any parameters. You have to call it to notify that output changed and put the assigning of the new value to the getOutputs function. You can check an example exactly with the lookup in the following repository - https://github.com/AndrewButenko/LookupToOptionset/blob/main/LookupToOptionset/index.ts

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

🌸 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…

Congratulations to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Power Apps - Power Apps Pro Dev & ISV

#1
WarrenBelz Profile Picture

WarrenBelz 55 Most Valuable Professional

#2
mmbr1606 Profile Picture

mmbr1606 42 Super User 2025 Season 1

#3
Michael E. Gernaey Profile Picture

Michael E. Gernaey 31 Super User 2025 Season 1

Overall leaderboard