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 / Different behavior of ...
Power Apps
Unanswered

Different behavior of the control depending on the type of the form - Create/Update

(0) ShareShare
ReportReport
Posted on by 3,306 Most Valuable Professional

I work on field-type control and based on the scenario it has to behave differently depending on the type of form:

For the create form scenario control has to be disabled. For the update form scenario it has to be enabled.  Here is the code that works:

if (context.page.entityId == null) {
//Code for create
} else {
//Code for update
}

Here is the problem - when I create a record and save it control is not re-rendered so "Create" scenario control is shown. Is there any trick I'm not aware of to make it work? 

@OOlashyn @DynamicsNinja you did attachments-viewer controls. How did you solve that scenario?

I have the same question (0)
  • Danish N. Profile Picture
    186 on at

    For the control to get re-render updateView should get invoked. That happens when any of the bounded propery changes or notifyOutputChanged is invoked.

    Not sure how you have your property bound but if the value of the attribute that is bound changes on save then the control will render or alternatively you can invoke notifyOutputChanged as stated earlier and make sure the output value is getting changed.

     

    Hope that helps.

  • a33ik Profile Picture
    3,306 Most Valuable Professional on at

    @PowerMaverick thanks for your prompt reply! I use field (and property to which field is bound) as a placeholder and I don't touch the field in my code at all. The whole implementation of my control is similar to following one - https://github.com/DynamicsNinja/PCF-Carousel-Control/blob/master/CarouselControl/index.ts it just works with "Connection" records using WebApi.

    Because I'm not touching the field and field is not changed via platform - updateView and init are not called.

     

    I got the idea to investigate. Field that is changed during create and it's possible to bind to is createdon. On the "Create" form value will be null. For the "Update" it will be changed so that should trigger re-rendering.

  • Verified answer
    ScottDurow Profile Picture
    1,039 on at

    Hey @a33ik 

     

    Some of my controls do a similar thing - but rather than being disabled they have to do some operations after the record has been saved (like creating related records etc.)

     

    I get updateView called with entityId in the list of context.updatedProperties when the the record is saved.

    Other interesting things you can get from this is when the user switches tabs or resizes the windw - you get an updateView called with layout in the context.updatedProperties.

  • ScottDurow Profile Picture
    1,039 on at

    if (context.page.entityId == null) {
    //Code for create
    } else {
    //Code for update
    }

    It's also worth nothing that apparently the way to get the entityId is using:

    context.mode.contextInfo.entityId

    See https://powerusers.microsoft.com/t5/PowerApps-Component-Framework/Access-Page-Context-within-a-component/m-p/362492/highlight/true#M879

  • a33ik Profile Picture
    3,306 Most Valuable Professional on at

    @ScottDurow , thanks! That's what I needed.

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