Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Microsoft Dataverse
Unanswered

Custom pcf for 2 same field on form

(0) ShareShare
ReportReport
Posted on by 2
Hello,
I have 2 same optionset fields on the form in my model driven app.. So I created 1 custom pcf control  and tagged to both the same fields.
When I select a value on field 1, field 1's updateview is called, which changes color of the selected option.
But how to call field 2's update view also at that time?
 
Categories:
  • Rashi Malhotra Profile Picture
    2 on at
    Re: Custom pcf for 2 same field on form

    Hi @DeviKrishna, thanks for the approach, means a lot.

    BTW I just realized that my code works properly for the 1st time I update the field, both the fields get updated automatically. But the next time I update the 1st field it updates only that field and not the 2nd one. Any idea why? 

  • Devikumari Krishna Profile Picture
    988 Super User 2024 Season 1 on at
    Re: Custom pcf for 2 same field on form

    Hi @rashi_malhotra 

     

    Please follow these steps

    In your app's form, make sure both Field 1 and Field 2 are using your custom PCF control as their control type.

    By following these steps, when you select a value on Field 1, the custom PCF control's notifyOutputChanged method will be called. It will then update the view for Field 1 based on the selected value and notify Field 2 about the new value, triggering its update view as well. This way, both fields will stay in sync with each other when you interact with the custom control.

     

    Inside your PCF control code, make sure you have defined two properties to hold the values for Field 1 and Field 2:

    //Sample code

    exportinterfaceMyControlProps

    {

    demofield1: number;

    demofield2: number;

    …..

    }

     

    Implement the notifyOutputChanged method in your control. This method will be called whenever a property value changes.

    publicnotifyOutputChanged(inputs: PropertyBag): void

    { // Check if Field 1 value has changed

    if(inputs.hasOwnProperty("demofield1"))

     {

    const demofield1 = inputs["demofield1"] as number;

    this._notifyField2Updated(demofield1);

     }

    Define the _notifyField2Updated method in your PCF control to trigger the update view for Field 2:

    private_notifyField2Updated(newValue: number): void

    {

    valuethis.notifyOutputChanged({ demofield2: newValue });

    }

    -------------------------------------------------------------------------
    If I have answered your question, please mark your post as Solved.
    If you like my response, please give it a Thumbs Up.

    My Blog: Dynamics 365 Key Topics – https://d365topicsbydk.com/

    My YouTube Channel : https://www.youtube.com/channel/UCxSIryP2ah2VpEFr-Z72t1A

     

    Regards
    Devi

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 - Microsoft Dataverse

#1
stampcoin Profile Picture

stampcoin 15

#2
ankit_singhal Profile Picture

ankit_singhal 11 Super User 2025 Season 1

#3
mmbr1606 Profile Picture

mmbr1606 9 Super User 2025 Season 1

Overall leaderboard

Featured topics