cancel
Showing results for 
Search instead for 
Did you mean: 
Reply

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

@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

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').

@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 


@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 

@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

Community will be READ ONLY July 16th, 5p PDT -July 22nd

Dear Community Members,   We'd like to let you know of an upcoming change to the community platform: starting July 16th, the platform will transition to a READ ONLY mode until July 22nd.   During this period, members will not be able to Kudo, Comment, or Reply to any posts.   On July 22nd, please be on the lookout for a message sent to the email address registered on your community profile. This email is crucial as it will contain your unique code and link to register for the new platform encompassing all of the communities.   What to Expect in the New Community: A more unified experience where all products, including Power Apps, Power Automate, Copilot Studio, and Power Pages, will be accessible from one community.Community Blogs that you can syndicate and link to for automatic updates. We appreciate your understanding and cooperation during this transition. Stay tuned for the exciting new features and a seamless community experience ahead!

Summer of Solutions | Week 4 Results | Winners will be posted on July 24th

We are excited to announce the Summer of Solutions Challenge!   This challenge is kicking off on Monday, June 17th and will run for (4) weeks.  The challenge is open to all Power Platform (Power Apps, Power Automate, Copilot Studio & Power Pages) community members. We invite you to participate in a quest to provide solutions in the Forums to as many questions as you can. Answers can be provided in all the communities.    Entry Period: This Challenge will consist of four weekly Entry Periods as follows (each an “Entry Period”)   - 12:00 a.m. PT on June 17, 2024 – 11:59 p.m. PT on June 23, 2024 - 12:00 a.m. PT on June 24, 2024 – 11:59 p.m. PT on June 30, 2024 - 12:00 a.m. PT on July 1, 2024 – 11:59 p.m. PT on July 7, 2024 - 12:00 a.m. PT on July 8, 2024 – 11:59 p.m. PT on July 14, 2024   Entries will be eligible for the Entry Period in which they are received and will not carryover to subsequent weekly entry periods.  You must enter into each weekly Entry Period separately.   How to Enter: We invite you to participate in a quest to provide "Accepted Solutions" to as many questions as you can. Answers can be provided in all the communities. Users must provide a solution which can be an “Accepted Solution” in the Forums in all of the communities and there are no limits to the number of “Accepted Solutions” that a member can provide for entries in this challenge, but each entry must be substantially unique and different.    Winner Selection and Prizes: At the end of each week, we will list the top ten (10) Community users which will consist of: 5 Community Members & 5 Super Users and they will advance to the final drawing. We will post each week in the News & Announcements the top 10 Solution providers.  At the end of the challenge, we will add all of the top 10 weekly names and enter them into a random drawing.  Then we will randomly select ten (10) winners (5 Community Members & 5 Super Users) from among all eligible entrants received across all weekly Entry Periods to receive the prize listed below. If a winner declines, we will draw again at random for the next winner.  A user will only be able to win once overall. If they are drawn multiple times, another user will be drawn at random.  Individuals will be contacted before the announcement with the opportunity to claim or deny the prize.  Once all of the winners have been notified, we will post in the News & Announcements of each community with the list of winners.   Each winner will receive one (1) Pass to the Power Platform Conference in Las Vegas, Sep. 18-20, 2024 ($1800 value). NOTE: Prize is for conference attendance only and any other costs such as airfare, lodging, transportation, and food are the sole responsibility of the winner. Tickets are not transferable to any other party or to next year’s event.   ** PLEASE SEE THE ATTACHED RULES for this CHALLENGE**   Week 1 Results: Congratulations to the Week 1 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Community MembersNumber of SolutionsSuper UsersNumber of Solutions @anandm08  23 @WarrenBelz  31 @DBO_DV  10 @Amik  19 AmínAA 6 @mmbr1606  12 @rzuber  4 @happyume  7 @Giraldoj  3@ANB 6 (tie)   @SpongYe  6 (tie)     Week 2 Results: Congratulations to the Week 2 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Community MembersSolutionsSuper UsersSolutions @anandm08  10@WarrenBelz 25 @DBO_DV  6@mmbr1606 14 @AmínAA 4 @Amik  12 @royg  3 @ANB  10 @AllanDeCastro  2 @SunilPashikanti  5 @Michaelfp  2 @FLMike  5 @eduardo_izzo  2   Meekou 2   @rzuber  2   @Velegandla  2     @PowerPlatform-P  2   @Micaiah  2     Week 3 Results: Congratulations to the Week 3 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge.   Week 3:Community MembersSolutionsSuper UsersSolutionsPower Apps anandm0861WarrenBelz86DBO_DV25Amik66Michaelfp13mmbr160647Giraldoj13FLMike31AmínAA13SpongYe27     Week 4 Results: Congratulations to the Week 4 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge.   Week 4:Community MembersSolutionsSuper UsersSolutionsPower Apps DBO-DV21WarranBelz26Giraldoj7mmbr160618Muzammmil_0695067Amik14samfawzi_acml6FLMike12tzuber6ANB8   SunilPashikanti8

Check Out | 2024 Release Wave 2 Plans for Microsoft Dynamics 365 and Microsoft Power Platform

On July 16, 2024, we published the 2024 release wave 2 plans for Microsoft Dynamics 365 and Microsoft Power Platform. These plans are a compilation of the new capabilities planned to be released between October 2024 to March 2025. This release introduces a wealth of new features designed to enhance customer understanding and improve overall user experience, showcasing our dedication to driving digital transformation for our customers and partners.    The upcoming wave is centered around utilizing advanced AI and Microsoft Copilot technologies to enhance user productivity and streamline operations across diverse business applications. These enhancements include intelligent automation, AI-powered insights, and immersive user experiences that are designed to break down barriers between data, insights, and individuals. Watch a summary of the release highlights.    Discover the latest features that empower organizations to operate more efficiently and adaptively. From AI-driven sales insights and customer service enhancements to predictive analytics in supply chain management and autonomous financial processes, the new capabilities enable businesses to proactively address challenges and capitalize on opportunities.    

Updates to Transitions in the Power Platform Communities

We're embarking on a journey to enhance your experience by transitioning to a new community platform. Our team has been diligently working to create a fresh community site, leveraging the very Dynamics 365 and Power Platform tools our community advocates for.  We started this journey with transitioning Copilot Studio forums and blogs in June. The move marks the beginning of a new chapter, and we're eager for you to be a part of it. The rest of the Power Platform product sites will be moving over this summer.   Stay tuned for more updates as we get closer to the launch. We can't wait to welcome you to our new community space, designed with you in mind. Let's connect, learn, and grow together.   Here's to new beginnings and endless possibilities!   If you have any questions, observations or concerns throughout this process please go to https://aka.ms/PPCommSupport.   To stay up to date on the latest details of this migration and other important Community updates subscribe to our News and Announcements forums: Copilot Studio, Power Apps, Power Automate, Power Pages

Users online (902)