cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Poweruser1101
Helper II
Helper II

Issue with Patch post deployment

Hi All,

 

I am facing an weird issue with the Patch function. I am using an embedded canvas app on the CRM Form.

This is working fine in DEV environment but post deployment it stopped working.

 

Issue - 

1) Open the existing record ,gets the data properly,  modify data and hit save -> data is saved - works fine

2) Modify field values and save again -> data does not save and reloads the previous data

 

Below is the formula applied on 'onDataRefresh' property of ModelDrivenFormIntegration

 

Patch('DataSourceName', ModelDrivenFormIntegration.Item,
{
    'Attribute 1': If(IsBlank(DataCardValue3.Text),Blank(),Value(DataCardValue3.Text)),
     'Attribute 2': If(IsBlank(DataCardValue4.Text),Blank(),Value(DataCardValue4.Text))
}
)

 

Please suggest if i have missed anything, or what could be wrong in this case. 

 

Any help would be appreciated. Thanks in Advance

1 ACCEPTED SOLUTION

Accepted Solutions
poweractivate
Most Valuable Professional
Most Valuable Professional

@Poweruser1101 

 

After you SubmitForm or Patch from the button or wherever you are doing this, you should also use this formula right after:

 

 

ModelDrivenFormIntegration.RefreshForm(true);

 

 

otherwise the host Model Driven form might not refresh automatically after the changes made from inside the Canvas App and still contain the stale data.

 

See if it helps @Poweruser1101 .

 

Also for the OnDataRefresh we usually do not ever Patch over there. In most apps where we do this, we usually refresh the data source if needed (by calling Refresh(DataVerseDataTableDataSource) - reason why is the Model Driven App changes from the form, would have just changed the Dataverse data source, right? Of course this was made outside the Canvas App, so the Canvas App might not know this directly. How to make the Canvas App know this directly, would be that a simple call to Refresh(DataVerseDataTableDataSource) in the OnDataRefresh should result in reflecting those specific kinds of changes that were "technically made outside the Canvas App", inside the Canvas App by using that handy  "OnDataRefresh" property. Check if this simpler approach helps @Poweruser1101 .

 

Besides that, only in some specific cases we might perform any other checks in "OnDataRefresh" - for example in some apps, it is very important if specific Lookup columns in particular that have a relationship with another table, and/or other complex columns have values in them or are left blank and the App does something in response to one or the other - so sometimes we do this kind of re-checking there for some scenarios like that - but other than this we usually do nothing else actually. We definitely not Patch from there (unless perhaps the Patch was maybe to another data source entirely, not the Dataverse one that Model Driven App just changed, for some cases). Please clarify regarding why you have to Patch to the same data source that was just modified by the Model Driven App in case this is your requirement.

 

Keep in mind if your datasource is Dataverse, you do not need and in general should not need to Patch from OnDataRefresh to the same data source that was just sent changes via the hosting Model Diven App form - because model driven apps change that same Dataverse data source too so that may create a paradox or weird behavior. This may be related to those issues you face as well, and also, if that was the issue, it is present in the dev environment too but you may not have performed the same kinds of tests on both environments.

 

See if this helps @Poweruser1101 

View solution in original post

5 REPLIES 5
Anonymous
Not applicable

Hello @Poweruser1101 ,

 

I don't understand why you are doing the patch in the onDataRefresh property. Patch should be used in a button not in the from itself 

Could you please give us more intel about what you are trying to do?

 

Regards,

Akram

Poweruser1101
Helper II
Helper II

Hi @Anonymous  Thank you for responding. Since it is embedded on the crm form, requirement was to save the entered data in the embedded canvas app when the  crm Form Save button is hit, hence placed formula under 'on Data Refresh' property so this way don't need another button, and the save works too.
And the embedded app looks part of the same form

 

Below is the Form  and the embedded canvas inside it -

 

Poweruser1101_1-1608758457539.png

 

The issue is it works perfectly fine in Dev environment, but in Test Environment it behaves wierd.

Scenario -

1) Works well when the value is modified on form for the first time and hit Save

