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

Patching lookup field Type Error

I have a form with the following fields:

 

Date:  Date Selector

Supervisor:  Single-select that looks up a Office365User

Employee:  Single-select that looks up a Office365User

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.

 

I am using the following code:

 

ForAll(TaskSelectBox.SelectedItems, 
   Patch('Rail Task Tracking', Defaults('Rail Task Tracking'), 
       {'Date of Task': DataCardValue6.SelectedDate, 
        Supervisor: {'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
                Claims:"i:0#.f|membership|"&SupervisorSelect.Selected.Mail,
                Department:"",
                DisplayName:SupervisorSelect.Selected.DisplayName,
                Email:SupervisorSelect.Selected.Mail,
                JobTitle:"",
                Picture:""
             },
        Employee: {'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
                Claims:"i:0#.f|membership|"&EmployeeSelect.Selected.Mail,
                Department:"",
                DisplayName:EmployeeSelect.Selected.DisplayName,
                Email:EmployeeSelect.Selected.Mail,
                JobTitle:"",
                Picture:""
             }, 
        Task:{'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
              Id: Id, 
              Value: Value}
       }
      )
);Navigate(HomeScreen,ScreenTransition.None)

It is displaying the following error:Error.png

Any help would be greatly appreciated Smiley Happy

 

1 ACCEPTED SOLUTION

Accepted Solutions

@RandyHayes  you pointed me in the correct direction that ended up being an embarrasing mistake (I will blame it on late night coding Smiley LOL).  As it turns out, the "Task" column in the "Rail Task Tracking" list should have been a "Lookup" type that referenced a "Task" list.

Unfortunately I had it set to "Text" instead of "Lookup" which I think was leading to the error I was receiving because the "Task" column in "Rail Task Tracking" was looking for text and not a lookup value (a record).

My working code is:

ForAll(TaskSelectBox.SelectedItems, 
   Patch('Rail Task Tracking', Defaults('Rail Task Tracking'), 
       {'Date of Task': DataCardValue6.SelectedDate, 
        Supervisor: {'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
                Claims:"i:0#.f|membership|"&SupervisorSelect.Selected.Mail,
                Department:"",
                DisplayName:SupervisorSelect.Selected.DisplayName,
                Email:SupervisorSelect.Selected.Mail,
                JobTitle:"",
                Picture:""
             },
        Employee: {'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
                Claims:"i:0#.f|membership|"&EmployeeSelect.Selected.Mail,
                Department:"",
                DisplayName:EmployeeSelect.Selected.DisplayName,
                Email:EmployeeSelect.Selected.Mail,
                JobTitle:"",
                Picture:""
             }, 
        Task:{'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
              Id: Id, 
              Value: Value}
       }
      )
);ResetForm(Form1_2);Navigate(HomeScreen,ScreenTransition.None)

Thank you once again for your assistance in solving my issues Smiley Happy

View solution in original post

2 REPLIES 2
RandyHayes
Super User III
Super User III

@jkperth 

 

I am assuming this is a continuation of the message thread from before.  I never got a clear understanding of the source of your data for the ComboBox selections, and still not entirely sure of the column names and how your lookup is defined.

But, here is a formula with a correction (in red) that you can try to start with:

 

ForAll(TaskSelectBox.SelectedItems, 
   Patch('Rail Task Tracking', Defaults('Rail Task Tracking'), 
       {'Date of Task': DataCardValue6.SelectedDate, 
        Supervisor: {'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
                Claims:"i:0#.f|membership|"&SupervisorSelect.Selected.Mail,
                Department:"",
                DisplayNameupervisorSelect.Selected.DisplayName,
                EmailupervisorSelect.Selected.Mail,
                JobTitle:"",
                Picture:""
             },
        Employee: {'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
                Claims:"i:0#.f|membership|"&EmployeeSelect.Selected.Mail,
                Department:"",
                DisplayName:EmployeeSelect.Selected.DisplayName,
                Email:EmployeeSelect.Selected.Mail,
                JobTitle:"",
                Picture:""
             }, 
        Task:{'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
              Id: ID, 
              Value: Title}
       }
      )
);Navigate(HomeScreen,ScreenTransition.None)

 

In this case, your ComboBox most likely has a list of Items that are coming directly from the Task Tracking List.  If so, then they are full records and have the same record structure that you can reference in your ForAll.

So...the first is obvious, a change from Id to ID, as the record suorce in your ComboBox will have ID.

The next is a guess based on your task list...in this case I assumed you had a Title column and used that to assign to the Value of the Lookup.  Which you use here will depend on the columns in your Task List and the definition of the lookup.

 

But, give the above a try and post back if things aren't helping.

 

 

 

_____________________________________________________________________________________
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.
Check out my PowerApps Videos too!

@RandyHayes  you pointed me in the correct direction that ended up being an embarrasing mistake (I will blame it on late night coding Smiley LOL).  As it turns out, the "Task" column in the "Rail Task Tracking" list should have been a "Lookup" type that referenced a "Task" list.

Unfortunately I had it set to "Text" instead of "Lookup" which I think was leading to the error I was receiving because the "Task" column in "Rail Task Tracking" was looking for text and not a lookup value (a record).

My working code is:

ForAll(TaskSelectBox.SelectedItems, 
   Patch('Rail Task Tracking', Defaults('Rail Task Tracking'), 
       {'Date of Task': DataCardValue6.SelectedDate, 
        Supervisor: {'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
                Claims:"i:0#.f|membership|"&SupervisorSelect.Selected.Mail,
                Department:"",
                DisplayName:SupervisorSelect.Selected.DisplayName,
                Email:SupervisorSelect.Selected.Mail,
                JobTitle:"",
                Picture:""
             },
        Employee: {'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
                Claims:"i:0#.f|membership|"&EmployeeSelect.Selected.Mail,
                Department:"",
                DisplayName:EmployeeSelect.Selected.DisplayName,
                Email:EmployeeSelect.Selected.Mail,
                JobTitle:"",
                Picture:""
             }, 
        Task:{'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
              Id: Id, 
              Value: Value}
       }
      )
);ResetForm(Form1_2);Navigate(HomeScreen,ScreenTransition.None)

Thank you once again for your assistance in solving my issues Smiley Happy

View solution in original post

Helpful resources

Announcements
User Groups Public Preview

Join us for our User Group Public Preview!

Power Apps User Groups are coming! Make sure you’re among the first to know when user groups go live for public preview.

Power Apps Community Call

Monthly Power Apps Community Call

Did you miss the call?? Check out the Power Apps Community Call here!

Power Platform ISV STudio

Power Platform ISV Studio

ISV Studio is the go-to Power Platform destination for ISV’s to monitor & manage applications post-AppSource publish.

Top Solution Authors
Top Kudoed Authors
Users online (76,341)