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

Returning Planner's ThisItem.CreatedBy.user.id as text to pass to the Office 365 connector to show the display name within a table in a Canvas app

I have a Canvas app which can

1. select a Team from our Teams deployment

2. select a plan from the Team

3. Filter a data grid based on the completion date of the planner task

 

Within that table, I need to convert several values from IDs to display strings.

 

ThisItem.createdBy.user.displayName

 

 is not working, so I'm seeking a workaround.

 

Office365Users.UserProfileV2(Text(ThisItem.createdBy.user.id)).displayName

 

fails, stating that it expects text. If I go into the source code and grab the actual user.id, then replace everything inside the UserProfileV2 parens with the quoted text value, it succeeds.

 

How can I reliably convert ThisItem.createdBy.user.id into a text value which can be used by Office365Users.UserProfileV2?

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @Anonymous ,

Yes, I think that's the key problem.

"ThisItem" is the special property inside gallery. It's not supported to use this in data table.

You have two solutions:

1)use gallery instead.

Then you could use formula like I used:

Office365Users.UserProfileV2(ThisItem.createdBy.user.id).displayName

2)use data table

Please do not use  "ThisItem". Try to use AddColumns to add column with the value that you want.

Try to set your data table's Items like this:

AddColumns(
Filter(Planner.ListTasksV3(planDropdown.Selected.id,teamDropdown.Selected.id).value,completedDateTime>=DatePicker1.SelectedDate,completedDateTime<=DatePicker2.SelectedDate),
"username",Office365Users.UserProfileV2(createdBy.user.id).displayName
)

Then in your data table, choose username field to display.

 

 

Best regards,

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

View solution in original post

9 REPLIES 9
WarrenBelz
Super User
Super User

Hi @Anonymous
You don't need the Office365 connector to simply display the person who created it

ThisItem.'Created By'.DisplayName

Will do the job

 

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.

 

v-yutliu-msft
Community Support
Community Support

Hi @Anonymous ,

Do you want these feathers?

1)list tasks based on selected group and selected plan?

2)display created user's displayname in the gallery?

If so, I 've made a similar test for your reference:

1)connect with Planner, Office365 Groups, Office365 Users

2)insert two drop downs to display group and plan

set drop down1's Items:

Office365Groups.ListOwnedGroupsV3().value

//list the groups related to current user

set drop down2's Items:

Planner.ListGroupPlans(Text(Dropdown2.Selected.id)).value

 //list plans related to selected group

3)insert a gallery to display tasks

set the gallery's Items:

Planner.ListTasksV3(Dropdown1.Selected.id,Dropdown2.Selected.id).value

set one label's Text inside the gallery:

ThisItem.createdBy.user.id

//the creator's id

set one label's Text inside the gallery:

 

Office365Users.UserProfileV2(ThisItem.createdBy.user.id).displayName

 

//the creator's displayname

 

4163.PNG

 

 

Best regards,

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

I wish it were that easy. Since I'm returning data to a data grid, this syntax produces an error. It isn't expecting the period after 'Created By'.

Anonymous
Not applicable

That might be a way I can refactor the whole solution, though I'd prefer to have a way to return the Created By value for multiple tasks to a DataTable. Could it be that constraints of the DataTable might be preventing access to some of these methods?

Hi @Anonymous ,

Do you want to display creator 's name of tasks in a data table?

Solution is similar.

1)drop down1's Items:

Office365Groups.ListOwnedGroupsV3().value

 2)drop down2's Items:

Planner.ListGroupPlans(Text(Dropdown1.Selected.id)).value

3)data table's Items:

AddColumns(Planner.ListTasksV3(Dropdown2.Selected.id,Dropdown1.Selected.id).value,"creator",Office365Users.UserProfileV2(createdBy.user.id).displayName)

Please notice the parameters' position: the first one is plan id, the second is the group id.

You need to connect with these data sources:

Planner, Office365 Users, Office365 Groups.

 

 

Best regards,

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Thank you for another interesting solution, just not for the problem I have. 

 

I'm using a canvas app. The app has two dropdowns.

I'm using two collections.

ClearCollect(allTeams, MicrosoftTeams.GetAllTeams().value);
ClearCollect(allBuckets, Planner.ListBucketsV3("valid reference to a team","valid reference to a plan").value);

dd_Team shows the allTeams collection.

allTeams

dd_Plan shows the plans for the selected team in dd_Team

Planner.ListGroupPlans(dd_Team.Selected.id).value

The app has two date pickers

DateStart is Today()-7.

DateEnd is Today.

 

Next the application has a DataTable which is populated by this code:

Filter(Planner.ListTasksV3(dd_Plan.Selected.id,dd_Team.Selected.id).value,completedDateTime>=DateStart,completedDateTime<=DateEnd)

 

Using the PowerApps user interface, I selected the createdBy column, and PowerApps wrote this as a command to populate that field:

ThisItem.createdBy.user.id

My goal is to take that value and find the displayName instead of the id.

This fails:

Office365Users.UserProfileV2(ThisItem.createdBy.user.id).displayName

I ran my application and found a valid user.id string and just pasted into a label to see if it would work. It works:

Office365Users.UserProfileV2("ccf81f63-7185-41bd-991e-807887b3986e").displayName

So, there's something about "ThisItem" that is failing to convert the id to a valid string for Office365Users to consume. ThisItem is data type "record". The PowerApps UI states that "The method UserProfileV2 has an invalid value for parameter 'id'". Since that function expect text, I thought of converting the value to text using this function:

Office365Users.UserProfileV2(Text(ThisItem.createdBy.user.id)).displayName

this also fails, but in this case with 

{"statusCode" : 404, "message": "Resource not found"}

 

I'd prefer not to refactor the entire application. The core issue is converting a record data type's ThisItem.createdBy.user.id into a format consumeable by the UserProfileV2 method.
 

 

Hi @Anonymous ,

That's really strange... I've totally made a same test as yours, but I didn't met the same problem as yours.

Here's my test:

1)gallery's Items:

Filter(Planner.ListTasksV3(planDropdown.Selected.id,teamDropdown.Selected.id).value,completedDateTime>=DatePicker1.SelectedDate,completedDateTime<=DatePicker2.SelectedDate)

2)the label in the gallery's Text:

Office365Users.UserProfileV2(ThisItem.createdBy.user.id).displayName

 And I could get user displayname directly.

4201.PNG

 

 

Please check these points:

1)whether you get result by using this formua:

Filter(Planner.ListTasksV3(dd_Plan.Selected.id,dd_Team.Selected.id).value,completedDateTime>=DateStart,completedDateTime<=DateEnd)

2)the completedDateTime is the task completed time, not start time or due time

3)whether your data source is larger than 500 or 2000 records

(delegation problem)

4)whether you have permission to check this plan

 

Best regards,

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Thank you for testing that Phoebe. The one difference in your test is that you're loading data into a gallery but I'm loading it into a data table. Since I can substitue a valid string for the ThisItem.user.id and retreive a value in a label outside the data table, it doesn't seem to be a permissions issue accessing the Office365 user profile service. Could there be unique characteristics of evaluating ThisItem within a data table?

Hi @Anonymous ,

Yes, I think that's the key problem.

"ThisItem" is the special property inside gallery. It's not supported to use this in data table.

You have two solutions:

1)use gallery instead.

Then you could use formula like I used:

Office365Users.UserProfileV2(ThisItem.createdBy.user.id).displayName

2)use data table

Please do not use  "ThisItem". Try to use AddColumns to add column with the value that you want.

Try to set your data table's Items like this:

AddColumns(
Filter(Planner.ListTasksV3(planDropdown.Selected.id,teamDropdown.Selected.id).value,completedDateTime>=DatePicker1.SelectedDate,completedDateTime<=DatePicker2.SelectedDate),
"username",Office365Users.UserProfileV2(createdBy.user.id).displayName
)

Then in your data table, choose username field to display.

 

 

Best regards,

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

Helpful resources

Announcements
Ignite 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Power Apps Africa Challenge 2022

Power Apps Africa Challenge

Your chance to join an engaging competition of Power Platform enthusiasts.

Users online (1,680)