When you want to change the owner of a record, so that it appears in another Stakeholder's My Stuff you can do so by means of an expression.
Imagine in a car dealership you need to design a solution where sale representatives can reassign the vehicles they have allocated for sale. After it is done the chosen cars must disappear from My Stuff of the first sales rep and move My Stuff of the new sales rep.
What you need to do
To reassign many vehicles from one sales rep to another we need to use a very simple process and an expression.
1. Create the data model that will support the scenario
2. Enable the entity in My Stuff
3. Create an batch action to select the cars to transfer
4. Create a process with a Start form to chose the new sales representative.
5. Create an action on Exit of the Start event to reassign chosen vehicles to the new sales rep and remove them from the initial sales rep.
Create the data model that will support the scenario
The first thing we need to notice is Sales representatives are direct owners of the vehicles allocated to them. Thus we can use a direct one-to-many relationship from Sales representatives to Vehicles.
Enable the entity in My Stuff
The entity that we need to link to the Stakeholder's Sales rep definition is the Vehicles entity.
Go to My Stuff and enable the collection Vehicles in the Always available context.
Create an batch action to select the cars to transfer
We want to be able to chose many vehicles and transfer them from one sales rep to another. Thus we will create an action over the Vehicles entity, that we want to be shown in My Stuff.
This action will use a simple process to do the transfer.
Create a process with a Start form to chose the new sales representative
We create a new process for this action with a new process entity called Reassign.
We can edit the process definition and just include the Start event. We just need a Start event because all we have to do is select a new sales rep and execute an action to transfer the chosen cars.
Below is the data model of our simple process.
Create an action on Exit of the Start event to transfer the vehicles
In the Wizard view we create a form where we display the chosen vehicles and the new sales representative.
Finally we include an expression that will transfer the vehicles. The first thing we need to do is to detach the chosen vehicles from the initial sales rep.
Then we attach the chosen vehicles to the new sales rep.
//Detach the vehicles from the current sales rep
//Attach the vehicles to the new sales rep