BACKGROUND
As an fyi: I'm working in a data card in an edit form, where I've dropped some new controls, which may be part of my problem here.
I've set up an "Attach" button to find a record in my data source and turn it into a "child ticket" of the currently displayed "parent ticket" in the edit form. I do this by referencing an integer typed in a text box and using that value to search the "parent" data source for a matching record & patching that record to the secondary "child" data source. I'm using this in combination with a PowerAutomate flow to migrate correlating files in a Sharepoint Documents Library, and it has worked great so far.
After the patch function is complete, I want to delete the child record from the primary "parent" data source, so it only exists in the child data source. To prepare for this, I wrote a basic "Remove" function by itself, applied to its own button, to test the Remove function on its own and make sure it does what I expect. No problems this way.
THE PROBLEM
For some reason, when I copy and paste the working Remove function to the end of the code on my Attach button, the Edit form refreshes and reloads with a different record in the data source--the pattern seems to be that it's loading the last record in the data source, possibly because the gallery that the edit form loads from is sorted that to have most recent items on top. So if I was working with Record ID 1 and tried to attach Record ID 3 to it, PowerApps correctly filters & patches a copy of Record 3 to the secondary data source with Record 1 as its parent, and even correctly removes Record 3 from the primary database. But then suddenly the edit form populates all the datacards with the data from Record ID 5 (if that's the latest entry).
Again, this does not happen if I put the remove function separately on its own button--when Remove is by itself on its own button, it deletes the target record and stays on the record I've been working with. How can I add Remove() to my Attach button, and not have it suddenly change records on me after the removal is complete?
Here's my code:
Note that I've tried moving the Remove function to different points of the code, after the Patch. If it comes after the line where the Flow has been triggered, then it doesn't work at all--it'll just navigate to that other record and not remove it. If it comes before the Flow has been triggered, it does remove the record correctly, but like I indicated before will also load a different record.
Solved! Go to Solution.
I found a way to work around this by moving most of the functions out of the scope of the form.
The data card still has the main "attach" button, but the button now only creates variables to pass the current item's ID and the visibility of the pop up:
UpdateContext
(
{
varCurrentItemID: ThisItem.ID,
varShowAttachPopup: true
}
);
I created an "Are you sure?" pop up for the user to confirm whether or not they want to attach the record. The pop up is ordered so that it's on the top of the screen and outside the scope of the Edit form. Almost all the code that used to be on the OnSelect() property of my datacard's "Attach" button is now on the OnSelect() of this pop up's "OK" button. It now correctly deletes the record and does not repopulate the Edit form with a different record.
Hi @elemenopi
I believe the issue is the order of execution. I assume you have Editform on this screen. Patch command does not guarantee to complete before the next statement. So the best approach is to move some of the code.
Please move the below code to the OnSuccess Property of Edit form
//Prep variables for upcoming Flow
UpdateContext
(
{
varChildAttachmentsID: Text(txtSearchSimilarTicketID.Text),
varParentAttachmentsID: Text(ThisItem.ID)
}
);
//Remove matching "child record" from "parent" data source
Remove
(
'Incidents',
First
(
Filter
(
'Incidents',
ID = Value(txtSearchSimilarTicketID.Text)
)
)
);
//Flow moves Sharepoint files from Child to Parent folder
Incident_MergeSPFolders.Run(varParentAttachmentsID,varChildAttachmentsID);
Reset(txtSearchSimilarTicketID);
Refresh(Incidents_Attachments);
Note: I haven't changed any code
Thanks for the tip. A question: I have other data cards on this edit form with customized buttons. If one of those other buttons runs successfully, will that "Call" this OnSuccess() property on the edit form too--and therefore do I need to come up with a way to make sure it's not running this Flow during unrelated button presses?
Edit: I tried a couple variants on this concept--moving the entire section recommended, moving just the Remove(), etc. And unfortunately it does not seem to work. If I move the Remove() to the OnSuccess() property, it no longer removes the record as needed. Because of the suggestion that it could be the timing on the Patch(), I moved the Remove() to go after the collection but before the Patch()--it still populates with a different record when I do that.
Hi @elemenopi
Looks like something I missed when responding. Anyway, still, the problem is the order of execution. We need to handle it on the save button, but will take some action if the previous save is successful.
In this example, using collection "colResult" to get the result of the patch. And further steps will proceed if the patch is successful by comparing Total records = No of records success
//Store searched record in collection
ClearCollect
(
colSearchedTicket,
LookUp
(
colAllTickets,
ID = Value(txtSearchSimilarTicketID.Text)
)
);
//Patch record in a collection to the child data source
Clear(colResult);
Collect(
colResult,
ForAll
(
colSearchedTicket As MyRecord,
Patch
(
'Incidents - Child Tickets',
Defaults('Incidents - Child Tickets'),
{
Title: MyRecord.Title,
'Prospect Company': MyRecord.ProspectCompany,
Persona:MyRecord.Persona,
Description:MyRecord.Description,
Comments:MyRecord.Comments,
'Parent ID':varCurrentItemID,
intIncrement:MyRecord.ID
}
);
)
);
If(
CountRows(colResult) = CountRows(colSearchedTicket),
//Prep variables for upcoming Flow
UpdateContext
(
{
varChildAttachmentsID: Text(txtSearchSimilarTicketID.Text),
varParentAttachmentsID: Text(ThisItem.ID)
}
);
//Remove matching "child record" from "parent" data source
Remove
(
'Incidents',
First
(
Filter
(
'Incidents',
ID = Value(txtSearchSimilarTicketID.Text)
)
)
);
//Flow moves Sharepoint files from Child to Parent folder
Incident_MergeSPFolders.Run(varParentAttachmentsID,varChildAttachmentsID);
Reset(txtSearchSimilarTicketID);
Refresh(Incidents_Attachments);
,
Notify("Request was not submitted", Notification.Failure)
)
Thank you. I will try this in the future--I found a different solution this time.
I found a way to work around this by moving most of the functions out of the scope of the form.
The data card still has the main "attach" button, but the button now only creates variables to pass the current item's ID and the visibility of the pop up:
UpdateContext
(
{
varCurrentItemID: ThisItem.ID,
varShowAttachPopup: true
}
);
I created an "Are you sure?" pop up for the user to confirm whether or not they want to attach the record. The pop up is ordered so that it's on the top of the screen and outside the scope of the Edit form. Almost all the code that used to be on the OnSelect() property of my datacard's "Attach" button is now on the OnSelect() of this pop up's "OK" button. It now correctly deletes the record and does not repopulate the Edit form with a different record.
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!
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
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.
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