Community Tip - You can subscribe to a forum, label or individual post and receive email notifications when someone posts a new topic or reply. Learn more! X

Translate the entire conversation x

Customization for warning message

SK_12337814
6-Contributor

Customization for warning message

Whenever an alternate link is created between 2 parts, a pop/warning message should appear saying "You are adding this as a global alternative. Consequently this Alternate part and will be introduced into all BOMs where the previous part is used"

 

 

How to achieve this?

 

 

11 REPLIES 11

Article - "Alternate Part vs Substitute Part in Windchill PDMLink": https://www.ptc.com/en/support/article/CS214847 

HelesicPetr
22-Sapphire II
(To:SK_12337814)

Hi @SK_12337814 

Could you provide any screen shot how you wish to present the error to the user? - when/where

PetrH 

Wanted to know the approach for customisation........im adding a part as an alternative part to another part.....now before confirming, I need to get a warning/alert message with the above message.

 

HelesicPetr
22-Sapphire II
(To:SK_12337814)

Hi @SK_12337814 

It is complicated and not recommended. 

 

You can decompile OOTB processor and add a warning message in the preProcess method. 

The problem is that the OOTB class is in a wncWeb.jar package and you have to take it decompile, rewrite(add the code to add a warning) compile it, place it in the codebase folder and remove the class from the wncWeb.jar file (<wt_home>\codebase\WEB-INF\lib). 

 

the Wizard class: com.ptc.windchill.enterprise.part.forms.AlternatesSubstitutesFormProcessor

 

This is just an example, but you can any condition when the message should appear. 

 

public FormResult preProcess(NmCommandBean var1, List<ObjectBean> var2) throws WTException {
	log.debug("In preProcess");
	this.whichReplacementsButton = var1.getTextParameter("whichReplacementsButton");
	if (!this.isCancelButton()) {
		this.formData = getFormData(var1);
		this.addItemOids = var1.getAddedItemsByName("replacementsTable");
		this.addItemOids = this.removeDuplicate(this.addItemOids);
		this.removedItemOids = var1.getRemovedItemsByName("replacementsTable");
		this.addSubstituteOids = this.getAddedPart("addSustituteLink_replacementsTable", var1);
		this.addAlternateOids = this.getAddedPart("addAlternateLink_replacementsTable", var1);
	}
	// CUSTOMIZATION ADDED TO SHOW THE WARNING MESSAGE
	FormResult result = new FormResult();
	result.setStatus(FormProcessingStatus.NON_FATAL_ERROR);
	ArrayList<String> incorrectMessages = new ArrayList<>();
	incorrectMessages.add("PreCheck Failed");
	WTMessage errorTitle = new WTMessage("com.ptc.core.ui.errorMessagesRB", "35", new ArrayList[]{incorrectMessages}); // 32 - Error, 33 - Info, 35 - Warning
	FeedbackMessage fMS = new FeedbackMessage(FeedbackType.CONFIRMATION, var1.getLocale(), errorTitle.getLocalizedMessage(var1.getLocale()), incorrectMessages, "You are adding this as a global alternative. Consequently this Alternate part and will be introduced into all BOMs where the previous part is used");
	result.addFeedbackMessage(fMS);

	return result;
}

 

PetrH

Can we add this to a custom class and call it from the custom actions?

 

HelesicPetr
22-Sapphire II
(To:SK_12337814)

No, you have to modify the OOTB class.

 

if you use own custom class then the function will stop working because it is in the GWT environment and your class is not configured to use it in the OOTB GWT function.

 

PetrH

avillanueva
22-Sapphire II
(To:HelesicPetr)

Easier approach might be to block access to creating alternates to a few special users who know how to use them and what they mean. The rest of the users can use substitute links. 

HelesicPetr
22-Sapphire II
(To:avillanueva)

Hi @avillanueva 

Yes, also, you can create a listener that controls the Link creation and throw the error that user is not allowed to create the link...

PetrH

@HelesicPetr @avillanueva It would be so much easier if there was a possibility to show a confirmation dialog from an event instead of having only the block possibility. 

Was thinking the same though. Can it be a trigger of an info message instead a warning one box after clicking ok.?

Hi @BjoernRueegg 

I did similar thing for deleting WTPart that is connected to a ProcessPlan with overridable error if user is sure to delete the WTPart in a event manager

PetrH

Announcements
Top Tags