Skip to main content

Notifications

Power Apps - Error Handling
Suggested answer

Formula Error

Posted on 26 Nov 2024 16:05:04 by
I have a few formulas to correct for my app. Basically I have created a popup message for when the user clicks a button. However they are all giving me an error.
 
First set of errors stemming from the argument (false), this is the formula in the Onsuccess of the form: 
The error I receive: "Incompatible type. The formula cannot be evaluated because the types of the context variables are incompatible with the value types in other parts of the app." 
 
Set(varButtonColor; Self.Fill)&  // Reset the button color to its default
Set(varButtonPressed; false)&  // Mark the button as idle
Set(varButtonScale; 1)&        // Reset size to 100%
Set(varButtonTransparency; 1) // Reset transparency to 100%
 
Second set of errors stemming from the argument (true): Set(varButtonPressed; true)
The error I receive: "Incompatible type. The formula cannot be evaluated because the types of the context variables are incompatible with the value types in other parts of the app." 
 
Third set of errors comes from the whole formula:  If(varButtonPressed; RGBA(0; 255; 0; 1); RGBA(255; 255; 255; 1))
The error I receive: "Invalid argument type. One of the following values is expected: Text, Number, Decimal, Date, Time, DateTimeNoTimeZone, DateTime, Boolean, ViewValue, UntypedObject."
 
Fourth set of errors comes from If(varButtonPressed within the formula: Set(varButtonScale; If(varButtonPressed; 1,2; 1))
The error I receive: "Invalid argument type (Error). A Boolean value is expected."

Fifth set of errors is the same as the fourth one with the following formula: If(varButtonPressed within the formula: Set(varButtonTransparency; If(varButtonPressed; 0,8; 1)

The error I receive: "Invalid argument type (Error). A Boolean value is expected."


 
This is the formula in the Onselect of the confirm button:
 
If(
    IsBlank('EasyFLY Form'.LastSubmit);  // Check if the form is new (blank record)
   
   
    EasyTravelFlow.Run(        // If new, create a new record
        Nome.Text;
        Dipartimento.Text;
        Tipologia.Text;
        Text(DateAdd(Data1.SelectedDate; 0; TimeUnit.Hours); "yyyy-mm-dd");
        Ora1.Selected.Value;
        Minuto1.Selected.Value;
        AeroportoPartenza.Selected.Value;
        VoloPartenza.Text;
        Text(DateAdd(Data2.SelectedDate; 0; TimeUnit.Hours); "yyyy-mm-dd");
        Ora2.Selected.Value;
        Minuto2.Selected.Value;
        AeroportoRientro.Selected.Value;
        VoloRientro.Text;
        Value(Costo.Text);
        Value(Int.Text);
        Round.Selected.Value
    );;
);;
    // After submission, reset fields and close the popup
    Set(varButtonPressed; true)&  // Change the button state (to indicate press)
    Set(varTimerRunning; true)&  // Start the timer to reset the effect
    If(varButtonPressed; RGBA(0; 255; 0; 1); RGBA(255; 255; 255; 1))&   // Green when pressed, Neutral when idle
    Set(varButtonScale; If(varButtonPressed; 1,2; 1))&  // Increase size by 20% when pressed, 100% when idle
    Set(varButtonTransparency; If(varButtonPressed; 0,8; 1))&   // Make the button slightly transparent when pressed
    ResetForm('EasyFLY Form')&
    NewForm('EasyFLY Form')&
    Set(varShowPopup; false)  // Close the popup after submission
 
Sixth set of errors comes from the formula in the Onselect of the cancel button: 
 
    Set(varButtonPressed; RGBA(0;100;0;1))&
    // After submission, reset fields and close the popup
    Set(varButtonPressed; true)&  // Change the button state (to indicate press)
    Set(varTimerRunning; true)&
     // Start the timer to reset the effect
    Set(varButtonScale; If(varButtonPressed; 1,2; 1))&  // Increase size by 20% when pressed, 100% when idle
    Set(varButtonTransparency; If(varButtonPressed; 0,8; 1))&  // Make the button slightly transparent when pressed
    ResetForm('EasyFLY Form')&
    NewForm('EasyFLY Form')&
    Set(varShowPopup; false)  // Close the popup after submission
 
I get an error on: RGBA(0;100;0;1))
The error message I receive: "Incompatible type. The formula cannot be evaluated because the context variable types are incompatible with the value types in other parts of the app."
 
I get an error on: Set(varButtonPressed; true) same thing with (true)
The error message I receive: "Incompatible type. The formula cannot be evaluated because the context variable types are incompatible with the value types in other parts of the app."
 
I get an error on: If(varButtonPressed and If(varButtonPressed
The error message I receive: "Invalid argument type (Error). A Boolean value is expected."
 
Seventh set of errors comes from the OnTimerEnd of the timer:
 
Set(varButtonPressed; false)&  // Reset the button appearance after the timer ends
Set(varTimerRunning; false)   // Stop the timer
 
I only get an error on the (false) of: Set(varButtonPressed; false)
The error message I receive: "Incompatible type. The formula cannot be evaluated because the context variable types are incompatible with the value types in other parts of the app."
 
*Ps. The popup screen does not show up after clicking a button called "Add". Thus the record of the form never gets saved onto sharepoint, because none of the elements of the popup screen are visible. 
 
I have included the following formula inside the department field to auto populate it based on the name inserted in the name field, but it doesn't work: 
 
Switch(
    Nome.Text;
    "Name of person"; "Sporting";
    "Name of person"; "Org";
    "Name of person"; "Org.";
    "Name of person"; "Org.";
    "Name of person"; "Sporting";
....
....
    ""  // Default value if no match
)
 
I have included the following formula inside the office type field to auto populate it based on the name inserted in the name field, but it doesn't work: 
 
Switch(
    Nome.Text;
    "Name of person"; "PT";
    "Name of person"; "ST";
    "Name of person"; "ST";
    "Name of person"; "PT";
....
....
    ""  // Default value if no match
)
 
This post is long I know, but all of these formulas have been inserted and written correctly according to chat GPT. Is there anyone that could help me out? Thank You! 
  • Suggested answer
    KeithAtherton Profile Picture
    KeithAtherton 3,565 on 26 Nov 2024 at 16:19:17
    Formula Error
    Hey. Looking at the code, the varButtonPressed global variable is often set to true or false.
     
    However, there is an occasion where it may be set to a color, i.e.:
    Set(varButtonPressed; RGBA(0;100;0;1))
     
    It may be this line which is confusing Power Apps into not knowing if the variable should be a Boolean or a Color.

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

November 2024 Newsletter…

November 2024 Community Newsletter…

Community Update Oct 28…

Power Platform Community Update…

Tuesday Tip #7 Community Profile Tips…

Welcome to a brand new series, Tuesday Tips…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 143,129

#2
RandyHayes Profile Picture

RandyHayes 76,308

#3
Pstork1 Profile Picture

Pstork1 63,797

Leaderboard

Featured topics