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

When patching from a Collection to Dataverse the Lookup value does not save/upload

Hey everyone,

 

Due to the needs of my company, I am creating an offline first app. The data is saved into a collection and when the user has internet or phone service, they can sync the collections back to dataverse.

The issue I am having is with a lookup column. I have two tables (System Materials and System Materials History), where System Materials History has a lookup column with System Materials information. The data can save when downloaded to the collections, can be added to the collection using information of the System Material collection, but will not upload the lookup to DataVerse when it is sync'd.

 

I have tried a basic collection and patch to no avail. I am using a ForAll because I am uploading multiple records at once.

The closest I have gotten is 

Screenshot 2021-02-09 100036.png

 

Unfortunately the LookUp is just the first Material (Material-00000) every time. Even when the actual offline Lookup refers to the correct record. 

 

Thank you all so much for the help in advance. 

 

Above the code pictured is the code for patching the System Materials and it works perfectly, so the actual data to be looked-up is there.

1 ACCEPTED SOLUTION

Accepted Solutions
Bob_Bland
Frequent Visitor

Bit of an update: I have gotten it to partially work

Screenshot 2021-02-18 155851.png

 

By changing the column name it patches the correct lookup IF the parent item has been uploaded to Dataverse before this sync and is recognized as an existing option choice in dataverse.

In other words, when a user logs in for the first time and has their data come from Dataverse to their collection, then they can patch existing System Materials and System Materials History, but if they create the parent System Material offline and try to patch a System Material History item of the same name, they get the "Value must be a data entity record" error when syncing. 

This leads me to believe that for a lookup to work in Dataverse, there is something I cannot or am not adding to the record in my collection. 

View solution in original post

10 REPLIES 10
v-jefferni
Community Support
Community Support

Hi @Bob_Bland ,

 

Would you like to patch a LookUp field to Dataverse?

 

If so, to patch LookUp column, the right syntax would be as follows:

Patch('SP list', Default('SP list'), {LookUpColumn: LookUp(Choices('SP list'.LookUpColumn),Value = "Test Value")})

 

On your end, it could be:

{'Material LookUp': LookUp(Choices([@SystemMaterials].'Meterial Name'),Value = ThisRecord.'Material Name')
}

 

Please have a try and hope this helps.

 

Best regards,

Community Support Team _ Jeffer Ni
If this post helps, then please consider Accept it as the solution to help the other members find it.

Community Support Team _ Jeffer Ni

If this post helps, then please consider Accept it as the solution to help the other members find it.

Hey @v-jefferni 

 

Thank you for your reply. 

Yes I am trying to patch a lookup field to dataverse from a collection.

 

 

I tried your solution and it looks like it wants to work, but I am still getting an issue with the data. Now it is saying that I am missing a column and the schema of the record is incorrect.

 

Screenshot 2021-02-11 093550.png 

 

Would I need to DropColumn somewhere before?

Thanks again for the help.

 

 

Hi @Bob_Bland ,

 

There is one extra opening parenthesis next to LookUp, meanwhile a closing parenthesis at last is missing.

 

Please just replace your 'Material LookUp' sentence with everything inside the curly braces in my formula:

{'Material LookUp': LookUp(Choices([@SystemMaterials].'Meterial Name'),Value = ThisRecord.'Material Name')
}

 

Best regards,

Community Support Team _ Jeffer Ni
If this post helps, then please consider Accept it as the solution to help the other members find it.

 

Community Support Team _ Jeffer Ni

If this post helps, then please consider Accept it as the solution to help the other members find it.

Hello @v-jefferni , 

 

I replaced the lookup with what you said and am still getting the error issue. 

If I go to settings and turn on explicit column selection could that help anything?

From what I understand the Owner lookup is a default lookup in the dataverse tables, but it is not referenced in my app anywhere. 

Screenshot 2021-02-12 092500.png

 

 

Thanks for your help

Hi @Bob_Bland ,

 

My bad, did not notice it is Dataverse in your case.

 

So, try below:

LookUp(Choices([@SystemMaterials].'Meterial Name'),'Meterial Name' = ThisRecord.'Meterial Name')

 

Best regards,

Community Support Team _ Jeffer Ni
If this post helps, then please consider Accept it as the solution to help the other members find it.

Community Support Team _ Jeffer Ni

If this post helps, then please consider Accept it as the solution to help the other members find it.

Bob_Bland
Frequent Visitor

Hello @v-jefferni 

 

Unfortunately I am still having issues. 

When I put in the code you suggested I still have the errors with locating the lookup and having the name be recognized 

 

Screenshot 2021-02-15 115328.png

 

I tried the same code but using the system material history as the lookup base and got a result that had no errors, but when I ran the code, the system couldn't find the "property" as shown below.

 

Screenshot 2021-02-15 114620.png

 

Screenshot 2021-02-15 114658.png

 

Thanks for your continual help in this. I feel as though I am missing something obvious because I can't seem to make lookups work when going from collection to dataverse. 

Hi @Bob_Bland ,

 

Could you please double check the table name of Dataverse? Since I have noticed that table names in both Patch and Defaults functions are showing in Black which indicates they are not correct:

130.png

 

Best regards,

Community Support Team _ Jeffer Ni
If this post helps, then please consider Accept it as the solution to help the other members find it.

Community Support Team _ Jeffer Ni

If this post helps, then please consider Accept it as the solution to help the other members find it.

Bob_Bland
Frequent Visitor

Hello @v-jefferni 

 

The table name is correct. All of my Patches go to the right table in dataverse and are all black when nestled in a ForAll statement.  

The actual tables and patching still work completely normal for my other tables. Its only Lookups data columns from collection to dataverse that aren't uploading correctly. 

Bob_Bland
Frequent Visitor

Bit of an update: I have gotten it to partially work

Screenshot 2021-02-18 155851.png

 

By changing the column name it patches the correct lookup IF the parent item has been uploaded to Dataverse before this sync and is recognized as an existing option choice in dataverse.

In other words, when a user logs in for the first time and has their data come from Dataverse to their collection, then they can patch existing System Materials and System Materials History, but if they create the parent System Material offline and try to patch a System Material History item of the same name, they get the "Value must be a data entity record" error when syncing. 

This leads me to believe that for a lookup to work in Dataverse, there is something I cannot or am not adding to the record in my collection. 

Helpful resources

Announcements
Ignite 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Power Apps Africa Challenge 2022

Power Apps Africa Challenge

Your chance to join an engaging competition of Power Platform enthusiasts.

Users online (1,502)