cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Anonymous
Not applicable

Setting default on Form, can not choose complex field default value

I have a connection to SharePoint list and the list has complex field (People/Group). 

I have an edit form, and I am trying to make it show different things depending if it is in New mode or Edit mode.

Here is what I have so far in the cards default function:

If(FormMode=Edit,ThisItem.Traveler,
{'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
             Claims:Concatenate("i:0#.f|membership|",UserProfileCollection.Mail),
             Department:UserProfileCollection.Department,
             DisplayName:UserProfileCollection.DisplayName,
             Email:UserProfileCollection.Mail,
             JobTitle:UserProfileCollection.JobTitle,
             Picture:""
})

It does work but it does not allow to select to show any other value in the field than odata.type or Picture. I would like to change Value1 to DisplayName.

Is there a workaround so that I can still use this default function but it would display the DisplayName instead of the list type?

It is strange because I have almost identical code for another default value but it allows me to select any of the fields (Department, DisplayName, Email, JobTitle) only this one for some reason does not allow to select fields that are set by using UserProfileCollection

 

Here how it looks in PowerApps:

1.png

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Anonymous
Not applicable

Re: Setting default on Form, can not choose complex field default value

After some experimentation I finally found my stupid mistake.

 

For collections you have to specify which record to take. So just a simple fix of changing UserProfileCollenction to First(UserProfileCollection) fixed the issue.

Here is the correct code:

If(FormMode=Edit,ThisItem.Traveler,
{'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
             Claims:Concatenate("i:0#.f|membership|",First(UserProfileCollection).Mail),
             Department:First(UserProfileCollection).Department,
             DisplayName:First(UserProfileCollection).DisplayName,
             Email:First(UserProfileCollection).Mail,
             JobTitle:First(UserProfileCollection).JobTitle,
             Picture:""
})

View solution in original post

2 REPLIES 2
Highlighted
Anonymous
Not applicable

Re: Setting default on Form, can not choose complex field default value

After some experimentation I finally found my stupid mistake.

 

For collections you have to specify which record to take. So just a simple fix of changing UserProfileCollenction to First(UserProfileCollection) fixed the issue.

Here is the correct code:

If(FormMode=Edit,ThisItem.Traveler,
{'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
             Claims:Concatenate("i:0#.f|membership|",First(UserProfileCollection).Mail),
             Department:First(UserProfileCollection).Department,
             DisplayName:First(UserProfileCollection).DisplayName,
             Email:First(UserProfileCollection).Mail,
             JobTitle:First(UserProfileCollection).JobTitle,
             Picture:""
})

View solution in original post

Highlighted
Community Support
Community Support

Re: Setting default on Form, can not choose complex field default value

Hi MartynasJurkus,

 

I am so glad to hear that the function now is working for you.


Thanks for updating. Anytime you have issue when working with PowerApps, please feel free post your issues here, we’re always ready to help.

 

 

Best regards,
Mabel Mao

Community Support Team _ Mabel Mao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
secondImage

New Return to Workplace

Reopen responsibly, monitor intelligently, and protect continuously with solutions for a safer work environment.

August 2020 CYST Challenge

Check out the winners of the recent 'Can You Solve These?' community challenge!

Experience what’s next for Power Apps

Join us for an in-depth look at the new Power Apps features and capabilities at the free Microsoft Business Applications Launch Event.

Check this Out

Helpful information

Featuring samples like Return to the Workplace and Emergency Response Applications

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Users online (3,447)