Skip to main content
14-Alexandrite
April 25, 2017
Question

Inline Messaging customization

  • April 25, 2017
  • 2 replies
  • 3250 views

Hi.

How to add link to primary content in ObjectFormProcessor feedback message?

I want user to have a link to pdf file in inline message.

Thanks.

2 replies

15-Moonstone
April 26, 2017

The following code provides the primary content download URL.

import wt.content.ApplicationData

import wt.content.ContentHelper

import wt.content.ContentRoleType

import wt.doc.WTDocument

import wt.fc.QueryResult

// Initialize from somewhere...

WTDocument doc;

doc = (WTDocument) ContentHelper.service.getContents(doc); QueryResult queryResult = ContentHelper.service.getContentsByRole(doc,ContentRoleType.PRIMARY);

URL url=null; if(queryResult.hasMoreElements()){    // There can be only one...     url = ContentHelper.getDownloadURL(doc, (ApplicationData) queryResult.nextElement());

} // Test url, if it's null, no content.

// Otherwise, add it in the feedback message, within an <a href="url">downloadPrimary</a>

14-Alexandrite
April 26, 2017

olivier fresse написал(а):

The following code provides the primary content download URL.

// Otherwise, add it in the feedback message, within an <a href="url">downloadPrimary</a>

Thanks, but the question is "how to add url to feedback message".

And the question is relevant for windchill version 11.

15-Moonstone
April 26, 2017

ok,

in your processor, you have a doOperation method. It returns a FormResult object. :

replace the "message" string with the html code to download the content, it should be ok.

import com.ptc.core.components.beans.ObjectBean

import com.ptc.core.components.forms.FormResult

import com.ptc.core.components.util.FeedbackMessage

import com.ptc.core.ui.resources.FeedbackType

import com.ptc.netmarkets.util.beans.NmCommandBean

FormResult doOperation(NmCommandBean nmCommandBean, List<ObjectBean> objectBeans) {

  FormResult formResult = super.doOperation(nmCommandBean, objectBeans);

   // do the job...


   formResult.addFeedbackMessage(

   new FeedbackMessage(

  FeedbackType.SUCCESS,

  nmCommandBean.getLocale(),

   "Title",

   null,

   "message"));

   return formResult;

}

14-Alexandrite
April 26, 2017

It works in windchill 10, but it does not in windchill 11.

HTML tags do not work, they looked like text in message.

inline message html.png

15-Moonstone
April 26, 2017

Hmm I see, same thing with workflow activities.

There is probably an html tag filtering to prevent xss attacks

Not sure it can be bypassed