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.
Solved! Go to Solution.
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.
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.
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'."
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?
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
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.
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.
User | Count |
---|---|
137 | |
132 | |
79 | |
75 | |
71 |
User | Count |
---|---|
210 | |
200 | |
69 | |
62 | |
53 |