cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
PHaringsNL
Frequent Visitor

Server Response: Object must implement IConvertible

Hi Community,

 

I hope you are able to help me out, because I need to get this working before next week.

 

I'm currently making an App of where information can be viewed by Students and edited by Instructors & Admins. 

It keeps making I problem with something of an IConvertible. I have refreshed sources, rebooted, re-entered the code and I'm all out of Community Pages and Google Searches.

 

My code is as follows:

 

Patch(dimCourses, ThisItem, {Title:CourseTitle2, Instructor_temporarily: CourseInstructor2, Description: CourseDescription2, IDClass: Dropdown1.Selected.IDClass})

 

 

Does anyone know how to fix this? 

 

As an added bonus I want my code to be conditional so that based on the IDClass it will be a new line or Update an existing.

 

If you need any more info, please let me know. And thank you in advance for the effort.

2 ACCEPTED SOLUTIONS

Accepted Solutions
PowerAddict
Super User
Super User

Follow these steps and see if it helps:
1. Save and Close the editor
2. Reopen the editor and either refresh the data source or remove it and add it back
3. Some questions about your code:
Patch(dimCourses, ThisItem, {Title:CourseTitle2, Instructor_temporarily: CourseInstructor2, Description: CourseDescription2, IDClass: Dropdown1.Selected.IDClass})
Are these variables: CourseTitle2, CourseInstructor2, CourseDescription2?

The conditional logic should be easy, we can get to it once we resolve this issue.

---
If you like this reply, please give kudos. And if this solves your problem, please accept this reply as the solution.

Thanks!
Hardit Bhatia
https://www.thepoweraddict.com

View solution in original post

If I correctly understood your problem, DropDown1 has on item property a list of existing class and a field for new class (to be created). If you select an existing class you update data for this class and if you select new class a new record will be created.

 

I guess your problem can be solved like this:

If(Dropdown1.Selected.IDClass in dimCourses.IDClass,
       Patch(dimCourses, ThisItem, {Title:CourseTitle2.Text, Instructor_temporarily: 
       CourseInstructor2.Text, Description: CourseDescription2.Text, IDClass: 
       Dropdown1.Selected.IDClass}),
       Patch(dimCourses, defaults(dimCourses), {Title:CourseTitle2.Text, Instructor_temporarily: 
       CourseInstructor2.Text, Description: CourseDescription2.Text, IDClass: 
       Dropdown1.Selected.IDClass})

 

 Please give it a try ! Thx !

View solution in original post

7 REPLIES 7
PowerAddict
Super User
Super User

Follow these steps and see if it helps:
1. Save and Close the editor
2. Reopen the editor and either refresh the data source or remove it and add it back
3. Some questions about your code:
Patch(dimCourses, ThisItem, {Title:CourseTitle2, Instructor_temporarily: CourseInstructor2, Description: CourseDescription2, IDClass: Dropdown1.Selected.IDClass})
Are these variables: CourseTitle2, CourseInstructor2, CourseDescription2?

The conditional logic should be easy, we can get to it once we resolve this issue.

---
If you like this reply, please give kudos. And if this solves your problem, please accept this reply as the solution.

Thanks!
Hardit Bhatia
https://www.thepoweraddict.com

Hi Hardit,

 

I've tried the first 2 steps a few times over, but without result. I already tried it before, but hey, who knows...

 

The CourseTitle2 etc are TextInput Fields that are normally deactivated, but active if you press a pensil button. And the submit happens on the push of the accept button.

If CourseTitle2 is a TextInput field, try CourseTitle2.Text and similarly for all other fields.

Let me know if that helps.

---
If you like this reply, please give kudos. And if this solves your problem, please accept this reply as the solution.

Thanks!
Hardit Bhatia
https://www.thepoweraddict.com

If CourseTitle2 and the other one are TextInput controls, you should refer to its value as CourseTitle2.Text.

 

Please modify your code accordingly.

 

Patch(dimCourses, ThisItem, {Title:CourseTitle2.Text, Instructor_temporarily: CourseInstructor2.Text, Description: CourseDescription2.Text, IDClass: Dropdown1.Selected.IDClass})

Ok, 

 

Strangely enough..... It started to work. Tried everything for 2 weeks, went nuts, whaha. THANKS!! I have faith again.

 

Ok now the conditionals. Could you also help with that?

 

 

I would do something like this:

If(Dropdown1.Selected.IDClass = "VALUE",
Patch(dimCourses, ThisItem, {Title:CourseTitle2.Text, Instructor_temporarily: CourseInstructor2.Text, Description: CourseDescription2.Text, IDClass: Dropdown1.Selected.IDClass}),
Patch(dimCourses, Defaults(dimCourses), {Title:CourseTitle2.Text, Instructor_temporarily: CourseInstructor2.Text, Description: CourseDescription2.Text, IDClass: Dropdown1.Selected.IDClass}))

TEST was just an example. You can replace it with whatever value you want to check for IDClass.

Let me know if this helps.

---
If you like this reply, please give kudos. And if this solves your problem, please accept this reply as the solution.

Thanks!
Hardit Bhatia
https://www.thepoweraddict.com

If I correctly understood your problem, DropDown1 has on item property a list of existing class and a field for new class (to be created). If you select an existing class you update data for this class and if you select new class a new record will be created.

 

I guess your problem can be solved like this:

If(Dropdown1.Selected.IDClass in dimCourses.IDClass,
       Patch(dimCourses, ThisItem, {Title:CourseTitle2.Text, Instructor_temporarily: 
       CourseInstructor2.Text, Description: CourseDescription2.Text, IDClass: 
       Dropdown1.Selected.IDClass}),
       Patch(dimCourses, defaults(dimCourses), {Title:CourseTitle2.Text, Instructor_temporarily: 
       CourseInstructor2.Text, Description: CourseDescription2.Text, IDClass: 
       Dropdown1.Selected.IDClass})

 

 Please give it a try ! Thx !

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (5,671)