Skip to main content
8-Gravel
January 27, 2025
Question

Customization for warning message

  • January 27, 2025
  • 2 replies
  • 1487 views

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?

 

 

2 replies

24-Ruby III
January 27, 2025

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

HelesicPetr
22-Sapphire II
22-Sapphire II
January 27, 2025

Hi @SK_12337814 

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

PetrH 

8-Gravel
January 27, 2025

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
22-Sapphire II
January 27, 2025

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