Hi there,
This post is less a question but more a "info" message.
The problem
Some years ago, I was looking for a solution to display on a promoted drawing, who approved the PR.
There are several methods to get this done.
You can run plugins from third party companies, which either set a value in a database or insert that information to drawings via a PDF watermark.
You can use "alias attribute mapping" ( https://www.ptc.com/en/support/article/CS131355 ), which unfortunately could not be implemented to drawing according to https://www.ptc.com/en/support/article/cs260828 .
There have been product ideas to get this functionality to Windchill.
At last, PTC implemented this (so I heard) From Windchill 12.1.2.0 ( https://www.ptc.com/en/support/article/cs140710 ).
Unfortunately, upgrading Windchill is not an easy task (especially for smaller companies, it can get really pricey ). Those plugins also come with a certain price tag.
Luckily, I found a way to implement this functionality to our Windchill 12.0 installation, quite easily but with heavy support of this community.
In terms of "fair play", I would like to share it with You.
Short reminder and disclaimer:
There is no guarantee, that the steps described below will work on YOUR system.
Test every customization before You get it in production use. All at Your own risk.
The workaround
Define an attribute
First, You have define an attribute for that information.
In this example, I call mine com.example.attribute.released_by.
The attribute can later be mapped to the models' and drawings' parameter "RELEASED_BY" or "RELEASED_BY:D".
( See https://support.ptc.com/help/wnc/r12.0.2.0/en/#page/Windchill_Help_Center%2FTypeMgrAbout.html for details).
Alter Your PR
Find Your active "Promotion Request Template" within Yours "Windchill Template Administration" panel.
https://support.ptc.com/help/wnc/r12.0.2.0/en/#page/Windchill_Help_Center%2FWFAdminAbout.html%23
Edit, or better duplicate and edit Your PR.
Insert a Expression block between "Set State Approved" and "Promotion Request Approval"
Insert this code to the "Expression Block":
// This first block gets the approver's information
// get the principals selected for the APPROVER role
java.util.Enumeration principals_approver=((wt.team.Team)((wt.workflow.engine.WfProcess)self.getObject()).getTeamId().getObject()).getPrincipalTarget(wt.project.Role.toRole("APPROVER"));
// define STRING for approver's information
String approver_info = ""
// loop through all approvers, which were selected for this PR
while(principals_approver.hasMoreElements())
{
// get account object of current approver
wt.org.WTPrincipal wtprincipal = ((wt.org.WTPrincipalReference)principals_approver.nextElement()).getPrincipal();
// returns approver with Email address
approver_info = wtprincipal.getUniqueDisplayIdentifier();
}
// ---------------------------------------------------
// This block alters the attributes of the objects in the PR
// from https://community.ptc.com/t5/Windchill/Java-Code-to-add-Windchill-IBA-Values-to-WTPart-Object/m-p/418583
wt.maturity.PromotionNotice pn = (wt.maturity.PromotionNotice) primaryBusinessObject;
wt.fc.QueryResult qr = wt.maturity.MaturityHelper.service.getPromotionTargets(pn);
while (qr.hasMoreElements()) {
java.lang.Object obj = qr.nextElement();
wt.iba.value.IBAHolder ibaHolder=wt.iba.value.service.IBAValueHelper.service.refreshAttributeContainer((wt.iba.value.IBAHolder)obj, null, null, null);
wt.iba.definition.service.StandardIBADefinitionService defService=new wt.iba.definition.service.StandardIBADefinitionService();
wt.iba.value.DefaultAttributeContainer attributeContainer=(wt.iba.value.DefaultAttributeContainer)ibaHolder.getAttributeContainer();
wt.iba.definition.litedefinition.AttributeDefDefaultView attributeDefinition=defService.getAttributeDefDefaultViewByPath("com.example.attribute.released_by");
wt.iba.value.litevalue.StringValueDefaultView attValue= (wt.iba.value.litevalue.StringValueDefaultView)attributeContainer.getAttributeValues(attributeDefinition)[0];
attValue.setValue( approver_info );
attributeContainer.updateAttributeValue( attValue );
wt.iba.value.service.StandardIBAValueService.theIBAValueDBService.updateAttributeContainer(ibaHolder, null, null, null);
}
Save and checkin the changes You made to the PR.
Make the (new) PR available for Your users via the "Promotion Preference Management" utility.
Kudos to this posts, which made this workaround possible:
Hi @Mat
Good work.
Same think you can do in a ChangeNotice or Activity workflow
instead of method for promotion request
wt.fc.QueryResult qr = wt.maturity.MaturityHelper.service.getPromotionTargets(pn);
use following .
// get changeActivity from ChangeNotice
wt.fc.QueryResult changeActivities = wt.change2.ChangeHelper2.service.getChangeActivities(changeOrder);
//get resulting objects from ChangeActivity
wt.fc.QueryResult changeablesAfter = wt.change2.ChangeHelper2.service.getChangeablesAfter(sourceChangeActivity);
PetrH