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

Add new item to sharepoint list with refence fields.

Hello all,

 

i can't find the way how to collect() an ne item to a sharepoint list with a refenced collumn to another sharpoint list.

let me explain what i need:

We have a list for planing internal educations in our company. So the fist List called (Schulungsübersicht) has all the informations except the employees who can book the education by itselve. The second List called "Teilnehmer" has a reference field to the "Schulungsübersicht" Title, wich is the Name of the Education.

 

i've created a Powerapp to search and select an education. on the Detailscreen there are all the informations. so there should be one button "book education" to add an item to the "Teilnehmer" List with the Title Information from the selected education an add the name of the current User to the List.

So my code looks like this but it doesn't work:

Collect(
    Teilnehmer;
    {
        Schulung: {
            '@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference";
            ID: LookUp(
                Schulungsübersicht;
                Titel = DataCardValue12.Text;
                ID
            );
            Value: DataCardValue12.Text
        }
    };
    {
        Teilnehmer: {
            '@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser";
            Claims: "i:0#.f|membership|" & Lower(User().Email);
            Department: "";
            DisplayName: User().FullName;
            Email: User().Email;
            JobTitle: ".";
            Picture: "."
        }
    }
)

the reference Field in "Teilnehmer" is Schulung and it references to the Titel field in "Schulungsübersicht".

 

any idea?

 

kind regards Alex

1 ACCEPTED SOLUTION

Accepted Solutions
v-yutliu-msft
Community Support
Community Support

Hi @zlex ,

Do you want to update lookup field?

ID is a read-only field, so you can't update it.

Try this formula:

Collect(
    Teilnehmer;
    {
        Schulung: 
            LookUp(
                Choices(Teilnehmer.Schulung);
                Value = DataCardValue12.Text
                  )
        '@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser";
         Claims: "i:0#.f|membership|" & Lower(User().Email);
         Department: "";
         DisplayName: User().FullName;
         Email: User().Email;
         JobTitle: ".";
         Picture: "."
    }
)

Here's a doc about how to update lookup column for your reference:

https://powerapps.microsoft.com/en-us/blog/default-values-for-complex-sharepoint-types/

 

 

Best regards,

Community Support Team _ Phoebe Liu

 

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

5 REPLIES 5
RabbyC
Frequent Visitor

Hi,

I think I understand your question, it sounds like you are trying to populate referenced information using collected data, if that is the case, I will try and answer below. If not, ignore me!

 

From my experience, using collect with lookup columns is not currently working 100%. I have tried to do something simillar in the past, but for some reason, the returned values dont match up with the values being given by the lookup. Have to tried doing your lookup directly to the data source, if possible?

The last time, I was doing it so that I could allow the user to work offline, but had to abandon my efforts and make it online only, and then we worked around it from there.

v-yutliu-msft
Community Support
Community Support

Hi @zlex ,

Do you want to update lookup field?

ID is a read-only field, so you can't update it.

Try this formula:

Collect(
    Teilnehmer;
    {
        Schulung: 
            LookUp(
                Choices(Teilnehmer.Schulung);
                Value = DataCardValue12.Text
                  )
        '@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser";
         Claims: "i:0#.f|membership|" & Lower(User().Email);
         Department: "";
         DisplayName: User().FullName;
         Email: User().Email;
         JobTitle: ".";
         Picture: "."
    }
)

Here's a doc about how to update lookup column for your reference:

https://powerapps.microsoft.com/en-us/blog/default-values-for-complex-sharepoint-types/

 

 

Best regards,

Community Support Team _ Phoebe Liu

 

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
zlex
Frequent Visitor

Hello RabbyC,

 

thanks for your answer. i've testet the code from @v-yutliu-msft and this do the trick.

 

kind regards

Hello @v-yutliu-msft,

 

 

very thanks for your reply. Thats the solution and works fine.

to update the lookup field was one of the problem.

 

It saves me a lot of Time

 

Kind Regards

Alex

RabbyC
Frequent Visitor

No Worries, glad you sorted it!

Helpful resources

Announcements
Power Platform Call June 2022 768x460.png

Power Platform Community Call

Join us for the next call on August 17, 2022 at 8am PDT.

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Users online (3,844)