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.

Change Object number in Workflow task notification subject

pyalavarthi
1-Newbie

Change Object number in Workflow task notification subject

Hi all,
We are using Windchill 9.1. OOTB email notifications for the
workflow task notifications have generic subject with Activity name such
'Approve task' , 'Review task'.
I am trying to find a way to add the ECR/ECN number to the subject such as
'ECR-1234 Approve task', 'ECN-2345 Review task'. I am wondering if there
is any way of extending notification processors and add this to all the
tasks.
Any pointers will be helpful.


Thanks,
Prathap <">http://goo.gl/LuT5>
20 REPLIES 20

Hi Prathap

educated guess: From the start transition tab, programmatically alter the
assigned activity name. That should be reflected in the email subject.





Thank you and have a great time.

Best Regards

Swamy Senthil

Principal Solutions Architect, Swasen Inc

swamy.senthil@swasen.com(Email); 909 800 8423(M); 973 324 2729(W); 866
908 6561(F);




dwilliams
6-Contributor
(To:pyalavarthi)

The following example might work well for you in the start transition of
your activity.



//Define the Activity Name

String ecnNumber =
((wt.change2.WTChangeOrder2)primaryBusinessObject).getNumber();

String MyActivityName = "Analyze Change Notice " + ecnNumber



//Set the Name

wt.workflow.engine.WfActivity myActivity =
(wt.workflow.engine.WfActivity)self.getObject();

myActivity.setName (MyActivityName);

myActivity = (wt.workflow.engine.WfActivity)
wt.fc.PersistenceHelper.manager.save(myActivity);





You need to modify the activity in the start transition and persist/modify it. The email notification OOTB takes care of the rest.

I got this code stuffed somewhere and searching this solutions blaster for old posts would likely turn it up.

Hey PTC, has no one ever asked for this in a enhancement request? No BOCA requests? I always seem to have to implement this eventually or find it previously implemented.






Sent from my Verizon Wireless BlackBerry

Thanks David. I agree with you that this should be OOTB feature rather than
customization.
I am thinking of writing a listener event on WfProcess object and update
all the WfAssignedActivity names to append change object number. That way I
don't have to update all the workflows and new workflows will automatically
get that feature.



Prathap <">http://goo.gl/LuT5>



Listeners are expensive on performance, not foolproof. Better off writing a queue with a single entry that runs and reschedules. I would also update the existing templates with this. If you have a lot, may find SQL handy to update them. It isn't as scary as it sounds.

Another option could be a stored procedure in the database.





Sent from my Verizon Wireless BlackBerry
AL_ANDERSON
5-Regular Member
(To:pyalavarthi)

We have a much different experience with listeners. We find our part and
document listeners to not have a negative performance impact, whereas we
found that relying on workflow queue entries inevitably fail after enough
years of running with tens of thousands of objects. Moreover, we often
need real time updates based on user transactions with as little impact to
out of the box code as possible - and listeners do that since they do not
impact the user interface and are segregated form the main codebase. For
example, we use a listener service to rename parts automatically based on
PartsLink classification naming rules - it executes on create, revise,
save as, check out, and check in. It works very well - much better than
if we had relied on workflows, for example, or some other asynchronous
queuing method.

For this particular issue on the worklist, it is fairly easy to create
your own column on a worklist. It is a very lightweight enhancement, and
you can put anything you want in your own column. For example, we have a
column called "Parent ECN for ECT Only" that lists the ECN number and link
to the ECN on an ECT task on the worklist (it displays "-" for other
tasks). We added a few other columns, as well. While this is a
customization, we have found it to be easy enough to maintain from upgrade
to upgrade to make the benefit worth the incremental cost added to our
upgrades to regression test those columns.

