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

Patch the Collection Value to LookUp Column in SharePoint List

Hi all.

I have code in my Patch button.

 

 

 

ForAll(
    Split(
        Concat(ListBox1.SelectedItems,EmployeeCode,","),","),
        Collect(boxCol,Result);
Patch(ProjAs,Defaults(ProjAs),{
    EmployeeCode: Result,
    StartDate:DatePicker1.SelectedDate,
    EndDate:DatePicker1_1.SelectedDate,
    Project: Dropdown2_1.Selected}
    )
    );

 

 

 

I want to Patch values "Result" in Collection to the LookUp Column "EmployeeCode".

Is there any way to do it. Thank you!

1 ACCEPTED SOLUTION

Accepted Solutions

@Penguniii ,

You do not have Allow Multiple Values checked, and I assume it was (My purpose is to assign multiple employees) ? The code I supplied was on the assumption that this was set. If you are only storing a single value and the Items of the Combo Box are as per my last post, then

Patch(
   ProjAs,
   {
      EmployeeCode:
      {
         Value: ListBox1.Selected.Value,
         Id: ListBox1.Selected.Id
      },
      StartDate:DatePicker1.SelectedDate,
      EndDate:DatePicker1_1.SelectedDate,
      Project: Dropdown2_1.Selected
   }
)

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Visit my blog Practical Power Apps

View solution in original post

5 REPLIES 5
C-Papa
Super User
Super User

hi, might need to see what type of column the Employee code column is but you should be able to do the below assuming it's not a choice column

 

ForAll(
ListBox1.SelectedItems.EmployeeCode As MyUpdate

,

Collect(boxCol,MyUpdate);
Patch(ProjAs,Defaults(ProjAs),{
EmployeeCode: MyUpdate,
StartDate:DatePicker1.SelectedDate,
EndDate:DatePicker1_1.SelectedDate,
Project: Dropdown2_1.Selected}
)
);

WarrenBelz
Super User
Super User

Hi @Penguniii ,

Assuming the Items of ListBox1 are

Choices(ProjAs.EmployeeCode)

and (I assume) it is a multi-select column

Patch(
   ProjAs,
   {
      EmployeeCode:
      ForAll(
         ListBox1.SelectedItems As aCode,
         {
            Value: aCode.Value,
            Id: aCode.Id
         }
      ),
      StartDate:DatePicker1.SelectedDate,
      EndDate:DatePicker1_1.SelectedDate,
      Project: Dropdown2_1.Selected
   }
)

You might also consider why you are using Lookup columns - they will cause you a lot of unnecessary grief unless you really need them.

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Visit my blog Practical Power Apps

gabibalaban
Dual Super User
Dual Super User

ClearCollect(boxCol,ListBox1.SelectedItems.EmployeeCode};
Patch(ProjAs,
        ForAll(boxCol As TableItem,
          {
           EmployeeCode: 
           {
             Id: LookUp(LookUpColumnBaseTable,EmployeeCode=TableItem.EmployeeCode,ID),
             Value:TableItem.EmployeeCode
           },
           StartDate:DatePicker1.SelectedDate,
           EndDate:DatePicker1_1.SelectedDate,
           Project: Dropdown2_1.Selected
          }
        )
);

where LookUpColumnBaseTable is the name of the table where EmployeeCode column has source and also EmployeeCodeColumnNameFromBaseTable is the name of the column from parent source of lookup. If EmployeeCodeColumnNameFromBaseTable is not EmployeeCode (as name) you can eliminate from code As TableItem and TableItem references. 

Hope it help !  

Penguniii
Frequent Visitor

Hi everyone thank you for pay attendtion in my thread.

First, here is my EmployeeCode Property

Penguniii_0-1660729542154.png

Employee Code is referencing the EmployeeCode Column from the Employee Table.

My purpose is to assign multiple employees from the Employee table to the ProjAs(ProjectAssignment) Table. 
And I can get information of people in Employee table from the EmployeeCode column of the ProjAs Table.

Thank you

 

@Penguniii ,

You do not have Allow Multiple Values checked, and I assume it was (My purpose is to assign multiple employees) ? The code I supplied was on the assumption that this was set. If you are only storing a single value and the Items of the Combo Box are as per my last post, then

Patch(
   ProjAs,
   {
      EmployeeCode:
      {
         Value: ListBox1.Selected.Value,
         Id: ListBox1.Selected.Id
      },
      StartDate:DatePicker1.SelectedDate,
      EndDate:DatePicker1_1.SelectedDate,
      Project: Dropdown2_1.Selected
   }
)

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Visit my blog Practical Power Apps

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.

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

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 (4,903)