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 / How to change the form...
Power Apps
Unanswered

How to change the form field based on condition?

(0) ShareShare
ReportReport
Posted on by

Hello,

 

I have Edit form that changes the data source based on specific condition. and for one of the form fields, I have formula with default property as follows:

 

Switch(varCondition,"True", ThisItem.Workdetail,ThisItem.Title)

 

Where 

ThisItem.Workdetail == field from SP List 1

ThisItem.Title == field from SP List 2

 

However, because current data source value is "SP List 2" for the form, it throws an error for the formula that "function switch has some invalid argument" as ThisItem.Workdetail is not available in "SP List 2"

 

Can you please share how can I resolve this error?

 

Thanks,

 

Categories:
  • BrianS Profile Picture
    2,407 Super User 2024 Season 1 on at

    I would say the issue is that a form is bound to a specific data source and can't have items from several sources. You will either need to create a collection that incorporates the fields you need from both sources and then build the form based on that collection, or not use a form and just create your own data fields and then Patch them to the various data sources.

    Unless you are needing to change the data source of all the fields in the form to the second list. In that case you can create 2 separate forms and have the Switch control the Visible Property of the forms so the correct one will show.

  • Dave Wi Profile Picture
    on at

    I forgot to mention that all SP Lists are having same schema.

     

    Also, I have tried patching value via collection, which did not work - for example, below formula:

     

    Patch(Collection1,{Title:"Test"}); where "Collection1" is identified based on different list of same schema.

     

    Can we specify the collection dynamically?

     

    Thanks,

  • BrianS Profile Picture
    2,407 Super User 2024 Season 1 on at

    If all your lists have the same schema then you should be able to put the Switch in the Data Source of the Form. But you can still only have one source in the form at a time. Your Patch command seems to be missing an indication of the Record you want to Patch, so that could be an issue. 

  • Dave Wi Profile Picture
    on at

    That switch command is not working as I have raised here - How to bind the SP List to Edit form based on the ... - Power Platform Community (microsoft.com)

     

    any clue?

     

    Thanks,

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 382 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 329

#3
WarrenBelz Profile Picture

WarrenBelz 187 Most Valuable Professional

Last 30 days Overall leaderboard