1
votes

I am working on a small COVID screening app. I have 2 lists in a single Sharepoint site:

BasicInfo:

  • ID (autogenerated by Sharepoint)
  • Name
  • Company

PersonalInfo:

  • BasicInfoID (a Lookup field to BasicInfo.ID)
  • Personal Phone
  • Personal Address
  • Company Phone
  • Company Address

All fields in both lists are required.

Creating the Powerapp, the BasicInfo form works as expected - records are populated in the Sharepoint list, and I can access the ID generated with BasicInfo.LastSubmit.ID after submission.

On the second screen of the app, I am having a hard time getting the "BasicInfoID" field populated. I am expecting to be able to set the value of BasicInfoID on the 2nd screen, then hide it, so the end user doesn't need to see (or populate) the value.

I have tried:

Setting the default value to BasicInfo.LastSubmit.ID, but I get an error of "Expected Record Value. The property on this control expects Record values. The rule produces Number values which are incompatible."

If I set the default value to BasicInfo.LastSubmit (no .ID), the form oddly submit - but the resulting data in the Sharepoint list doesn't show any value in the "BasicInfoID" field - it lists it as Required Info.

If I remove the automatically generated BasicInfoID field, I obviously get an error of "BasicInfoID: Field "BasicInfoID" is required."

I have added a Text field, assigned the DataField value to "BasicInfoID", set the default value to BasicInfo.LastSubmit.ID, but the form fails with the same error (BasicInfoID: Field "BasicInfoID" is required).

Thanks in advance!

1

1 Answers

0
votes

When you do a LookUp from one SPO list (1) to another (2), the schema of the field in the list 1 is the same as the one returned by the Choices function. So in your scenario you can use this expression:

BasicInfoID: LookUp(Choices(BasicInfo, Id = BasicInfo.LastSubmit.ID))

The post at https://powerapps.microsoft.com/en-us/blog/default-values-for-complex-sharepoint-types/ has some more detailed information about using complex columns in SharePoint (such as LookUp ones).

Hope this helps.