2) For Second time, it does the save twice and re-loads the previous value again

For eg : If i update a fields value from 100 to 200, it does the save twice (found this in audit history)

Update 1 : value changed from 100 to 200

Update 2 : value changed from 200 to 100

 

Not understanding why the save is happening twice which is not the case on DEV environment. If the approach is wrong do let me know, happy to be corrected.

 

Apart from patch, there's only one another formula which is applied on Total field to calculate total - 

 

IfError(

If(IsBlank('Test1 Sales Number_DataCardValue'.Text), 0, Value('Test1 Sales Number_DataCardValue'.Text)) +
If(IsBlank('Test2 Sales Number_DataCardValue'.Text), 0, Value('Test2 Sales Number_DataCardValue'.Text)) +
If(IsBlank('Test3 Sales Number_DataCardValue'.Text), 0, Value('Test3 Sales Number_DataCardValue'.Text)) +
If(IsBlank('Test4 Sales Number_DataCardValue'.Text), 0, Value('Test4 Sales Number_DataCardValue'.Text))

, ThisItem.'Stored Value of the field').

poweractivate
Most Valuable Professional
Most Valuable Professional

@Poweruser1101 

 

After you SubmitForm or Patch from the button or wherever you are doing this, you should also use this formula right after:

 

 

ModelDrivenFormIntegration.RefreshForm(true);

 

 

otherwise the host Model Driven form might not refresh automatically after the changes made from inside the Canvas App and still contain the stale data.

 

See if it helps @Poweruser1101 .

 

