web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Power Apps - Patch Sha...
Power Apps
Answered

Power Apps - Patch SharePoint Person column on dropdown OnChange event

(0) ShareShare
ReportReport
Posted on by 2
Hi everyone,
I'm building a Power Apps application connected to a SharePoint list called 'Boitiers KPAX'.
I have a form with a dropdown control (DataCardValue3) that can take two values: "PRIS" or "INSTALLE".
I want to trigger an automatic Patch to the SharePoint list in the OnChange event of the dropdown, depending on the selected value:
• If "PRIS" → write to columns TECH (Person) and RECUPERE (Date/time)
• If "INSTALLE" → write to columns TECH (Person) and INSTALLATION (Date/time)
In both cases, TECH should contain the currently logged-in user (User().Email / User().FullName) and the date/time should be the current moment (Now()).
Technical details:
- The TECH column is a Person type (single person only)
- My Power Apps environment uses French locale (separator: ;)
- I'm using '@odata.type' with #Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser for the Person column
Here is the code I'm currently using:
If(
    DataCardValue3.Selected.Value = "PRIS";
    Patch(
        'Boitiers KPAX';
        ThisItem;
        {
            TECH: {
                '@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser";
                Claims: "i:0#.f|membership|" & User().Email;
                DisplayName: User().FullName;
                Email: User().Email;
                JobTitle: "";
                Picture: ""
            };
            RECUPERE: Now()
        }
    );
    DataCardValue3.Selected.Value = "INSTALLE";
    Patch(
        'Boitiers KPAX';
        ThisItem;
        {
            TECH: {
                '@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser";
                Claims: "i:0#.f|membership|" & User().Email;
                DisplayName: User().FullName;
                Email: User().Email;
                JobTitle: "";
                Picture: ""
            };
            INSTALLATION: Now()
        }
    )
)
Has anyone implemented this kind of logic before? Does the code look correct to you? Any feedback is welcome, thanks in advance!
form1.jpg
form2.jpg
Categories:
I have the same question (0)
  • Suggested answer
    Kalathiya Profile Picture
    2,410 Super User 2026 Season 1 on at
    Hello @CM-17061356-0
     
    Your code looks correct only but just did some twick there..
    With(
        {
            _tech: {
                '@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
                Claims: "i:0#.f|membership|" & Lower(User().Email),
                Department: "",
                DisplayName: User().FullName,
                Email: User().Email,
                JobTitle: "",
                Picture: ""
            }
        };
        If(
            DataCardValue3.Selected.Value = "PRIS";
            Patch(
                'Boitiers KPAX';
                ThisItem;
                {
                    TECH: _tech;
                    RECUPERE: Now()
                }
            );
            DataCardValue3.Selected.Value = "INSTALLE";
            Patch(
                'Boitiers KPAX';
                ThisItem;
                {
                    TECH: _tech;
                    INSTALLATION: Now()
                }
            )
        )
    )

    Another approach could be to avoid Patch in the OnChange altogether and instead set default values directly in the form controls and disable the field.

    TECH Field - Default Selected Item Property field

    If(IsBlank(Parent.Default) && (DataCardValue3.Selected.Value = "PRIS" || DataCardValue3.Selected.Value = "INSTALLE"); 
        {
            '@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser";
            Claims: "i:0#.f|membership|" & Lower(User().Email);
            DisplayName: User().FullName;
            Email: User().Email;
            JobTitle: "";
            Picture: ""
        };
        Parent.Default
    )

    RECUPERE - Default Date 

    If(IsBlank(Parent.Default) && DataCardValue3.Selected.Value = "PRIS";
       Now(); 
       Parent.Default
    )

    INSTALLATION - Default Date

    If(IsBlank(Parent.Default) && DataCardValue3.Selected.Value = "INSTALLATION";
       Now(); 
       Parent.Default
    )
    ---------------------------------------------------------------------------
    Glad it helped 🙂
    If this fixed your issue,
    please click “Does this answer your question?” to mark it as verified so others can find the solution easily.
    A Like 👍 is always appreciated, and I’m around if you need more help @Kalathiya
  • CM-17061356-0 Profile Picture
    2 on at
    Hello @Kalathiya,
     
    Thanks a lot for your answer.
     
    Unfortunately, I still have issues and I cannot test whether it is working.
     
    I chose the second option because the AI agents also indicated that it is more robust.
     
    **************
    ERRORS
    **************
     
    If and IsBlank = invalid arguments 
    Default = invalid name
     
    Best regards, 
    Chris

     
     
    Error install.jpg
    error recup.jpg
    Error Tech.jpg
  • Verified answer
    Kushal_M Profile Picture
    251 Super User 2026 Season 1 on at
     
    Hello @CM-17061356-0
     
    Yes, the approach is correct. The main thing to check is the If() syntax.
     
    Use:
     
    If(
        DataCardValue3.Selected.Value = "PRIS",
        Patch(
            'Boitiers KPAX',
            ThisItem,
            {
                TECH: {
                    '@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
                    Claims: "i:0#.f|membership|" & User().Email,
                    DisplayName: User().FullName,
                    Email: User().Email
                },
                RECUPERE: Now()
            }
        ),
        DataCardValue3.Selected.Value = "INSTALLE",
        Patch(
            'Boitiers KPAX',
            ThisItem,
            {
                TECH: {
                    '@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
                    Claims: "i:0#.f|membership|" & User().Email,
                    DisplayName: User().FullName,
                    Email: User().Email
                },
                INSTALLATION: Now()
            }
        )
    )
     
    Key Points:
    • Person column format (SPListExpandedUser) looks correct.
    • Claims, DisplayName, and Email are sufficient for most SharePoint Person fields.
    • Now() correctly populates Date/Time columns.
    • Ensure ThisItem refers to the record being edited; otherwise use Form1.LastSubmit or LookUp() to target the correct item.
    • Verify that DataCardValue3.Selected.Value actually returns "PRIS" / "INSTALLE" (sometimes it's .SelectedText.Value depending on the control).
  • WarrenBelz Profile Picture
    155,686 Most Valuable Professional on at
    Firstly everything @Kalathiya has posted should work for you  - I will add a couple of things that may be helpful.
     
    You no longer need the odata.type reference - this was changed a couple of years back.
     
    Code below is a bit more condensed and is an alternative
    Patch(
       'Boitiers KPAX';
       ThisItem;
       {
          TECH: 
          {
             Claims: "i:0#.f|membership|" & Lower(User().Email);
             DisplayName: User().FullName;
             Department: "";
             Email: User().Email;
             JobTitle: "";
             Picture: ""
          };
          Switch(
             DataCardValue3.Selected.Value;
             "PRIS";
             {RECUPERE: Now()};
             "INSTALLE";
             {INSTALLATION: Now()}
          )
       )
    };
    I also agree with the principal of using the Update of the Data Cards as another approach - I see that you are creating new records here, but if you were also displaying existing records - for the TECH field
    If(
       YourFormName.Mode = FormMode.New;
       {
          Claims: "i:0#.f|membership|" & Lower(User().Email);
          DisplayName: User().FullName;
          Department: "";
          Email: User().Email;
          JobTitle: "";
          Picture: ""
       };
       ThisItem.TECH;
    );
    The INSTALLE field
    If(
       DataCardValue3.Selected.Value = "INSTALLE" && YourFormName.Mode = FormMode.New;
       Now()
       ThisItem.INSTALLATION;
    )
    and the ECUPERE field
    If(
       DataCardValue3.Selected.Value = "PRIS" && YourFormName.Mode = FormMode.New;
       Now();
       ThisItem.RECUPERE
    )
     
    Please Does this answer your question 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 answering Yes to Was this reply helpful? or give it a Like
    Visit my blog
    Practical Power Apps    LinkedIn  
     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Valantis Profile Picture

Valantis 463

#2
WarrenBelz Profile Picture

WarrenBelz 364 Most Valuable Professional

#3
11manish Profile Picture

11manish 275

Last 30 days Overall leaderboard