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 / App had 0 errors when ...
Power Apps
Answered

App had 0 errors when last saved, but shows many errors after reopening with only one difference in a record Patch

(0) ShareShare
ReportReport
Posted on by 143

Hello everybody,

 

I am having a hard time trying to figure out why I am having this problem:

  • I have an app that, before it is saved from the development/studio environment, it shows 0 errors
  • But if I exit the development page and reopen the app for editing, now it shows many errors related with a record

 

I was able to narrow down to one line of code that generates the problem:

  • If that line of code IS NOT present in the code, then if I save and exit, and then  reopen the app, it shows 0 errors
  • If that line of code IS present in the code, when I save it, it shows 0 errors, but when I exit and reopen to edit it, it shows many errors

 

Thay are all related with a record (regItemObr) that I use to read from a table (tblOfertasObras) and also in a form.

 

In different parts of the program I have the following sentences related with the record:

UpdateContext( { regItemObr: LookUp( TblOfertasObras, IDObra = frmCMOfeObra.LastSubmit.IDObra ) } );
UpdateContext( { regItemObr: Patch( TblOfertasObras, regItemObr, { FechaEscritura: Now(), ActualizadoPor: TXT_USER_EMAIL } ) } );
UpdateContext( { regItemObr: Blank() } );
UpdateContext( { regItemObr: LookUp( TblOfertasObras, IDOferta = varOfertaID ) } );
UpdateContext( { regItemObr: Patch( TblOfertasObras, Defaults(TblOfertasObras), { IDOferta: varOfertaID, CreadoPor: TXT_USER_EMAIL } ) } );

 

And then I have the "offending" line of code:

UpdateContext( { regItemObr: Patch( regItemObr, { ObraNombre: "" } ) } );

 

As mentioned before:

  • when I save the app, it shows 0 errors
  • but if I exist and reopen the app for editing, I get many errors
  • and the referenced table field (ObraNombre) is indeed a valid field in the record and table

 

And the error related with the "offending" line is "Invalid argument type (Error). Expecting table instead", but many other lines show an error (see some sample below).

 

Can you think of any reason why that simple line can generate such error.

 

vllanso_0-1661968347086.png

vllanso_1-1661968862952.png

 

 

Thanks, Victor.

Categories:
  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @vllanso 

    Yes!  What is the entire formula that the error is in?

     

    PowerApps constantly has to infer the schema of any records in your app.  It can get confused quickly when you try to manipulate the columns of the record like you are.  More importantly is the order of operations of those functions.  When the app is first opened, it has to look through the entire app formulas and try to determine what the schema of the record will be.  If it sees functions that change only one column, it can start to infer that it only has that column.  It's kind of hard to type out exactly what that process is, but suffice to say, this can happen quickly and turn things bad.  Many times this happens when you are building your formulas and then, once the editor has inferred the schema incorrectly, it "sticks" until you close and re-open the app.  However, this also happens the other way, which is to say that as you alter your app, it "builds" the schema it thinks it should be based on your changes and then all works fine when you are editing.  Then you close the app and re-open and it doesn't work - why?  Because there was some edit that you made previously that it "used" in its inference and now it doesn't exist - so when it attempts to re-evaluate the schema, it cannot.

     

    Hopefully this makes some sense and is helpful for you.

  • vllanso Profile Picture
    143 on at

    Hello @RandyHayes !

     

    thanks for your quick response. 

    Now I can understand why it is happening ... but unfortunately I am not sure how to solve it.

     

    Is there a way to "help" powerapps to infer the correct schema ? 

    As mentioned, the "offending" formula is just:

    UpdateContext( { regItemObr: Patch( regItemObr, { ObraNombre: "" } ) } );

     

    thanks again, Victor.

  • Verified answer
    RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @vllanso 

    Yes, that might be the "part" of the formula that is a problem, but it depends on the entirety of the formula that it is in.

    From your image of the error, it appears that there is much more to the formula than just that line.  And, it would make a difference as to where in the formula the function exists.  

    In other words, as PowerApps tries to infer the schema, the order of operations that determine that schema are paramount.  

  • vllanso Profile Picture
    143 on at

    Thanks again @RandyHayes .

     

    I started "playing around" with your idea of the importance of the order of the formulas to help PowerApps to determine the schema and found out that, if I include the following formula in very begining of the OnVisible method of the screen, then after saving and reopening the app, the errors went away.

    If( 1 > 2,
    UpdateContext( { regItemObr: LookUp( TblOfertasObras, IDObra = -1 ) } );
    );

     

    So many thanks for your ideas !!

     

    Regards, Victor.

  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @vllanso 

    Yes, just be cautious with the manipulation of the schemas and how the app needs to infer its columns.  Best to keep things as simple as possible so that the formula editor can infer without confusion.  Those things sometimes creep up later on, like at play time.  

    Glad it helped!

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 Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 248 Super User 2026 Season 2

#2
WarrenBelz Profile Picture

WarrenBelz 192 Most Valuable Professional

#3
Mohsin Ali Profile Picture

Mohsin Ali 135

Last 30 days Overall leaderboard