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 / using switch function ...
Power Apps
Unanswered

using switch function to submit data from a form to a specific sharepoint list based on user name

(0) ShareShare
ReportReport
Posted on by 133

Hello 

 

Trying to achieve:

- submit form data (in this case 'data entry form' created using the edit form linked to sharepoint list) to another specific sharepoint list depending on the user. I am trying to use the Switch Function to make this work but am running into " the operation is invalid error message".... 

 

OnSelect code for form submit button is:

Switch(User().FullName,
"Person 1", 'Form 1';
"Person 2", 'Form 2';
"person 3", 'Form 3');
SubmitForm('data entry form');
Notify("Your form has been submitted, thank you", NotificationType.Information, 3000);
NewForm('data entry form')

 

Newbie - so would not be surprised if reinventing the wheel with this .... all help much appreciated! 

Categories:
  • mmbr1606 Profile Picture
    14,629 Super User 2026 Season 1 on at

    hey @BaseHQ 

     

    please try this approach:

     

    Set(varFormToSubmit, 
     Switch(User().FullName,
     "Person 1", 'Form 1',
     "Person 2", 'Form 2',
     "Person 3", 'Form 3',
     'Default Form' // Default case if none of the names match
     )
    );
    
    If(
     !IsBlank(varFormToSubmit),
     SubmitForm(varFormToSubmit);
     Notify("Your form has been submitted, thank you", NotificationType.Information, 3000);
     NewForm(varFormToSubmit),
     Notify("Error: Form not found", NotificationType.Error, 3000)
    );

     

    Remember that the user names must match exactly, including case sensitivity. Also, ensure that 'Form 1', 'Form 2', etc., are the correct names of the forms in your app.

     

    Let me know if my answer helped solving your issue.

    If it did please accept as solution and give it a thumbs up so we can help others in the community.



    Greetings

  • mmbr1606 Profile Picture
    14,629 Super User 2026 Season 1 on at

    @BaseHQ 

     

    normally this should work if u ask me:

     

    Switch(
     User().FullName,
     "Tony Farrar", SubmitForm(Form_HerzliaSIRegister), // Form for Tony's SharePoint list
     "Willie Breedt", SubmitForm(Form_RavineSIRegister), // Form for Willie's SharePoint list
     "Steven Scott", SubmitForm(Form_KobusSIRegister), // Form for Steven's SharePoint list
     // Add more cases as needed
     SubmitForm(Form_Default) // A default form if user doesn't match any case
    );

     

     

    if its not one thought is that names do not match with the office365users connector

     

    The User().FullName function retrieves the full name of the current user as registered in your Office 365 environment. Ensure that the names you're using in your condition match exactly with how they appear in Office 365, including spaces and case sensitivity. Sometimes, the way names are recorded in Office 365 might not match your expectations (e.g., "Tony Farrar" vs. "Anthony Farrar").

  • BaseHQ Profile Picture
    133 on at
    SubmitForm(Form_HerzliaSIRegister)

    this part of the code is telling powerapps what form to send right? but the screen only has one form (called site instruction form) how does the code know where to send the data based on user id?

  • BaseHQ Profile Picture
    133 on at

    sorry for being a pain

  • v-qiaqi@microsoft.com Profile Picture
    Microsoft Employee on at

    Hi @BaseHQ,

    Have you solved your problem?

    Based on your description, you want to save data from a form to another SP list, right?

     

    Actually, you refer to different form name in your Switch() function, so others thought you want to submit different forms.

    To be honest, I am confused of what exactly you want to achieve😂

     

    If you want to save form data to different SP list, you need to use Patch() function:

    Patch(List_name,
    Defaults(List_name),
    {Field1:control_name.Text,
    ...
    }
    )

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 Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 381 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 340

#3
WarrenBelz Profile Picture

WarrenBelz 187 Most Valuable Professional

Last 30 days Overall leaderboard