Skip to main content
15-Moonstone
February 4, 2024
Solved

How can I get the "SOFPART" attribute value of the document type object in the promotion?

  • February 4, 2024
  • 2 replies
  • 4688 views

How can I get the "SOFPART" attribute value of the document type object in the promotion?

SOFPART contains multiple string values

 

I wrote a code to deal with this situation, but the attribute value is empty. Where am I making a mistake?

CODE:

 

try {
 wt.maturity.PromotionNotice pn = (wt.maturity.PromotionNotice) primaryBusinessObject;
 wt.fc.QueryResult qr = wt.maturity.MaturityHelper.service.getBaselineItems(pn);
 
 while (qr.hasMoreElements()) {
 java.lang.Object obj=(java.lang.Object)qr.nextElement();

 if (obj instanceof wt.doc.WTDocument) {
 wt.doc.WTDocument wtdoc = (wt.doc.WTDocument) obj;
 wt.content.ContentHolder contentHolder = wt.content.ContentHelper.service.getContents(wtdoc);
 wt.content.ContentItem item = wt.content.ContentHelper.getPrimary((wt.content.FormatContentHolder) contentHolder);
 com.ptc.core.lwc.server.PersistableAdapter persistableAdapter = new com.ptc.core.lwc.server.PersistableAdapter(wtdoc, null, java.util.Locale.getDefault(), new com.ptc.core.meta.common.UpdateOperationIdentifier());
 persistableAdapter.load("SOFPART");
 SOFPART = (java.lang.String) persistableAdapter.get("SOFPART");
 }
 }
} catch (Exception wte) {
 wte.printStackTrace();
}

 

 

Best answer by HelesicPetr

Hi @joe_morton 

In his case there is a issue with the retyping the result object.

SOFPART = (java.lang.String) obj2.get("SOFPART");

 If the attribute contains multi values the return object is an array with a string not a String so this is the case why his final variable is empty.

PetrH

2 replies

avillanueva
23-Emerald I
23-Emerald I
February 4, 2024

Is "SOFTPART" an IBA on the WTDocument? Or are you trying to get the name a soft typed sub-type of WTDocument? If its an IBA, I can post code for that. Might already be posted. Also looks like you are interrogating the primary content of the WTDocument. Why? Attributes should not be part of the content file.

smcvr15-MoonstoneAuthor
15-Moonstone
February 5, 2024

Hi @avillanueva,

 

"SOFTPART" is an IBA in WTDocument

avillanueva
23-Emerald I
23-Emerald I
February 5, 2024
18-Opal
April 3, 2024

Why not clearly state the problem when you initially post?

Your post is a bit ambiguous.