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

Patching O365 Users in a Collection to then patch back to SharePoint List

Hi all. I've build an app with a repeating table in a gallery that allows for inline editing of a number of actions (new rows, deleting rows and editing rows) and an overall "Save Changes" to patch back to SharePoint list once done , roughly based on Shane Young / PowerApps 911 solution: https://www.youtube.com/watch?v=xgznk4XlPCo

 

However, I've gone beyond what Shane demonstrates in that my solution works with a People picker combo box and a Person / Group column in the SharePoint list.

dw909_3-1660841845341.png

The fields shown in the Power App match those of my SharePoint List. (Action Description is in fact a renamed "Title" column in SharePoint List).

For the inline changes - i.e. editing an item, and temporarily saving the change in the app, or for adding a new line item and temporarily saving in the app, I'm working with a Collection. The Collection itself is pulling data from the SharePoint list, so consequently my People information form O365 is presented within the Collection as a table of data (call it "ActionOwner"):

Claims     Department    DisplayName    Email    JobTitle     Picture

The "Claims" is in the format of i:0#f|membership|firstname.lastname@company.com

 

For the items already saved in my gallery this is of course fully populated ok. Now, if I want to add a new item in my gallery in a new blank row, or I want to edit an existing entry, either editing the person to be someone else, or perhaps just editing another field, I need to update the collection. I have been unable to work out how to actually patch the ActionOwner table within my Collection.

I did do a workaround of creating some additional columns in my Collection to capture Display Name and Email address and then use those to patch the SharePoint list. I found that creating a new entry or modifying the person field when editing an existing entry I could write both the Display Name and the Email address to these new columns, and then use these to patch the SharePoint list. Oddly whilst it worked, the system displays an annoying error: The requested operation is invalid. Server Response <SharePoint List Name> failed. The specified user i:o#f|membership| could not be found. Monitoring with the app showed a Network "createRow" Bad Request 400 error. I think it was finding that for some of my patching there was no email address which is required for the claims - and because the gallery contains always a blank row I assume it might have been because of that. I also noted that if I edit a row in the app but don't change the Action owner (person) then only the Display Name of the person would be added to the additional column for the Display Name in the collection, and the email isn't captured. It only gets captured if you remove the person in the combo box, then search for them again.

I've tried lots of ways to sort out the issues, but every single method I follow from these forums seems to result in one or more errors - most recently with my current syntax I get Network error when using patch function, the requested operation is invalid and in fact it's not even saving to SharePoint now.

 

I think rather than patching Display Name and Email address to these additional columns in the Collection, what I really need to do is have a way to update the actual ActionOwner table within my collection:

dw909_4-1660843020327.png

Then I need the syntax to patch from this Collection back to the SharePoint list. I suspect this is the only way to avoid all these patching areas related to people.

Any ideas anyone? 

Currently my inline save icon has an OnSelect of:

Patch(ActionCollection, ThisItem, {Title: TextInput3_1.Text, ActionOwner: ComboBox3_1.Selected.DisplayName, ActionOwnerEmail: ComboBox3_1.Selected.Mail, 'Action Status': Dropdown2_1.Selected, 'Target Date' : DatePicker1_1.SelectedDate, 'Associated ID' : BrowseGallery2.Selected.ID}); 

 

My overall Save Changes button has this syntax:

//Edit Existing Record
ForAll(ActionCollection As EditAction, Patch('SharePointList', LookUp(''SharePointList',ID = EditActionID), {Title: EditAction.Title, 'Action Status': EditAction.ActionStatus, 'Target Date': EditAction.TargetDate, 'Action Owner':{
'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
Department:"",
Claims:"i:0#.f|membership|"& Lower(EditActionRTPOwner.Email),
Email:"",
DisplayName:EditAction.ActionOwner,
JobTitle:"",
Picture:""
}
}));


//Add New Record
ForAll(ActionCollection As EditAction If(IsBlank(EditAction.ID), Patch(''SharePointList, Defaults('SharePointList'), {Title: EditAction.Title, 'Action Status': EditAction.ActionStatus, 'Target Date': EditAction.TargetDate, 'Action Owner':{
'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
Department:"",
Claims:"i:0#.f|membership|"& Lower(EditAction.ActionOwner.Email),
Email:"",
DisplayName:EditAction.ActionOwner,
JobTitle:"",
Picture:""
}
,'Associated ID': BrowseGallery2.Selected.ID})));

 

Really feel like I'm going round in circles here so any help would be greatly appreciated!! Many thanks!

