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 / Creating an Object in ...
Power Apps
Suggested Answer

Creating an Object in a Table Based on Data Selected in a Form

(1) ShareShare
ReportReport
Posted on by 2
I want to create an object in a table on my PowerApps page using 3 Text Inputs that are connected to two different tables (Appareil and Activité). Additionally, there are two Date Inputs: the first one captures the Month and Year, while the second one captures the Day, Month, and Year. Based on the selected data from these inputs, the object will be created in the respective table.
image.png
I have the same question (0)
  • Suggested answer
    Nandit Profile Picture
    1,568 Moderator on at
     
    When you say you want to create an object, do you mean creating a new record in your Data Source?
    If yes, you can use the following code (modify it based on your control names) and it should create a record -
    ​
    Patch(DataSource,
          Defaults(DataSource), {
          DateColumn: DateControl.SelectedDate
    TextColumn: TextInput.Value
    .
    .
    .
    and so on
    })
    
    ​
    Hope this helps. 
     
    Kind regards, 
    Nandit
     
    If this answers your query, please mark this response as the answer.
    If its helpful, please leave a like. Thanks!
     
     
     
  • Niranjanbabu Chakali Profile Picture
    23 on at
    Hello,

    Here’s a formula for the OnSelect property of the submit button that handles the object creation logic:
     
    // Extract month and year from DatePicker1
    Set(SelectedMonth, Month(DatePicker1.SelectedDate));
    Set(SelectedYear, Year(DatePicker1.SelectedDate));
    // Extract day, month, and year from DatePicker2
    Set(SelectedDay, Day(DatePicker2.SelectedDate));
    Set(SelectedFullMonth, Month(DatePicker2.SelectedDate));
    Set(SelectedFullYear, Year(DatePicker2.SelectedDate));
    // Create object in the Appareil table
    Patch(
        Appareil,
        Defaults(Appareil),
        {
            AppareilName: TextInput1.Text,
            Description: TextInput3.Text,
            MonthYear: DateValue(SelectedMonth & "/01/" & SelectedYear)  // Example format for Month and Year
        }
    );
    // Create object in the Activité table
    Patch(
        Activité,
        Defaults(Activité),
        {
            ActivitéName: TextInput2.Text,
            EventDate: DateValue(SelectedFullMonth & "/" & SelectedDay & "/" & SelectedFullYear)  // Example format for full date
        }
    );
     

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 536

#2
WarrenBelz Profile Picture

WarrenBelz 426 Most Valuable Professional

#3
Haque Profile Picture

Haque 305

Last 30 days Overall leaderboard