Hello everyone,
I'm trying to give users the opportunity to enter NEW values NOT present in a second list that populates a lookup field when they fill out a primary list.
So there are two lists: the main list, which has a Lookup field inside it that links to the second list.Main list form is customized with powerapp.
Both of my sharepoint lists have been uploaded as data sources in the power app
This is the second list

This is the main list (where "Sede" Field is lookup type on the second list )

So..when in main list I choose one "Sede" in my Combobox, I see the values in second list

Objective:
when the user chooses "***NUOVA SEDE***" (a special value, "new Location" in english ) , in the power app I bring up two new fields (Nuova Sede e Nuovo Indirizzo) where the user enters the values related to the new "SEDE" that he wants to insert in the second list (e.g.: "SEDE 3") .
PS: Of course, I also created the corresponding support fields in the SharePoint main list

I customized the form in the power app and hooked a Flow to which I pass the new values entered by the user as parameters and so far everything is ok.
Result : I have now a new SEDE in the second list !

The flow is launched by the "Inserisci Sede" button and it also returns to me the ID of new record created (67)
What I can't do is update the value of my Lookup "Sede" field in my main list with the new value inserted in the second list. (SEDE 3)
Here's the code I added to the button with which I first launch the flow that returns the ID of the new record created in the second list and then I retrieve this new record with a lookup on the second list where I search by ID.
I used 2 global variables (ID_NewRecordInSecondList and NEWSEDE_RECORD)
Set(
ID_NewRecordInSecondList,
'MYFLOW'.Run(DataCardValue_NuovaSede.Text,DataCardValue_NuovoIndirizzo.Text
);
Set(
NEWSEDE_RECORD,
LookUp('SEDE Service List',ID= Value(ID_NewRecordInSecondList.ID_NewSede))
)
Then i modified DefaultselectedItems of "SEDE" field (lookup field in the main list) to:
DefaultselectedItems = NEWSEDE_RECORD
BUT:
The field is blank...white..empty..

If I add two simple labels and set their text to
NEWSEDE_RECORD.Title and NEWSEDE_RECORD.ID I see the values correctly "SEDE 3" and "67".
So I think the variable is ok!
What is the easiest way to change the value of a lookup field "at runtime?"
Thank you in advance