I was watching the latest YT video by Shane Young where was demontsrated that you can (undocumented) patch a whole collection in one go to a table. I started experimenting and found it works if I use the "non display" names of the fields. If anything in field names or datatype my code does not correspond with the actual table I get an error (curly brackets) in the patch function.
Alas I also found that I am not able to provide the right data to put into a lookup field. F.e. my table dierevent has a lookup field protocol ("cra27_protocol" as its non display name is) referring to the dataverse table protocol. So if I have a variable named ProtocolToRun (record of the table protocol) and want to include it in the patch I would expect to provide the field/column cra27_protocol and assign a reference to this record to this to make it work. But even if I assign Blank() to cra27_protocol I get the curly brackets signifying I have broken the magic patch collection spell. No way around this I suppose?
Collect(
ParameterProtocolLines
;ShowColumns(
AddColumns(
RenameColumns(
Filter(
CurrentProtocolLines
;LineRegelType=[@ProtocolRegelTypen].'446690000' And !IsBlank(lPreInput) And (Trim(lPreInput) <> "-")
)
//;"Protocol";"_Protocol"
;"IsParameter";"_IsParameter"
)
;"cra27_diereventid";ThisRecord.EventLine.cra27_diereventid//If(IsBlank(ThisRecord.EventLine);Blank();ThisRecord.EventLine.DierEvent)
;"cra27_eventdatum";If(IsNew;Now();EventLine.cra27_eventdatum)
;"cra27_memo";lPreInput
;"cra27_primaryname";If(Len(ItemNaam)=0;"ItemNaam";ItemNaam)
;"cra27_docadierid";vCurrentAnimal
;"cra27_eventtypeid";4
;"cra27_guid";LineGuid
;"cra27_useremail"; If(IsNew Or Trim(lPreInput)<>Trim(EventLine.cra27_memo);User().Email;EventLine.cra27_useremail)
;"cra27_planstatus";-1
;"cra27_locatieid";If(!IsBlank(gKennel_asiel);gKennel_asiel.kennel_asiel_id;0)
;"cra27_locatieasstring";If(!IsBlank(gKennel_asiel);gKennel_asiel.naam;"")
;"cra27_aantal";If(IsNumeric(lPreInput);Value(lPreInput);0)
;"cra27_eenheid";ParameterEenheid
;"cra27_parameter";recParameter//.cra27_parametersid
;"cra27_protocol";ProtocolToRun//.cra27_protocolid
;"cra27_groepid";lGroepId
;"cr856_verberg";VerbergEvent//'Verberg (DierEvent)'.Ja//If(VerbergEvent;'Verberg (DierEvent)'.Ja;'Verberg (DierEvent)'.Nee)
)
;"cra27_diereventid"
;"cra27_eventdatum"
;"cra27_memo"
;"cra27_primaryname"
;"cra27_docadierid"
;"cra27_eventtypeid"
;"cra27_guid"
;"cra27_useremail"
;"cra27_planstatus"
;"cra27_locatieid"
;"cra27_locatieasstring"
;"cra27_aantal"
;"cra27_eenheid"
//;"cra27_parameter"
//;"cra27_protocol"
;"cra27_groepid"
;"cr856_verberg"
)
)
;;Patch(
[@DierEvent]
;ParameterProtocolLines
)
mmbr1606
22
Super User 2025 Season 1
stampcoin
17
ankit_singhal
11
Super User 2025 Season 1