cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
LennartWalldén
Advocate II
Advocate II

Patch Sharepoint list with Lookup Column with data from Collection

Hi,

 

I am trying to load an Excel Table into a Sharepoint List with Contacts. The contact records have a Lookup field to link to a Company name from another SP list. In the Excel table there is a column with company name, and now I am trying to load contacts from Excel and link all contacts to their respective companies. The company names already exists in the Company SP list. (I have preloaded them).

 

I am importing the data from Excel to a Collection and then I am trying to use Patch to load the data. But I can't figure out how to store the company name into the lookup field.

 

I am using the following code:

 

ClearCollect(colContacts;       
            Filter(
                Filter(
                    FirstN(PAImport; 5);
                    IsMatch(Organisationsnummer;"\d{6}-\d{4}";MatchOptions.Complete  ) ||
                    IsMatch(Organisationsnummer;"\d{6}-XXXX";MatchOptions.Complete)
                    );
                    
                    !StartsWith(Organisationsnummer;"2")
                )
            );;


/* Save to Sharepoint */
ForAll(colContacts; 
    Patch(Kontakter; Defaults(Kontakter); 
            { 
                'Namn (field_Column2)': Kontaktperson ; 
                Epost:Mailadress; 
                Organisation: 
                    Table(      
                            { 
                                '@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference";
                                Id:1;
                                Value:'Bolag/Aktör'
                            }
                        )
            }
        )
)

 

 Any help would be appreciated! 🙂

1 ACCEPTED SOLUTION

Accepted Solutions
LennartWalldén
Advocate II
Advocate II

Found the problem:

I needed to LookUp the ID of the Company in the Company database.

{ 
                                '@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference";
                                Id: LookUp(Verksamheter; Verksamhetsnamn = 'Bolag/Aktör').ID;
                                Value:LookUp(Verksamheter; Verksamhetsnamn = 'Bolag/Aktör').Verksamhetsnamn
                            }

View solution in original post

1 REPLY 1
LennartWalldén
Advocate II
Advocate II

Found the problem:

I needed to LookUp the ID of the Company in the Company database.

{ 
                                '@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference";
                                Id: LookUp(Verksamheter; Verksamhetsnamn = 'Bolag/Aktör').ID;
                                Value:LookUp(Verksamheter; Verksamhetsnamn = 'Bolag/Aktör').Verksamhetsnamn
                            }

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (3,482)