Also for the OnDataRefresh we usually do not ever Patch over there. In most apps where we do this, we usually refresh the data source if needed (by calling Refresh(DataVerseDataTableDataSource) - reason why is the Model Driven App changes from the form, would have just changed the Dataverse data source, right? Of course this was made outside the Canvas App, so the Canvas App might not know this directly. How to make the Canvas App know this directly, would be that a simple call to Refresh(DataVerseDataTableDataSource) in the OnDataRefresh should result in reflecting those specific kinds of changes that were "technically made outside the Canvas App", inside the Canvas App by using that handy  "OnDataRefresh" property. Check if this simpler approach helps @Poweruser1101 .

 

Besides that, only in some specific cases we might perform any other checks in "OnDataRefresh" - for example in some apps, it is very important if specific Lookup columns in particular that have a relationship with another table, and/or other complex columns have values in them or are left blank and the App does something in response to one or the other - so sometimes we do this kind of re-checking there for some scenarios like that - but other than this we usually do nothing else actually. We definitely not Patch from there (unless perhaps the Patch was maybe to another data source entirely, not the Dataverse one that Model Driven App just changed, for some cases). Please clarify regarding why you have to Patch to the same data source that was just modified by the Model Driven App in case this is your requirement.

 

Keep in mind if your datasource is Dataverse, you do not need and in general should not need to Patch from OnDataRefresh to the same data source that was just sent changes via the hosting Model Diven App form - because model driven apps change that same Dataverse data source too so that may create a paradox or weird behavior. This may be related to those issues you face as well, and also, if that was the issue, it is present in the dev environment too but you may not have performed the same kinds of tests on both environments.

 

See if this helps @Poweruser1101 

poweractivate
Most Valuable Professional
Most Valuable Professional


@Poweruser1101 wrote:

The issue is it works perfectly fine in Dev environment, but in Test Environment it behaves wierd.

 


About this one, in the production environment go to make.powerapps.com, make sure on upper right the correct environment is selected, and then from the left side go to Data -> Connections. Go ahead and delete all of them that the Canvas App is using. Especially pay attention in case there are duplicates and delete all of them.  Even if there is no duplicate, just delete all of them that the Canvas App is using.

 

What this does is it will reprompt for the permissions. If you are feeling nervous about it, just open the Canvas App in Play mode or Edit mode right after doing this, and it should just simply reprompt for the permissions - this should re-establish the Connections.

 

Check if this helps as well @Poweruser1101 

Poweruser1101
Helper II
Helper II

@poweractivate Apologies was on leave so did not have access to this account. Would really like to thank you for providing a detailed explanation on this. The data on the form is only getting modified via the canvas app and no change is happening through Model Driven Form hence ideally this should work. Since this was working in DEV environment and failing in TEST, I was not understanding why did it work in DEV though then. 

This issue has been raised to microsoft now to look into and I would come back and update here whatever is the reason behind it.

 

As per you suggestion, I did create a button on the canvas app in the TEST environment and moved the patch formula from ondatarefresh property to onselect property of the button and it worked!!Thank you for suggesting this.

Helpful resources

Announcements

Celebrating the May Super User of the Month: Laurens Martens

  @LaurensM  is an exceptional contributor to the Power Platform Community. Super Users like Laurens inspire others through their example, encouragement, and active participation. We are excited to celebrated Laurens as our Super User of the Month for May 2024.   Consistent Engagement:  He consistently engages with the community by answering forum questions, sharing insights, and providing solutions. Laurens dedication helps other users find answers and overcome challenges.   Community Expertise: As a Super User, Laurens plays a crucial role in maintaining a knowledge sharing environment. Always ensuring a positive experience for everyone.   Leadership: He shares valuable insights on community growth, engagement, and future trends. Their contributions help shape the Power Platform Community.   Congratulations, Laurens Martens, for your outstanding work! Keep inspiring others and making a difference in the community!   Keep up the fantastic work!        

Check out the Copilot Studio Cookbook today!

We are excited to announce our new Copilot Cookbook Gallery in the Copilot Studio Community. We can't wait for you to share your expertise and your experience!    Join us for an amazing opportunity where you'll be one of the first to contribute to the Copilot Cookbook—your ultimate guide to mastering Microsoft Copilot. Whether you're seeking inspiration or grappling with a challenge while crafting apps, you probably already know that Copilot Cookbook is your reliable assistant, offering a wealth of tips and tricks at your fingertips--and we want you to add your expertise. What can you "cook" up?   Click this link to get started: https://aka.ms/CS_Copilot_Cookbook_Gallery   Don't miss out on this exclusive opportunity to be one of the first in the Community to share your app creation journey with Copilot. We'll be announcing a Cookbook Challenge very soon and want to make sure you one of the first "cooks" in the kitchen.   Don't miss your moment--start submitting in the Copilot Cookbook Gallery today!     Thank you,  Engagement Team

Announcing Power Apps Copilot Cookbook Gallery

We are excited to share that the all-new Copilot Cookbook Gallery for Power Apps is now available in the Power Apps Community, full of tips and tricks on how to best use Microsoft Copilot as you develop and create in Power Apps. The new Copilot Cookbook is your go-to resource when you need inspiration--or when you're stuck--and aren't sure how to best partner with Copilot while creating apps.   Whether you're looking for the best prompts or just want to know about responsible AI use, visit Copilot Cookbook for regular updates you can rely on--while also serving up some of your greatest tips and tricks for the Community. Check Out the new Copilot Cookbook for Power Apps today: Copilot Cookbook - Power Platform Community.  We can't wait to see what you "cook" up!      

Tuesday Tip | How to Report Spam in Our Community

It's time for another TUESDAY TIPS, your weekly connection with the most insightful tips and tricks that empower both newcomers and veterans in the Power Platform Community! Every Tuesday, we bring you a curated selection of the finest advice, distilled from the resources and tools in the Community. Whether you’re a seasoned member or just getting started, Tuesday Tips are the perfect compass guiding you across the dynamic landscape of the Power Platform Community.   As our community family expands each week, we revisit our essential tools, tips, and tricks to ensure you’re well-versed in the community’s pulse. Keep an eye on the News & Announcements for your weekly Tuesday Tips—you never know what you may learn!   Today's Tip: How to Report Spam in Our Community We strive to maintain a professional and helpful community, and part of that effort involves keeping our platform free of spam. If you encounter a post that you believe is spam, please follow these steps to report it: Locate the Post: Find the post in question within the community.Kebab Menu: Click on the "Kebab" menu | 3 Dots, on the top right of the post.Report Inappropriate Content: Select "Report Inappropriate Content" from the menu.Submit Report: Fill out any necessary details on the form and submit your report.   Our community team will review the report and take appropriate action to ensure our community remains a valuable resource for everyone.   Thank you for helping us keep the community clean and useful!

Community Roundup: A Look Back at Our Last 10 Tuesday Tips

As we continue to grow and learn together, it's important to reflect on the valuable insights we've shared. For today's #TuesdayTip, we're excited to take a moment to look back at the last 10 tips we've shared in case you missed any or want to revisit them. Thanks for your incredible support for this series--we're so glad it was able to help so many of you navigate your community experience!   Getting Started in the Community An overview of everything you need to know about navigating the community on one page!  Community Links: ○ Power Apps ○ Power Automate  ○ Power Pages  ○ Copilot Studio    Community Ranks and YOU Have you ever wondered how your fellow community members ascend the ranks within our community? We explain everything about ranks and how to achieve points so you can climb up in the rankings! Community Links: ○ Power Apps ○ Power Automate  ○ Power Pages  ○ Copilot Studio    Powering Up Your Community Profile Your Community User Profile is how the Community knows you--so it's essential that it works the way you need it to! From changing your username to updating contact information, this Knowledge Base Article is your best resource for powering up your profile. Community Links: ○ Power Apps ○ Power Automate  ○ Power Pages  ○ Copilot Studio    Community Blogs--A Great Place to Start There's so much you'll discover in the Community Blogs, and we hope you'll check them out today!  Community Links: ○ Power Apps ○ Power Automate  ○ Power Pages  ○ Copilot Studio    Unlocking Community Achievements and Earning Badges Across the Communities, you'll see badges on users profile that recognize and reward their engagement and contributions. Check out some details on Community badges--and find out more in the detailed link at the end of the article! Community Links: ○ Power Apps  ○ Power Automate  ○ Power Pages  ○ Copilot Studio    Blogging in the Community Interested in blogging? Everything you need to know on writing blogs in our four communities! Get started blogging across the Power Platform communities today! Community Links: ○ Power Apps  ○ Power Automate  ○ Power Pages  ○ Copilot Studio   Subscriptions & Notifications We don't want you to miss a thing in the community! Read all about how to subscribe to sections of our forums and how to setup your notifications! Community Links: ○ Power Apps  ○ Power Automate  ○ Power Pages  ○ Copilot Studio   Getting Started with Private Messages & Macros Do you want to enhance your communication in the Community and streamline your interactions? One of the best ways to do this is to ensure you are using Private Messaging--and the ever-handy macros that are available to you as a Community member! Community Links: ○ Power Apps  ○ Power Automate  ○ Power Pages  ○ Copilot Studio   Community User Groups Learn everything about being part of, starting, or leading a User Group in the Power Platform Community. Community Links: ○ Power Apps  ○ Power Automate  ○ Power Pages  ○ Copilot Studio   Update Your Community Profile Today! Keep your community profile up to date which is essential for staying connected and engaged with the community. Community Links: ○ Power Apps  ○ Power Automate  ○ Power Pages  ○ Copilot Studio   Thank you for being an integral part of our journey.   Here's to many more Tuesday Tips as we pave the way for a brighter, more connected future! As always, watch the News & Announcements for the next set of tips, coming soon!

Hear what's next for the Power Up Program

Hear from Principal Program Manager, Dimpi Gandhi, to discover the latest enhancements to the Microsoft #PowerUpProgram, including a new accelerated video-based curriculum crafted with the expertise of Microsoft MVPs, Rory Neary and Charlie Phipps-Bennett. If you’d like to hear what’s coming next, click the link below to sign up today! https://aka.ms/PowerUp  

Top Solution Authors
Top Kudoed Authors
Users online (4,952)