cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
zlex
Level: Powered On

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
Community Support Team
Community Support Team

Re: Add new item to sharepoint list with refence fields.

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
Level: Powered On

Re: Add new item to sharepoint list with refence fields.

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.

Community Support Team
Community Support Team

Re: Add new item to sharepoint list with refence fields.

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

zlex
Level: Powered On

Re: Add new item to sharepoint list with refence fields.

Hello RabbyC,

 

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

 

kind regards

zlex
Level: Powered On

Re: Add new item to sharepoint list with refence fields.

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
Level: Powered On

Re: Add new item to sharepoint list with refence fields.

No Worries, glad you sorted it!

Helpful resources

Announcements
New Ranks and Rank Icons in April

'New Ranks and Rank Icons in April

Read the announcement for more information!

Better Together’ Contest Finalists Announced!

'Better Together’ Contest Finalists Announced!

Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

thirdimage

Community Summit North America

Innovate, Collaborate, Grow - The top training and networking event across the globe for Microsoft Business Applications

Top Solution Authors
Top Kudoed Authors
Users online (5,217)