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

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
jkperth
Level: Powered On

Re: Patching lookup field Type Error

@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
Super User
Super User

Re: Patching lookup field Type Error

@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.
jkperth
Level: Powered On

Re: Patching lookup field Type Error

@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
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
Users Online
Currently online: 169 members 5,683 guests
Please welcome our newest community members: