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 / ClearCollect. Patch, t...
Power Apps
Unanswered

ClearCollect. Patch, then Defaults ERROR

(0) ShareShare
ReportReport
Posted on by 442

Why I have something is wrong with my formula?

 

ClearCollect(coldropClasses, 'Add and Drop Classes (Drop Courses List)'.AllItems)&ClearCollect(colAddClasses, 'Add and Drop Classes (Add Courses List)'.AllItems);
Patch(
'Add and Drop Course Classes',
Defaults('Add and Drop Course Classes'),
{
'Student Name': User().FullName,
'Drop Course': Index(colDropClasses,1).Title5_25.Text,
'Add Course': Index(colAddClasses,1).Title5_27.Text,
Reason: TextInput2_2.Text

}
)

 Screenshot 2023-11-08 195130.png

Categories:
I have the same question (0)
  • AARON_C Profile Picture
    2,235 Most Valuable Professional on at

    Hi @dylandavis09,

     

    Try this:

     

    ClearCollect(coldropClasses, 'Add and Drop Classes (Drop Courses List)'.AllItems);
    ClearCollect(colAddClasses, 'Add and Drop Classes (Add Courses List)'.AllItems);
    Patch('Add and Drop Course Classes',
     Defaults('Add and Drop Course Classes'),
     {
     'Student Name': User().FullName,
     'Drop Course': Index(colDropClasses, 1).Title5_25,
     'Add Course': Index(colAddClasses, 1).Title5_27,
     Reason: TextInput2_2.Text
     }
    )

     

     

    Please tick Accept as solution if the answer is useful.

    Thanks,

    @AARON_C 

     

  • dylandavis09 Profile Picture
    442 on at

    @AARON_C Not working. 😞 

     

    Screenshot 2023-11-09 112544.png

  • AARON_C Profile Picture
    2,235 Most Valuable Professional on at

    @dylandavis09 

     

    Thats not what I had.

     

    Remove all the .Text bits out of the 'Drop Course' and 'Add Course' columns.

     

    Please tick Accept as solution if the answer is useful.

    Thanks,

    @AARON_C 

  • dylandavis09 Profile Picture
    442 on at

    Ok, I did and still not working. 😭

  • AARON_C Profile Picture
    2,235 Most Valuable Professional on at

    @dylandavis09 

     

    I have tested this, and it works. Please show me how you are implementing this code.

     

    Do you also get any errors now? If you do, please share them too.

     

  • dylandavis09 Profile Picture
    442 on at

    Still error: The type of this argument 'ODats_x0031_stCourse' does not match the expected type 'Text'. Found type 'Error'.

     

    Screenshot 2023-11-09 194805.png

     

    What I have 2 Gallery and 2 Label each Gallery:

    Screenshot 2023-11-09 195330.png

  • AARON_C Profile Picture
    2,235 Most Valuable Professional on at

    Hi @dylandavis09,

     

    I have pretty much created what I could see on your screen. But I have made it to what I think is more logical.

     

    What I have Done:

    I have three tables called Courses, Students, StudentCourses

    AARON_C_0-1699597377506.pngAARON_C_2-1699597434773.png

    AARON_C_3-1699597479328.png

    In my app. Currently there is no courses for student 2 (ST002 Logged in user)

    AARON_C_4-1699597742135.png

    After creating some test data. As you can see only the courses for the student that is logged in can be seen in the gallery (Remove Courses gallery)

    AARON_C_5-1699597930754.png

    Making your changes.

    AARON_C_7-1699598891479.png

    Updating Changes. This clears the galleries on the right hand side and also moves the name of the course from CourseAdd to CourseDrop column.

    AARON_C_8-1699598973413.png

     

    -----------------------------------------------------------------------

    This is the Code focusing on the Student Course galleries

    Remove Course : 

    Filter(StudentCourses, (StudentName = LookUp(Students, StudentName = User().FullName).StudentName) && !IsBlank(CourseAdd))

     

    Review: Drop Course: colDropCourse

    Add Courses: Courses (The courses table)

    Review: Add Course: colAddCourse

     

    For the add icon: Switch the collection name for the Add courses gallery

    Collect(colDropCourse, {CN: ThisItem.CourseAdd, CC: ThisItem.CourseCode})

     

    For the minus icon: Also switch the collection name

    Remove(colDropCourse, ThisItem)

     

    The submit button:

    ForAll(colAddCourse,
     Patch(StudentCourses,
     Defaults(StudentCourses),
     {
     StudentCode: LookUp(Students, StudentName = User().FullName),
     StudentName: User().FullName,
     CourseAdd: CN,
     CourseCode: CC
     }
     )
    );
    Clear(colAddCourse);
    
    ForAll(colDropCourse,
     Patch(StudentCourses,
     LookUp(StudentCourses, StudentName = User().FullName && CourseCode in colDropCourse.CC),
     {
     StudentCode: LookUp(Students, StudentName = User().FullName),
     StudentName: User().FullName,
     CourseDrop: CN,
     CourseCode: CC,
     CourseAdd: ""
     }
     )
    );
    Clear(colDropCourse);
    
    
    

     

    I hope this helps and you can follow what I did.

     

    Please tick Accept as solution if the answer is useful.

    Thanks,

    @AARON_C 

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 April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Vish WR Profile Picture

Vish WR 1,055

#2
Valantis Profile Picture

Valantis 666

#2
11manish Profile Picture

11manish 666

Last 30 days Overall leaderboard