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

Multi-Select only patching one value

Hi,

 

I have a form with the following fields:

 

Date:  Date Selector

Supervisor:  Dropdown that looks up values from a 'Crew' list

Employee:  Drowdown that looks up values from a  'Crew' list

Task:  Multi-select that looks up values from a 'Task' list

 

I have a button that when pressed I would like it to create a record for each task that is selected.  For example, if you have the date, Supervisor, Employee and two tasks (say 'Wash Car' and 'Detail Car') selected, I would like the form to add two records to the 'Task Tracking' list.

 

Effectively, the new records would look like:

 

Record 1:  1/1/19, John Supervisor, Paul Employee, Wash Car

Record 2:  1/1/19, John Supervisor, Paul Employee, Detail Car

 

I am currently using the following code on the button:

 

ForAll(DataCardValue10.SelectedItems.Value, Patch('Task Tracking', Defaults('Task Tracking'), {'Date of task': DataCardValue7.SelectedDate, Supervisor: DataCardValue8.Selected, Employee: DataCardValue9.Selected, Task: DataCardValue10.Selected}))

The problem is, it creates two records but it uses the last selected task for both records.  For instance, if you selected 'Detail Car' last, the new records would be:

 

Record 1:  1/1/19, John Supervisor, Paul Employee, Detail Car

Record 2:  1/1/19, John Supervisor, Paul Employee, Detail Car

 

when they should be:

 

Record 1:  1/1/19, John Supervisor, Paul Employee, Wash Car

Record 2:  1/1/19, John Supervisor, Paul Employee, Detail Car

 

What am I missing?

Thank you in advance for your help.

 

1 ACCEPTED SOLUTION

Accepted Solutions
Super User
Super User

Re: Multi-Select only patching one value

 

@jkperth 

Here is what you might be looking for:

 

ForAll(DataCardValue10.SelectedItems, 
Patch('Task Tracking', Defaults('Task Tracking'),
{'Date of task': DataCardValue7.SelectedDate,
Supervisor: DataCardValue8.Selected,
Employee: DataCardValue9.Selected,
Task:{'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
   Id: Id,
Value: Value}
}
)
)

The reason you are getting the same data in the first and second entries is because you were referencing the control selected items value and id.  However, that will only give you one of what you want.  The fact that you are "ForAll"ing the selected items means you want to actually use the results of the ForAll.  ForAll will return either a single column table of Items if it is a single value in the Items collection, or a table of records if the Items of the control are a table of records.  In this case, they are a table of records with a Value and an Id.  So, you simply need to use them in your ForAll formula.

 

I hope this is clear and helpful.

 

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.

View solution in original post

7 REPLIES 7
Super User
Super User

Re: Multi-Select only patching one value

@jkperth 

Perhaps change your formula to the following:

 

ForAll(DataCardValue10.SelectedItems.Value, Patch('Task Tracking', Defaults('Task Tracking'), {'Date of task': DataCardValue7.SelectedDate, Supervisor: DataCardValue8.Selected, Employee: DataCardValue9.Selected, Task: DataCardValue10.Selected.Value}))

 

 

See if that helps you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
jkperth
Level: Powered On

Re: Multi-Select only patching one value

@RandyHayes

Thanks for the tip, I aprreciate it.  Unfortunately it throws the following error when I make that change:

"The type of this argument 'Task_x0020_Name' does not match the expected type 'Record'.  Found type 'Text'."

 

 

Super User
Super User

Re: Multi-Select only patching one value

@jkperth 

Okay...you mentioned your controls on the form and where they get their values from, let's focus on your 'Task Tracking' list.  What kind of columns do you have in that?  Specifically, what type of column is Task?

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Highlighted
jkperth
Level: Powered On

Re: Multi-Select only patching one value

@RandyHayes 

The 'Task Tracking' List has the following columns:

Title:  This is hidden and not used

Date of Task:  Date and Time

Supervisor:  Lookup (This gets it's values from the 'Crew Address' List)

Employee:  Lookup (This gets its values from the 'Crew Address' List)

Task:  Lookup (This gets it values from the 'Tasks' List)

 

The 'Task' List has the following columns:

ID:  ID number

Field1: Single line of text

 

Let me know if I can provide anymore information. Thanks

 

jkperth
Level: Powered On

Re: Multi-Select only patching one value

@RandyHayes 

I have even tried the following:

ForAll(DataCardValue10.SelectedItems.Value, Patch('Task Tracking', Defaults('Task Tracking'), {'Date of task': DataCardValue7.SelectedDate, Supervisor: DataCardValue8.Selected, Employee: DataCardValue9.Selected, Task: {'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
   Id: DataCardValue10.Selected.Id, Value: DataCardValue10.Selected.Value}}))

and

ForAll(DataCardValue10.SelectedItems.Value, Patch('Task Tracking', Defaults('Task Tracking'), {'Date of task': DataCardValue7.SelectedDate, Supervisor: DataCardValue8.Selected, Employee: DataCardValue9.Selected, Task: {Id: DataCardValue10.Selected.Id, Value: DataCardValue10.Selected.Value}}))

However they both have the same result and put in whatever the last selected Task is as the Task for all records added.

Super User
Super User

Re: Multi-Select only patching one value

 

@jkperth 

Here is what you might be looking for:

 

ForAll(DataCardValue10.SelectedItems, 
Patch('Task Tracking', Defaults('Task Tracking'),
{'Date of task': DataCardValue7.SelectedDate,
Supervisor: DataCardValue8.Selected,
Employee: DataCardValue9.Selected,
Task:{'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
   Id: Id,
Value: Value}
}
)
)

The reason you are getting the same data in the first and second entries is because you were referencing the control selected items value and id.  However, that will only give you one of what you want.  The fact that you are "ForAll"ing the selected items means you want to actually use the results of the ForAll.  ForAll will return either a single column table of Items if it is a single value in the Items collection, or a table of records if the Items of the control are a table of records.  In this case, they are a table of records with a Value and an Id.  So, you simply need to use them in your ForAll formula.

 

I hope this is clear and helpful.

 

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.

View solution in original post

jkperth
Level: Powered On

Re: Multi-Select only patching one value

@RandyHayes 

Thank you so much for the really clear explaination 🙂

Much appreciated!

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors (Last 30 Days)
Users online (5,318)