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 Apps
Answered

Error code in app.

(1) ShareShare
ReportReport
Posted on by 14
I am making an app for a school in which there is a screen to add students to the record. The code gave no errors untill i tried to add a student. The code i used is the following:
If(
    IsBlank(txtStudentName) || IsBlank(cmbStudentClass.Selected),
    Notify("❌ Please enter student name and select a class.", NotificationType.Error),
 
    Patch(
        Students,
        Defaults(Students),
        {
            Title: txtStudentName,
            Class: {
                '@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
                Id: cmbStudentClass.Selected.ID,
                Value: cmbStudentClass.Selected.Title
            }
        }
    );
 
    Notify("✅ Student added successfully!", NotificationType.Success);
    Reset(txtStudentName);
    Reset(cmbStudentClass)
)
Categories:
I have the same question (0)
  • Suggested answer
    Fredrik_A Profile Picture
    3,644 Super User 2026 Season 1 on at
    See my response in your other thread.
     
    You are using the control as input but need to define ".Text" on txtStudentName
  • Verified answer
    MS.Ragavendar Profile Picture
    7,431 Super User 2026 Season 1 on at
     
    Patch(
            Students, // Syntax Correct - DataSource
            Defaults(Students), // Syntax Correct - Defaults(DataSource) used for New Item Creation 
            {
                Title: txtStudentName,// Wrong Syntax
     
             }
    )
     
    Assume txtStudentName is mapped to the control text box named as txtStudentName If the onchange event of text box is written Set(vartxtStudentName,txtStudentName.text) then you can pass the Title : vartxtStudentName but here Title Column is expecting Text Value but you are passing control value hence casting of objects is not happening so powerapps throwing the error.
     
    Correct one
    Title: txtStudentName.Text,
    or 
    Using variable get the data 
    Set(vartxtStudentName,txtStudentName.text)
     
    Title: vartxtStudentName,
     
     
    ✅If this helped, please Accept as Solution to help others ❤️ A Like is appreciated 🏷️ Tag @MS.Ragavendar for follow-ups.
  • Ahmad Ali Profile Picture
    14 on at
    Thanks for your help.

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 424

#2
WarrenBelz Profile Picture

WarrenBelz 355 Most Valuable Professional

#3
11manish Profile Picture

11manish 290

Last 30 days Overall leaderboard