cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

We are happy to announce the new Windchill Customization board! Learn more.

SUMMARY Dynamically Set Workflow Activity

dwilliams
6-Contributor

SUMMARY Dynamically Set Workflow Activity

Adding summary:

Dynamic Activity Name (Activity Transition)
//Get the Activity
wt.workflow.engine.WfActivity myActivity = (wt.workflow.engine.WfActivity)self.getObject();
//Modify the Activity
myActivity.setName ("Work Order - " + task1Name); //task1Name is a String
//Save the Activity
myActivity = (wt.workflow.engine.WfActivity) wt.fc.PersistenceHelper.manager.save(myActivity);

Dynamic Activity Instructions
Add your String variable to the activity task instructions. Enclose the variable in curly braces.
{task1Instructions}

Dynamic Activity Participants (WFExpression)
if (task1User != null) //task1User is a wt.org.WTUser variable
{
//SET TEAM
wt.team.Team team = (wt.team.Team)((wt.team.TeamManaged)(self.getObject())).getTeamId().getObject();
//SET THE ROLES
wt.project.Role teamRole = wt.project.Role.toRole("TASK OWNER 1");
//REMOVE THE CURRENT PARTICIPANT
wt.org.WTPrincipal removeUser = null;
wt.team.TeamHelper.service.deleteRolePrincipalMap( teamRole,removeUser,team);
//ADD THE PARTICIPANTS TO THE TO_ROLES
wt.team.TeamHelper.service.addRolePrincipalMap( teamRole, task1User, team );
}

Dynamic Activity Due Date
Create and set a wt.workflow.engine.WfDueDate variable from a preceding task or from code.
Add the wt.workflow.engine.WfDueDate variable to the appropriate task as visible, required and read set to false. Set resettable to true.

Hope this helps,
Dax Williams
Business Administrator, Windchill
Lifetime Products, Inc.
-<">mailto:->

[Lifetime_Logo_BlkWhite_Sans_email sig]
8 REPLIES 8

Hi Dax,


Should the code you have given below be given inside a workflow expression ?




In Reply to Dax Williams:


Adding summary:

Dynamic Activity Name (Activity Transition)
//Get the Activity
wt.workflow.engine.WfActivity myActivity = (wt.workflow.engine.WfActivity)self.getObject();
//Modify the Activity
myActivity.setName ("Work Order - " + task1Name); //task1Name is a String
//Save the Activity
myActivity = (wt.workflow.engine.WfActivity) wt.fc.PersistenceHelper.manager.save(myActivity);

Dynamic Activity Instructions
Add your String variable to the activity task instructions. Enclose the variable in curly braces.
{task1Instructions}

Dynamic Activity Participants (WFExpression)
if (task1User != null) //task1User is a wt.org.WTUser variable
{
//SET TEAM
wt.team.Team team = (wt.team.Team)((wt.team.TeamManaged)(self.getObject())).getTeamId().getObject();
//SET THE ROLES
wt.project.Role teamRole = wt.project.Role.toRole("TASK OWNER 1");
//REMOVE THE CURRENT PARTICIPANT
wt.org.WTPrincipal removeUser = null;
wt.team.TeamHelper.service.deleteRolePrincipalMap( teamRole,removeUser,team);
//ADD THE PARTICIPANTS TO THE TO_ROLES
wt.team.TeamHelper.service.addRolePrincipalMap( teamRole, task1User, team );
}

Dynamic Activity Due Date
Create and set a wt.workflow.engine.WfDueDate variable from a preceding task or from code.
Add the wt.workflow.engine.WfDueDate variable to the appropriate task as visible, required and read set to false. Set resettable to true.

Hope this helps,
Dax Williams
Business Administrator, Windchill
Lifetime Products, Inc.
-<

[Lifetime_Logo_BlkWhite_Sans_email sig]
dwilliams
6-Contributor
(To:dwilliams)

Hi Praseeth,

This code was intended to be used as the start transition inside a
workflow activity.



Dax Williams
Engineering E-Tools Administrator
GE Healthcare OEC

Surgery

-




Hi,

I've added a variable in curly braces into my instructions tab of an activity (a global workflow variable) but all it comes out with is that exactly as it is inputted.

ie {TestDebugString}

So is there anything special I need to do to make this bit work

Dynamic Activity Instructions

Add your String variable to the activity task instructions. Enclose the variable in curly braces.

{task1Instructions}

I've found out how to do this. You cannot use a global variable and expect it to work. I created a local variable in the activity and used the initialize from the global variable. Then if you place the local variable into the instructions tab in curly braces it works.

Capture1.PNG

Capture2.PNGCapture3.PNG

Hello Dax,

I am having requirement of creating workflow activities with different instructions(actually part instruction is specific to user) for different participant. could you please guide, how i can achieve this?

In the case of needing just the text task instructions to vary, people have used various text functions for a long time to populate a String workflow variable.  Just present the variable in one Task, and then present the current value of that in Task(s) that follow.

Hello Mike,

Thank you for reply...

In my requirement, I am having only one activity in workflow...which is having only one responsible role....this role is having N no. of participants(WTUser)...this task is to be assigned to these users with slightly different subject in task....if possible could you please guide me how i can give task with different subject( Subject is having link to Primary object)

This is much more challenging and I don't have a good answer. If you were to configure the workflow template with separate Activities, then each could present the workflow variable after it was changed by a previous user.  If you need to keep it as is, I don't think that I can offer any help.

Top Tags