3 REPLIES 3

You don't need to do a Patch to update your collection. You can use an UpdateIf() to do that.

UpdateIf(
    ActionCollection,
    ID = ThisItem.Id,   // Pull ID from Current Gallery Item
    {
        Title: EditAction.Title,
        ActionStatus: ThisItem.ActionStatus.Selected.Value,
        TargetDate: ThisItem.TargetDate.SelectedDate,
        ActionOwner:
        {
            '@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
            Department: "",
            Claims: "i:0#.f|membership|"& Lower(ThisItem.RTPOwner.Email),
            Email: Lower( ThisItem.RTPOwner.Email ),
            DisplayName: ThisItem.ActionOwner,
            JobTitle: "",
            Picture: ""
        }
    }
);

You would call this from the row Save to update an item in your collection. For creating an item, is there a new button? Upon clicking New you can use Collect(...) to add a new entry to your collection.  Set ID to -1, add another property to your collection called "InternalId" that you can use for lookups. Set it to Max( InternalId ) + 1.  When loading your list into the collection set Internal Id equal to Id.

You can then trigger a "New" record based on ID being "-1". Otherwise, they are just updates.

 

A SharePoint People column needs the following structure to save the data to the column.  Also, the user must be a valid O365 user with access to SharePoint. The structure is as follows, which you appear too already be aware of.

{
    '@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
    Department:"IT",
    Claims: "i:0#.f|membership|[User UPN]",
    Email: "Email address",
    DisplayName: "John Doe",
    JobTitle: "Developer",
    Picture: Blank()
}

 

Some Questions

  1. What is RTPOwner?
  2.  

 

For your Reference

I will mention one thing for future reference.  The Claim ID is not based on email it is based on the users UPN (User Principal Name). Now, very often they are the same, but not always. If you are using the email address, it is possible that the users email, and UPN are not the same.  This is a stretch, but something to look at.

 

I hope this help.

 

Regards,

-S

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Regards,

-S

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Thanks for the super fast response @sperry1625  - in answer to your question 1, the SharePoint list has effectively two names for the same column. I renamed the display name of the column but the original name still exists behind the scenes (in the URL for example). I'll try out your UpdateIf and see how I get on! Really appreciate your detailed reply!

Hi again @sperry1625  - not doing very well here at all with the syntax you provided for the OnSelect of the Save icon when editing a line. 

 

 ID = ThisItem.Id,   // Pull ID from Current Gallery Item

It doesn't like ".Id" - it doesn't complain if I type it as ID

  Title: EditAction.Title,

It doesn't like this syntax either. The "EditAction" comes from  the overall Save icon of all the edited lines which patches to SharePoint list (the final step) where I have a ForAll(ActionCollection As EditAction, Patch(  - as this is a step before the "EditAction" is not yet recognised, so I assume here I need to use Title: ActionCollection.Title instead?

 

 ActionStatus: ThisItem.ActionStatus.Selected.Value,

It's not happy about this either - throws an error Name isn't valid. 'Selected' isn't recognized.

If I modify this to ActionStatus: ThisItem.ActionStatus.Value I get a new error Incompatible type. The 'Action Status' column in the data source you're updating expects a 'Record' type and you're using a 'Text' type.

TargetDate: ThisItem.TargetDate.SelectedDate,

Problems here too - error is Invalid use of '.'  If I change to TargetDate: ThisItem.TargetDate, it at least seems happier

 

Other errors also coming up:

  1. Invalid argument type. Expecting a Record value, but of a different schema.
  2. Missing column. Your formula is missing a column 'DisplayName' with a type of 'Invalid'.
  3. The function 'UpdateIf' has some invalid arguments.

Not sure if it helps you to know the following:

  • The Items property of the Gallery is set as ActionCollection
  • There is no concept of a button for a new row - the repeating table always has a blank row like this:

dw909_0-1660861954471.png

When you enter something in this blank row and hit the little save icon, a new blank row is automatically created. (If you follow through Shane's videos [he did 3 in this series] the concept basically tracks whether or not the edit button is pressed - got this extra syntax on the end of the OnSelect:

If(EditPressed, false, Collect(ActionCollection, {Title: "", ActionOwner: "", ActionOwnerEmail: "", ShowSaveButtons:true})); UpdateContext({EditPressed: false}); Set(NeedsSaved, false)

(note I also append a ,ShowSaveButtons:false} as part of the above syntax for editing)

 

Not sure if this is making any sense at all to you, but I'd appreciate your further thoughts! Thanks!

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 (647)