web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Custom pcf for 2 same ...
Power Apps
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?
 
I have the same question (0)
  • Devikumari Krishna Profile Picture
    988 Super User 2024 Season 1 on at

    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

  • Rashi Malhotra Profile Picture
    2 on at

    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? 

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 717 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 329 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard