cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
NurNina
Post Patron
Post Patron

Change owner of activity in canvas apps

Hi I have a question. Can I change the owner of task/activities inside a canvas apps? I know we can change the owner of activity in model-driven but for canvas apps, would I be able to do it?

20 REPLIES 20

@lfinman im still getting the same error. It will be better if the owner can be changed directly from the canvas apps 

may I know how do you trigger it using Flow? 

@NurNina Glad you asked.  As I check back on what ultimately succeeded, I find that the Flow/Power Automate that ultimately worked is updating the Task, not Activity.  Much like the Canvas App, Power Automate did not let me access/update the Owner field.  But because I am working with Tasks, I tried Power Automate on the Task, and that does show the Owner field and allow it to be set.  (fyi I have renamed Task to Task-Memo in my system, but it is the same entity).  This works for me with Tasks, you will need to adjust if working with other Activity types.

 

I followed this guidance to trigger the Power Automate from Canvas App:  Start a flow in a canvas app 

 

This is my test app, with a gallery of activities (they are all tasks).  When an activity is selected, it shows at the right and you can select a new owner from the dropdown, then submit the request.  

demo app for activity owner updates.png

 

These patch requests (each attached to a different button) fail:

Patch ('Tasks-Memos', LookUp('Tasks-Memos',Task=Gallery1.Selected.Activity),{owninguser_task:ComboBox1_1.Selected})

error: owninguser_task: The specified column is read-only and can't be modified

Patch (Activities, Gallery1.Selected,{Owner:ComboBox1_1.Selected})

error: '_ownerid_value' is not allowed to be updated

Patch (Activities, Gallery1.Selected,{'Owning User':ComboBox1_1.Selected})

error: owninguser: The specified column is read-only and can't be modified

 

This 'power automate' succeeds:

Assignactivitytouser.Run(Gallery1.Selected.Activity,ComboBox1_1.Selected.User)

 

The 'Assign Activity To User' power automate looks like this, with just the 'Record identifier' and 'Owner' field being set:

assign activity top.png

assign activity owner.png

 

Hope this helps.  

Lyn

Hye @lfinman, thank you for the help but I have some questions.
1. For the power automate, why do the selected item from Gallery1 is .Activity instead of Task? Assignactivitytouser.Run(Gallery1.Selected.Activity,ComboBox1_1.Selected.User)

2. When I did try it, it gave error which was invalid number of arguments:received 2,expected 1.

 

Hope you will be able to help me. Thank you.

@NurNina 

1) In my example, Gallery1 contains activities:

gallery1.jpg

The Flow runs on Tasks to update the Owner field, because the Owner field for Activities is not available in Flow.  I pass .Activity because in D365 a Task is a sub-entity (my word, not Microsoft's) of Activity, and the ID of a Task matches the ID of its parent Activity entity.  I have not found very robust documentation on dealing with Activities/Tasks/etc so this is my brute-force/practical experience.  You can see suggestion of the Activity/Task connection when you look at the Task fields:

task entity.jpg

My example works for setting the Owner of a Task Activity.  If you are working with other Activities, I assume you would have to determine the Activity type and design separate Flows for each type, or create a Flow that flexes between the different Activity types.

 

2) When you created your Flow, you need to specify 'Ask in Power Apps' for two fields: Record Identifier and Owner.  To find the Owner field, select 'Show Advanced Options' and scroll down to the Owner field:

flow1.jpgflow2.jpg

Hi @lfinman .

 

Not sure what went wrong but apparently my flow has failed. I think I have followed like what you did. Is there anything that Im missing? The error said that the method Run has invalid value for parameter 'Updatearecord_Owner' . 

error update.PNGerror update owner.PNG

 

function.PNG 

 

 

error 1.PNGerror2.PNG

@NurNina I do not know what the problem is, my only hint is that with my successful flow runs, it knows the _ownerid_type is systemusers, but yours is blank.

successful flow.jpg

 

You have added the Users table as a Data Source to your app and set the data source for the combo box to be Users?

 Users data source.jpg

 

This is default selected for my combo box:

default selected.jpg

 

And this is submit on my button that calls the flow:

button select.jpg

 

I hope something there helps!

LanceDelano
Power Apps
Power Apps

Yes you can.  We don't have formal data card support yet.  But you can do this with formulas.   https://powerapps.microsoft.com/en-us/blog/owner-customer-and-regarding-for-canvas-apps/

 

I have tried this as recently as yesterday. The documentation uses Accounts as an example. Activities are a different beast.

When working with tasks, as an example, even to display the owner of a task, I had to do something like this:

(LookUp(Activities, Activity = Task1.Task).Owner).'Full Name'

That's because there is no reference to the Owner column from the Task entity, so Task1.Owner results in an error.

So I tried a similar approach to update the owner of a task by creating a form, setting the data source to the Activities entity and setting the items property to LookUp(Activities, Activity = Task1.Task)

It actually allows me to submit the form (using either SubmitForm or Patch) but then it throws an error that this column cannot be updated.

So not sure if its because it was a task record and not an activity entity record, but the approach described above in my post definitely did not work. My apologies if I am off topic but as soon as I read the previous comment, it struck me a this has been troubling me for a couple of days now.

---
If you like this reply, please give kudos. And if this solves your problem, please accept this reply as the solution.

Thanks!
Hardit Bhatia
The Power Addict
https://thepoweraddict.com

Thanks for the reply @LanceDelano .  I agree with @PowerAddict that Activities are a different beast.  My starting point has been examples like the one you provided, but many times what works for other entities does not work for Activities & their subtypes (Tasks).

 

I was able to get 'change owner of activity' working in our app using a flow, as I described to @NurNina  in this thread.  I will keep watching, because hopefully the implementation/support structure/documentation on dealing with Activities/Tasks will become more robust at some point, but for now it's a bit of a slog.

Helpful resources

Announcements
User Group Leader Meeting January 768x460.png

Calling all User Group Leaders!

Don't miss the User Group Leader meetings on January, 24th & 25th, 2022.

Power Apps Community Call Jan. 2022 768x460.png

Power Apps Community Call

Please join us on Wednesday, January 19th, at 8a PDT. Come and learn from our amazing speakers!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Top Solution Authors
Top Kudoed Authors
Users online (2,840)