cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Voltes
Helper III
Helper III

Incompatible type while try to Patch from People combo box

Hi,

 

I'm not sure whether this is related to my previous threat, but I got an error while using Patch to update my Sharepoint list whereby the source contain User/People combo box.

 

So this is my patch code :

 

Patch(Visit, 
{   Title:txtTitle.Text,
    Traveler:{
        '@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
        Claims: "i:0#.f|membership|" & cboEmpoyee_1.Selected.Mail,
        Department:"", 
        DisplayName: cboEmpoyee_1.Selected.DisplayName,
        Email: cboEmpoyee_1.Selected.Mail
    },
    'Reason For Visits':txtReason_1.Text
}

 

 

So, basically I have 3 controls: txtTitle, txtReason_1 which is a single text type, and the cboEmployee_1 is the combo box with User list (People).

 

And the error is pointing to "DisplayName" which is am using for the combo box which in the end it will update my field in Sharepoint with type of User/people. 

 

Voltes_0-1603290031816.png

 

Anyone can advice what's wrong with this ? and how to resolve it ? 

 

Thanks,

1 ACCEPTED SOLUTION

Accepted Solutions
v-siky-msft
Community Support
Community Support

Hi @Voltes ,

 

I guess the Combobox Items is Office365Users.SearchUsers(), the correct DefaultSelectedItems property must have the same data structure as the Items property, so the easiest way is use LookUp function to retrieve on the Office365Users.SearchUsers().

Please modify the combobox.DefaultSelectedItems property as follows.

LookUp(Office365Users.SearchUser(),Mail=User().Email)

Then modify the Patch code as follows.

Patch(Visit, Defaults(Visit),
{   Title:txtTitle.Text,
    Traveler:{
        '@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
        Claims: "i:0#.f|membership|" & cboEmpoyee_1.Selected.UserPrincipalName,
        Department:"",
        DisplayName: "",
        Email: "",
        JobTitle:"",
        Picture:""
    },
    'Reason For Visits':txtReason_1.Text
}

Hope this helps.

Sik

View solution in original post

4 REPLIES 4
Voltes
Helper III
Helper III

Hi,

 

Sorry, turned out it is a typo error on the combo box name.

However I still cannot save it as there is an error :

The requested operation is invalid. Server Response: Visit failed: The specified user i:0#.f|membership| could not be found. clientRequestId: 9a8d78ad-5813-4ddc-8c87-623ae02f442b serviceRequestId: 9a8d78ad-5813-4ddc-8c87-623ae02f442b

 

When I tried to take a look at the "cboEmployee_1.Selected.Mail" by show it in Label control, it looks like it is empty at first, and will only have value after we click (select) from the combo box. Does it means because I put the default value on the combo box, the box not yet been selected ? Is that why the error says "the specified user not found" ? Then what to do when we're using combo box which have property DefaultSelectedItem filled in ? based on the name, doesn't it mean it supposed to be selected already ?

 

Thanks

 

 

v-siky-msft
Community Support
Community Support

Hi @Voltes ,

 

I guess the Combobox Items is Office365Users.SearchUsers(), the correct DefaultSelectedItems property must have the same data structure as the Items property, so the easiest way is use LookUp function to retrieve on the Office365Users.SearchUsers().

Please modify the combobox.DefaultSelectedItems property as follows.

LookUp(Office365Users.SearchUser(),Mail=User().Email)

Then modify the Patch code as follows.

Patch(Visit, Defaults(Visit),
{   Title:txtTitle.Text,
    Traveler:{
        '@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
        Claims: "i:0#.f|membership|" & cboEmpoyee_1.Selected.UserPrincipalName,
        Department:"",
        DisplayName: "",
        Email: "",
        JobTitle:"",
        Picture:""
    },
    'Reason For Visits':txtReason_1.Text
}

Hope this helps.

Sik

View solution in original post

Hi,

 

It works!

How to know what's the structure looks like from that "Office365Users.SearchUsers()" returned, if I may ask ?

 

Much thanks.

 

Hi @Voltes ,

 

See the output of SearcUser action of Office365 Users connector.

 

Sik

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

secondImage

Are Your Ready?

Test your skills now with the Cloud Skill Challenge.

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

Top Solution Authors
Top Kudoed Authors
Users online (70,220)