Power Apps Exchange

Please login or click SIGN UP FOR FREE to create your PowerAppsUG account to join this user group.
 View Only
Expand all | Collapse all

Patch works in edit mode, but not in normal (published) mode

  • 1.  Patch works in edit mode, but not in normal (published) mode

    Posted Feb 16, 2022 04:54 PM

    Hi all,

    I have a scenario where users can select a contact person from a gallery (items from a SharePoint list called Activities). The Activities list contains a person field (ContactName), so when the user selects a contact, I populate a global variable called gblSelectedRecentContact with the information from the ContactName field (claims, displayname, and email) .

    Set(gblSelectedRecentContact,ThisItem.ContactName)

    I then use gblSelectedRecentContact in a patch statement (on a different screen) to write the selected contact to a person field in a different SharePoint list:

    Requester:
    {
       '@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
       Claims: gblSelectedRecentContact.Claims,
       Department: "",
       DisplayName: gblSelectedRecentContact.DisplayName,
       Email: gblSelectedRecentContact.Email,
       JobTitle: "",
       Picture: ""
    }


    This all works just fine when I have the app in edit mode, but it fails when I run the published app because, for some reason, the user specific portion of the claims string is being stripped out. As a result, I get the following error:

    The requested operation is invalid. Server Response: Activities failed: The specified user i:0#.f|membership| could not be found.

    I have gone so far as to create separate variables to house the claims, displayname, and email (rather than storing them as a record in the single gblSelectedRecentContact variable), but that didn't solve the problem either. I also tossed some labels on the screen with the submit button (where the patch statement is) to show the variable contents to make sure I wasn't somehow losing the contents between screens (the labels show the correct claims, etc.)

    So – my question – why does this work flawlessly when the app is in edit mode (everything patches correctly), but fails when it is run normally?

    Thanks for any help,
    Joel



    ------------------------------
    Joel Roetzer
    Managing Principal
    Hudson
    ------------------------------


  • 2.  RE: Patch works in edit mode, but not in normal (published) mode

    Posted Feb 17, 2022 08:00 AM
    I've had some issues patching person fields before (not exactly what you are describing with it working in edit vs. published mode), and what I've found is that I had to manually construct the value for the claims by concatenating like this:

    Claims: "i:0#.f|membership|" & Lower(varUser.Mail)

    In this case I was getting the user information from the O365Users connector so its varUser.Mail instead of varUser.Email.

    Based on the error you are getting, it looks like the email portion of the Claims is being stripped out, so maybe this will work for you.

    ------------------------------
    Gary Stewart
    SharePoint Consultant
    6103213516
    ------------------------------