I have a record of type Job that I am storing in a variable _SelectedJob. It is set my clicking on an item in a gallery of all Jobs, with Set(_SelectedJob, ThisItem).
Job has a lookup column Part, which in turn has multiple fields including "Part Number", "Drawing Number", etc.
I want to access those internal fields of the Part, which works fine upon selection from the gallery; PowerApps recognizes those fields are being used in controls with expressions like _SelectedJob.Part.'Drawing Number' and populates the respective field.
However, if I want to change the Part the job is running (for example with a dropdown whose items are [@Parts]), I expected to be able to do something like:
Set(
_SelectedJob,
Patch(
[@Jobs],
_SelectedJob,
{Part: PartDropdown.Selected}
)
)
However, while this runs perfectly fine and the field is set in the backend on the Job upon run, the variable now does NOT populate the fields of Part correctly, and they are all blank besides the GUID. Does the Patch() statement do this as an optimization? Why does it not do the same field-checking that the first Set() statement does to see which fields of _SelectedJob are accessed?
I am very much trying to avoid having sidecar variables like _SelectedJobPart, as the part can be changed in multiple ways.