Skip to main content
12-Amethyst
January 13, 2024
Solved

Method to get Assigned Expression

  • January 13, 2024
  • 1 reply
  • 2937 views

Hello all,

 

I'm currently writing a custom JSP to summarise changes resulting from a Change Notice, I've managed to pull all the required data into the report except for Assigned Usage Expression (e.g. 'COLOUR= "GREEN"), which I'm struggling to get, does anyone know of an API method to retrieve this?

 

I've tried:

  • WTPartUsageLink.getExpressionData() - Returns null,  seems to just return the ExpressionData field from the WTPartUsageLink table,  which is completely empty, guess it's a redundant field 
  • ExpressionHelper.getDisplayExpression(Expressionable,  WTContainerRef) - Returns "{Display : "" , invalid: false}", not sure why it's taking a WTContainerRef argument as this shouldn't make a difference to the returned expression, so maybe it's not doing what the method name implies.

CS384380 states that there's no supported API to achieve this, however that's not to say there isn't one available. Worst case, I could always build the expression through QuerySpec, but it feels like reinventing the wheel, if anyone knows of a method for getting the expression then it would be greatly appreciated.

 

Thanks,

 

Graham

Best answer by HelesicPetr

Hi @GrahamV 

It is not so easy to find the correct API

OptionHelper.service.getAllChoices(child, optionSet);

here you can see the API how to get options from your result optionset with wtpart. Also try to use the Usage link as a input

 

OptionSet optionSet = result1.getOptionSet();
WTList[] choices = OptionHelper.service.getAllChoices(child, optionSet);

 

HelesicPetr_0-1705474928404.png

Here is my working code

You can create reference from WTPart or UsageLink and combinate it.

 

ObjectReference ref1 = ObjectReference.newObjectReference(wtpLink); WTPartUsageLink
ObjectReference ref2 = ObjectReference.newObjectReference(subpart); WTPart
OptionSetDelegateResult result1 = OptionHelper.service.getAssignedOptionSet(ref1, ref2);
OptionSet optionSet = result1.getOptionSet();
WTList[] choices = OptionHelper.service.getAllChoices(wtpLink, optionSet); // result for specific usageLink

 

PetrH

 

1 reply

HelesicPetr
22-Sapphire II
22-Sapphire II
January 15, 2024

Hi @GrahamV 

Where is the expression assigned? WTpart, UsageLink? difference place ? 

 

Here are apis that can be used

//with WTReference 
OptionHelper.service.getAssignedOptionSet(WTReference var0,WTReference var1);
//with colletion
OptionHelper.service.getAssignedOptionSets(WTColletion var1);

PetrH

GrahamV12-AmethystAuthor
12-Amethyst
January 15, 2024

Hi Petr, 

 

I'm trying to retrieve the Assign Usage Exapression (i.e. the expression associated to WTPartUsageLink), though I suspect the same method will also work for other Expressionable objects like WTParts.

 

The methods you listed appear to get the Assigned Option Set rather than the Assigned Usage Expression, so I don't think that's what I'm after, it may come in useful though.

 

Thanks,

 

Graham

HelesicPetr
22-Sapphire II
22-Sapphire II
January 16, 2024

Hi @GrahamV 

What Assigned Usage expression are you talking about?

The Assigned Usage Expressions are from the OptionsSets and the API retrieve it as you can see it in the Uses tab in the Structure.

HelesicPetr_0-1705390726912.png

HelesicPetr_1-1705391015535.png

If you use WTReference where you put usage link you will get what is in that usage link assigned. 

Or you can put first reference as a parent and second reference as a child WTPart and you would get again the Assigned Usage Expressions

PetrH