cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Colby
Advocate I
Advocate I

Unable to patch collection due to expected type error 'ObjNull'

I have two Power Apps, one is for my development work and the second is the main development app (where we bring in all the changes). This issue only seems to occur on the main dev app and not in mine (I have compared my app a number of times to try spot the differences and they both seem to have the same logic).

 

On a screen in my app I have an OnVisible action that does the following:

 

ClearCollect(
  NameOfCollection,
  {
    FIELD_NAME: Blank(),
    FIELD_NAME2: Blank(),
    FIELD_NAME3: Blank()
  }
);

 

 

The reason I do this is because I want to create a blank collection with the required columns. I need to do this because I use a Patch function (the AddColumns function doesn't work when called via a ForAll from my tests).

 

I then have two buttons. One button is in a gallery (named: UpdateBtn) and the other button (named: Add_Item_Btn) sits outside of the gallery. The Add_Item_Btn is used to call the UpdateBtn button for each item in the gallery.

 

For the Add_Item_Btn, the OnSelect property looks something like this:

 

ClearCollect(
  NameOfCollection,
  CollectionToImport
);

ForAll(
  GalleryName.AllItems As _Items,
  Select(
    GalleryName,
    _Items.Index,
    UpdateBtn
  );
);

 

 

For the UpdateBtn (added to the GalleryName gallery), the OnSelect property looks like this:

 

UpdateContext(
  {
    FIELD_NAME_VAR: LookUp(
      '[dbo].[TableName]',
      UID = ThisItem.UID,
      FIELD_NAME_ID)
  }
);

Patch(
  NameOfCollection,
  ThisItem,
  {
    FIELD_NAME: FIELD_NAME_VAR
  }
);

 

 

The error occurs in the patch call in the UpdateBtn OnSelect property. The error looks something like this:

The type of this argument 'FIELD_NAME' does not match the expected type 'ObjNull'. Found type 'Text'.

 

I have tried to change the Add_Item_Btn OnSelect to have "" instead of Blank() for each column, but that doesn't seem to fix the error.

 

I should also mention that I have simplified this logic to focus specifically on this issue. For example the patch is updating multiple fields in this case.

 

My next steps to try troubleshoot this issue is to try reproduce it in a net new Power App.

1 ACCEPTED SOLUTION

Accepted Solutions
Colby
Advocate I
Advocate I

So it seems this solution sort of solved my issue. I had a bunch of type cast issues. Basically (and not really sure the exact route cause) by passing data from a SQL table to collection and then to another collection, somehow my GUIDs got cast as text. I had to re-cast my GUIDs in my lookups so the types matched and that fixed it. I have no clue why my other app doesn't exhibit this behaviour but at least the issue is fixed. 🙂

View solution in original post

4 REPLIES 4
Colby
Advocate I
Advocate I

So I was able to reproduce this error in a net new app. Attached you will find the msapp file.

Colby
Advocate I
Advocate I

So interestingly I adjusted my initialization of the collection "NameOfCollection" to set each column to "" instead of Blank(). I had tried this previously in my main app but it didn't seem to fix things. Will try give it another shot and update my findings.

 

Below is what I updated the collection to in the Visible screen property.

 

ClearCollect(
  NameOfCollection,
  {
    FIELD_NAME: "",
    FIELD_NAME2: "",
    FIELD_NAME3: ""
  }
);

 

 

Colby
Advocate I
Advocate I

So it seems this solution sort of solved my issue. I had a bunch of type cast issues. Basically (and not really sure the exact route cause) by passing data from a SQL table to collection and then to another collection, somehow my GUIDs got cast as text. I had to re-cast my GUIDs in my lookups so the types matched and that fixed it. I have no clue why my other app doesn't exhibit this behaviour but at least the issue is fixed. 🙂

View solution in original post

alrez
Community Support
Community Support

Hi,

 

Thanks for your follow up post! I am glad that you were able to get this figured out. Hopefully this will prove useful for future communities users.

 

Regards,

 

Alex

 

-------

 

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

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (1,904)