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

Incompatible Type_Setting and Using Variables

I am having an issue using and setting variables in my app for User Onboarding. When a Job Title is selected, other parts of the app should be auto populated. I successfully accomplished this with one Job Title and one Auto-populated field (see below)

Demo Edit View_15Five_Yes.JPG15Five_DataCard.JPG

Formula / Setting Variables

New Form_Formula_Variables.JPG

15Five DefaultSelectedItems Property

15Five_DefaultSelectedItems.JPG

 

A couple things go wrong when I make additions . . .

 

When I attempt to declare new variables (as I've done in the above successful attempt), I get the incompatible type error. 

- Set Variable

varCDriver_Set_Variable.JPG

Set variable on DataCardValue

varCDriver_Incompatible Type_OnChange.JPG

Issue Details

varCDriver_Issue Details.JPG

 

1) What changes need to be made to auto-populate other fields based on a Job Title Selection?

2) Why does the "Incompatible Type Error" appear when I try to add other Job Titles to the Variable?

Adding Job Titles.JPG

3) As I build more logic, does all of the variables need to be declared in the same place (new form / button formula)?

1 ACCEPTED SOLUTION

Accepted Solutions

Thanks everyone for the responses and recommendations, we have solved the problem. There was a second variable declaration that was throwing the error. One of the columns I had listed was a question, "Drive Access Required?" and there were 5 options. 

 

Ultimately, there were three properties that needed to be changed:

  • OnVisible [Form Screen 1]
  • OnChange [Child Dropdown]
  • DefaultSelectedItems [Child Dropdown]
    • Depending on the parent source, additional configuration will be needed

 

Sample Code Below

 

Form Screen 1 Entry

Set(varDriveAccessRequired,["A", "B", "C", "N", "X"]);

OnChange Property

Switch(DataCardValue19.Selected.Value,"A",
Set(varJobTitle,"Accounts Payable Specialist"),"B",
Set(varJobTitle,"Accountant II"),"C",
Set(varJobTitle,"Accounting Intern"),"X",
Set(varJobTitle,"Accounts Payable Specialist II"),"N")

DefaultSelectedItems​ Property


Switch(varJobTitle, "Accounts Payable Specialist",
First(varDriveAccessRequired),
"Accountant II", Last(FirstN(varDriveAccessRequired,2)),
"Accounting Intern", Last(FirstN(varDriveAccessRequired,3)),
"Accounts Payable Specialist II",Last(varDriveAccessRequired))

View solution in original post

5 REPLIES 5
Super User III
Super User III

@AutoSol 

The incompatible type error occurs when the type of value stored in a SET variable is inconsistent across the app.  Your SET variable can only be one of these types, not both

 

  • Number
  • Text
  • Date
  • Boolean (true/false)
  • Record 
  • Table (all columns must be of the same name and type throughout)

 

In your app you have varJobTitle

  • "Accounts Payable Specialist" (Text)
  • ["Accounts Payable Specialist", "Accountant II"] (Table)

 

You could make the data types consistent by doing this.

  • ["Accounts Payable Specialist"] (Table)
  • ["Accounts Payable Specialist", "Accountant II"] (Table)

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

Hey @mdevaney 

 

Thanks for your reply. 

When I hover over each Job title: ["Accounts Payable Specialist", "Accountant II"], each show as "Text" even though they are written in the "Record" syntax. How can I force my app to recognize this entry: ["Accounts Payable Specialist", "Accountant II"], as a record vs "text"?

@AutoSol 

If you hover over the entire ["Accounts Payable Specialist", "Accountant II"] it should recognize as a Table.

 

(Sorry I said record earlier but meant table)

Community Support
Community Support

HI @AutoSol ,

Based on the issue that you mentioned, I think you have faced Incompatible error with your formula. The varJobTitle variable you initialized before in your app is a Text value variable, but then you update this variable with a Table value, which is not Incompatible.

Note: You must update a variable with Incompatible value as initialized before.

 

In addition, the ["Accounts Payable Specialist", "Accountant II"] formula would be recognized as a Table value rather than record in PowerApps app.

 

Based on the needs that you mentioned, I think it is not necessary to set up variables to store the default value for other fields in your Edit form. On your side, you could consider populate other fields in your Edit form directly based on the selected value within the Job Title ComboBox.

 

I have made a test on my side, please consider take a try with the following workaround:

Set the DefaultSelectedItems property of 15Five Needed? ComboBox to following:

{
  Value: If(
            JobTitleComboBox.Selected.Value = "AccountsPayableSpecialist",
            "Yes",
            JobTitleComboBox.Selected.Value = "Accountant II",
            "No"
         )
}

or

{
  Value: Switch(
                JobTitleComboBox.Selected.Value,
                "AccountsPayableSpecialist", "Yes",
                "Accountant II","No"
         )
}

Similar formula would be applied to other Choice field ComboBoxes within the Edit form.

 

Please consider take a try with above solution, check if the issue is solved.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thanks everyone for the responses and recommendations, we have solved the problem. There was a second variable declaration that was throwing the error. One of the columns I had listed was a question, "Drive Access Required?" and there were 5 options. 

 

Ultimately, there were three properties that needed to be changed:

  • OnVisible [Form Screen 1]
  • OnChange [Child Dropdown]
  • DefaultSelectedItems [Child Dropdown]
    • Depending on the parent source, additional configuration will be needed

 

Sample Code Below

 

Form Screen 1 Entry

Set(varDriveAccessRequired,["A", "B", "C", "N", "X"]);

OnChange Property

Switch(DataCardValue19.Selected.Value,"A",
Set(varJobTitle,"Accounts Payable Specialist"),"B",
Set(varJobTitle,"Accountant II"),"C",
Set(varJobTitle,"Accounting Intern"),"X",
Set(varJobTitle,"Accounts Payable Specialist II"),"N")

DefaultSelectedItems​ Property


Switch(varJobTitle, "Accounts Payable Specialist",
First(varDriveAccessRequired),
"Accountant II", Last(FirstN(varDriveAccessRequired,2)),
"Accounting Intern", Last(FirstN(varDriveAccessRequired,3)),
"Accounts Payable Specialist II",Last(varDriveAccessRequired))

View solution in original post

Helpful resources

Announcements
News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

Power Apps Community Call

Power Apps Community Call- January

Mark your calendars and join us for the next Power Apps Community Call on January 20th, 8a PST

PP Bootcamp Carousel

Global Power Platform Bootcamp

Dive into the Power Platform stack with hands-on sessions and labs, virtually delivered to you by experts and community leaders.

secondImage

Power Platform Community Conference On Demand

Watch Nick Doelman's session from the 2020 Power Platform Community Conference on demand!

Top Solution Authors
Top Kudoed Authors
Users online (4,042)