On the other hand, if every assigned activity needs the primary business
object number appended to the task name, you might just use a few lines of
code in the activity Start transition in the workflow template to change
the activity name if it isn't already changed. That should be even easier
to make than a listener or a new column on a worklist, assuming that the
activity is persisted by the time the start transition executes (I think
it is, but haven't tried it).

Al Anderson



Well I never suggested a solution that changes OOTB interface.

Not to get too much of a tangent, I stated only ever one entry in the queue. That entry executing code to look for workitems/activities matching desired criteria. In addition, I have no clue why a queue would grow so big, entries should be removed upon completion. It's not meant as a way to audit.

Lastly, since everyone's setups are different, and some are quick to add a listener for this or that, poorly code them, you can degrade the system. I mainly point out these points to make anyone objectively think about solution architecture, not to avoid event listeners altogether.

For example, I have a single listener that runs and monitors all events, a properties file then contractually is run at server startup to seed what helper classes have subscribed to an event.




Sent from my Verizon Wireless BlackBerry

We include the PBO Number in front of the assignment Name dynamically, as shown here (rather than including the subject). This number carries thru related emails. It's also very helpful because all reporting on completed assignments (tasks) can be filtered by the type of object.
[cid:image001.png@01CCF183.478D8AD0]

Thanks Mike this the solution I was referring to.


Sent from my Verizon Wireless BlackBerry

Hi Mike,


I know this is an old post but, how did you add the ECN number to the front of the Workflow Task name? I tried to add {primaryBusinessObject} to the Name field of the Activity node but that didn't work.


Perfect, thanks Steve. When I looked at the post on the forum I couldn’t see the code for some reason.

Patrick Williams | Engineering Systems | c: 616.947.2110
[cid:image001.jpg@01D0057C.01F45DE0]

Hi guys, here is the code I’ve used. It includes the prefix check (I may have my nomenclature backwards) to ensure it doesn’t duplicate the loop. Note this code adds the activity number to the end of the task.

If you enter this code into the “Start” transition of an ECR task it will append the Number of the ECR to the Activity name and subsequent email notifications and of course the tasks themselves. It must be tailored slightly to fit other workflow objects such as ECN’s or Problem reports. See examples below:

CODE:
// This code snippet is object specific and gets the number of the object and assigns it to the string number
java.lang.String number = ((wt.change2.WTChangeRequest2)primaryBusinessObject).getNumber();

// You can use the following instead of the line above for other objects
//= ((wt.change2.WTChangeRequest2)primaryBusinessObject).getNumber();
// = ((wt.change2.WTChangeOrder2)primaryBusinessObject).getNumber();
// = ((wt.change2.WTChangeActivity2)primaryBusinessObject).getNumber();
// =((wt.change2.WTVariance)primaryBusinessObject).getNumber();
// =((wt.change2.WTChangeIssue)primaryBusinessObject).getNumber();


wt.workflow.engine.WfActivity myActivity =(wt.workflow.engine.WfActivity)self.getObject();
String prefix=myActivity.getName();
if (!prefix.endsWith(number)) {
java.lang.String Activity_Name = prefix + ": " + number;
myActivity.setName (Activity_Name);
myActivity = (wt.workflow.engine.WfActivity) wt.fc.PersistenceHelper.manager.save(myActivity);
}

NOTIFICATION EMAIL:
[cid:image001.png@01CDFE17.241F33E0]

Steve,
I have been trying to get your code to work and I keep getting a stalled queue error when the task tries to start.
I too am trying to get the ECN number appended to the Change activity work flow task so the user know which ECN he is dealing with.
I thought I needed to added the variables to the workflow and the task, but that was not it. I believe the Start transition is seeing false and the task will not start.
Was there anything else you need to setup?
Thanks in advance for any help,

[UTC BIS_RGB-sml]
Ray Drennen
Technology, Components, & Methods Group – Engineering Systems

5 Farm Springs Rd.
Farmington, CT 06032
860-676-5619 - voice
860-353-1356 – eFax



Hi Raymond,

My client having similar type requirement and have tried the above code for WTDocument Type, however while executing the Check Syntax, Its giving errors,

Kindly help me out to execute the same.

Do i need to create *.java file to execute the above code?

Thanks in advance.

Regards,

Mahesh Kumar G

BenPerry
13-Aquamarine
(To:maheshkumar)

Mahesh Kumar G‌,

What is the code that you're using to give you syntax errors?  Can you post the code?

Ben,

I am using this below code for WTDocument Type "FM01",

I have created workflow variable, "number",

Code:

java.lang.String number = ((wt.WTdocument|com.ptc.abc.FM01)primaryBusinessObject).getNumber();

wt.workflow.engine.WfActivity myActivity =(wt.workflow.engine.WfActivity)self.getObject();

String prefix=myActivity.getName();

if (!prefix.endsWith(number)) {

               java.lang.String Activity_Name = prefix + ": " + number;

               myActivity.setName (Activity_Name);

               myActivity = (wt.workflow.engine.WfActivity) wt.fc.PersistenceHelper.manager.save(myActivity);

               }

Please find the Syntax error,

Checking Syntax...

F:\ptc\Windchill_10.2\Windchill\temp\WfExpression2582982.java:28: error: variable number is already defined in method executemethod_1(Object[])

java.lang.String number = ((wt.doc.WTdocument|com.abc.FM01)primaryBusinessObject).getNumber();

                 ^

F:\ptc\Windchill_10.2\Windchill\temp\WfExpression2582982.java:28: error: cannot find symbol

java.lang.String number = ((wt.doc.WTdocument|com.abc.FM01)primaryBusinessObject).getNumber();

                              ^

  symbol:   class doc

  location: package wt

F:\ptc\Windchill_10.2\Windchill\temp\WfExpression2582982.java:28: error: cannot find symbol

java.lang.String number = ((wt.doc.WTdocument|com.abc.FM01)primaryBusinessObject).getNumber();

                                                 ^

  symbol:   class abc

  location: package com

Note: F:\ptc\Windchill_10.2\Windchill\temp\WfExpression2582982.java uses unchecked or unsafe operations.

Note: Recompile with -Xlint:unchecked for details.

3 errors

Syntax check complete.

syadala
5-Regular Member
(To:maheshkumar)

Hi Mahesh,

    Please change to

java.lang.String number = ((wt.WTDocument)primaryBusinessObject).getNumber();

wt.workflow.engine.WfActivity myActivity =(wt.workflow.engine.WfActivity)self.getObject();

String prefix=myActivity.getName();

if (!prefix.endsWith(number)) {

               java.lang.String Activity_Name = prefix + ": " + number;

               myActivity.setName (Activity_Name);

               myActivity = (wt.workflow.engine.WfActivity) wt.fc.PersistenceHelper.manager.save(myActivity);

               }

Regards

Sudhakar

Hi Sudhakar,

I am using WTDocument sub type, shall i use full name for sub type document or Only WTDocument Name?.

Thanks in Advance.

Regards,

Mahesh Kumar G

syadala
5-Regular Member
(To:maheshkumar)

Hi Mahesh,

          For all MBAs you use WTDocument If you want get Typed Attributes use LWCNormalizedObject.

Regards

Sudhakar

BenPerry
13-Aquamarine
(To:syadala)

Mahesh,

I also notice some other things just by looking at the code.

  • Remove the java.lang.String before number.  You have already created that variable.  You said you created a "workflow variable" called "number".
  • The full name for WTDocument is wt.doc.WTDocument.

number = ((wt.doc.WTDocument)primaryBusinessObject).getNumber();

wt.workflow.engine.WfActivity myActivity =(wt.workflow.engine.WfActivity)self.getObject();

String prefix=myActivity.getName();

if (!prefix.endsWith(number)) {

               java.lang.String Activity_Name = prefix + ": " + number;

               myActivity.setName (Activity_Name);

               myActivity = (wt.workflow.engine.WfActivity) wt.fc.PersistenceHelper.manager.save(myActivity);

               }

Top Tags