cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
SushainKoul
Regular Visitor

Query regarding Project

Hello All,

I am working on Leave Application Project in PowerApps. For your reference, I have attached the layout of a screen which on the click of Submit button should transfer all the entered details to a SharePoint list which I have created in my SharePoint. The SharePoint list(Image3) is linked with Screen(Image1). Similarly Screen(Image5) is linked with another Sharepoint list (Image6). For your reference I have attached image for SharePoint list too. When an employee applies for a leave by clicking on "+" icon, it leads the employee to Image2. Now my confusion is when I enter the code which u can find below when I apply it on Submit button under OnSelect function, its showing me error. I have attached error image as well. In addition to the below error its showing me "The Patch function has invalid arguments".

SushainKoul_3-1632506889924.png

Image1

 

SushainKoul_0-1632506048601.png

Image2

SushainKoul_1-1632506216411.png

Image3

 

SushainKoul_2-1632506426705.png

Image4

SushainKoul_4-1632507042027.png

Image5

SushainKoul_5-1632507215816.png

Image6

Code:

Patch(
'LeaveAppliedBy Users',
Defaults('LeaveAppliedBy Users'),
{LeaveType:Gallery5.Selected.'LeaveType'.Value},
{FromDate:StartDate.SelectedDate},
{ToDate:EndDate.SelectedDate},
{LeaveTitle:TextInput1.Text},
{LeaveDescription:TextInput1_1.Text},
{
RequestedBy: {
'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
Claims:"i:0#.f|membership|" & Lower(User().Email),
Department:"",
DisplayName:User().FullName,
Email:User().Email,
JobTitle:".",
Picture:"."
}
},
{
RequestedTo: {
'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
Claims:"i:0#.f|membership|" & Lower(b.Mail),
Department:"",
DisplayName:b.DisplayName,
Email:b.Mail,
JobTitle:".",
Picture:"."
}
}
)

 

Hope I have cleared my query to u all. Plz help me out. 

9 REPLIES 9
WarrenBelz
Super User
Super User

Hi @SushainKoul ,

I am going to take a wild guess here that LeaveType is a Lookup field. You really need to ask yourself why you are using this field type with Power Apps - but that is another discussion. If I am correct, you need something like this

Patch(
   'LeaveAppliedBy Users',
   Defaults('LeaveAppliedBy Users'),
   {
      LeaveType:
      {
         Value:Gallery5.Selected.'LeaveType'.Value,
         Id:
         LookUp(
            YourReferenceList,
            YourLeaveTypeField = Gallery5.Selected.'LeaveType'.Value
         ).ID
      },
      FromDate:StartDate.SelectedDate,
      ToDate:EndDate.SelectedDate,
      LeaveTitle:TextInput1.Text,
      LeaveDescription:TextInput1_1.Text,
      RequestedBy: 
      {
         '@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
         Claims:"i:0#.f|membership|" & Lower(User().Email),
         Department:"",
         DisplayName:User().FullName,
         Email:User().Email,
         JobTitle:".",
         Picture:"."
      },
      RequestedTo: 
      {
         '@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
         Claims:"i:0#.f|membership|" & Lower(b.Mail),
         Department:"",
         DisplayName:b.DisplayName,
         Email:b.Mail,
         JobTitle:".",
         Picture:"."
      }
   }
)

 

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.

Hi @WarrenBelz ,

Thx for your help but the field type of LeaveType is not lookup but Choice whereas the Lookup datatype is foe leave Id for Image3. In Image6, LeaveType is Single line of text. Is there any mistake in this. Plz help me out. For your help I have attached list settings of Image3 and Image6

SushainKoul_0-1632560071782.png

Image3 List Settings-Image7

SushainKoul_1-1632560125289.png

Image6 List Settings-Image8

@SushainKoul ,

I will go the other way on LeaveType if it is a Text field, but that was not the error you posted.

LeaveType:Gallery5.Selected.LeaveType

Your problem is RequestedTo - are you trying to do a Lookup on a Person field? If so, I will raise the white flag now . . . .

 

@WarrenBelz  no not on a Person field but on LeaveId.

@SushainKoul ,

LeaveId is a single line of Text - what is in it and why are you patching a People field structure to it? If it is simply a list of email addresses, you need something like

RequestedTo: 
{
   Value: Lower(b.Mail),
   Id:
   Lookup(
      YourListName,
      ImageId = Lower(b.Mail)
   ).ID
}

 

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.

 

@WarrenBelz ,

Yes LeaveId is Single line of text field but list settings shown in Image8 are for Sharepoint list shown in Image6 whereas LeaveId shown in Image7 are list settings for Sharepoint list shown in Image3.

@SushainKoul ,

Sorry I am somewhat lost. What is the field you are getting the error on trying to Patch on, what type of field is it and what do you need to Patch to it?

Hi @WarrenBelz ,

Below is the error image on RequestedTo field. Its Person or Group type field.

SushainKoul_0-1632673009889.png

Hope this image clarifies your confusion. I am not sure why I am getting this error.

Hi @SushainKoul ,

Yes, I just wanted to confirm that, but what is the field that RequestedTo is looking up (and in what list). You said it was LeaveId which is a single line of Text. If this is the case, why are you patching a Person Field structure to it?

 

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.

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (1,122)