Skip to main content
11-Garnet
January 22, 2025
Solved

How to get the view of the WTPart in workflow ?

  • January 22, 2025
  • 1 reply
  • 904 views
Hi, 
I want to get the view of the WTPart in workflow to compare if it is "Design" or "manufacturing". 
 
I used below code in workflow execute expression robot. 
====
if (primaryBusinessObject instanceof wt.part.WTPart) {
    wt.part.WTPart part = (wt.part.WTPart) primaryBusinessObject;
    wt.vc.views.View view = (wt.vc.views.View) part.getView().getObject();
 
if(view != null && view.equals("Design")){
result = "Go";
}else{
result = "NoGo";
}
====
 
On syntax check it work, 
However, if i add workflow variable i got below error on syntax check.
===
Checking Syntax...
warning: Supported source version 'RELEASE_7' from annotation processor 'com.microsoft.azure.management.apigeneration.LangDefinitionProcessor' less than -source '1.8'
WfExpression_1315495121.java:129: error: variable view is already defined in method executemethod_1(Object[],Object[])
    wt.vc.views.View view = (wt.vc.views.View) part.getView().getObject();
                     ^
Note: WfExpression_1315495121.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
1 error
1 warning
 
Syntax check complete.
 
====
 
Can someone please guide me ?
Best answer by HelesicPetr

Hi @K_Patil 

What Windchill version do you use?

btw, where the variable partName is defined? 

Do you define this variable in the workflow variable? if so, then you can not define it again in your code.

If I create global workflow variable, then I get same error as you.

HelesicPetr_0-1737618966457.png

HelesicPetr_1-1737618989909.png

 

if the variable is defined as a global then you can not define it again. 

instead of wt.vc.views.View partName = ........

use just partName = (wt.vc.views.View) part.getView().getObject();

 

HelesicPetr_2-1737619073656.png

 

PetrH

1 reply

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

Hi @K_Patil 

Check the name of variable, it can not be same as the defined object wt.vc.views.View view

 

the error tells you that you have two declarations of the same variable and it can not be used.

 

PS> the view variable is a object type wt.vc.views.View so you can not compare the vale to a string "Design" that way as you try.

you can compare two strings not String with wt.vc.views.View. Try to use view.getName();

PetrH

K_Patil11-GarnetAuthor
11-Garnet
January 23, 2025

Hi @HelesicPetr , 

I tried to adopt it, but it is still the same. 

======

if (primaryBusinessObject instanceof wt.part.WTPart) {
wt.part.WTPart part = (wt.part.WTPart) primaryBusinessObject;
wt.vc.views.View partName = (wt.vc.views.View) part.getView().getObject();

if (partName != null && "Design".equals(partName.getName())) {
result = "Go";
} else {
result = "NoGo";
}
}

====================

 

Checking Syntax...
warning: Supported source version 'RELEASE_7' from annotation processor 'com.microsoft.azure.management.apigeneration.LangDefinitionProcessor' less than -source '1.8'
WfExpression_1315495121.java:129: error: variable partName is already defined in method executemethod_1(Object[],Object[])
wt.vc.views.View partName = (wt.vc.views.View) part.getView().getObject();
^
Note: WfExpression_1315495121.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
1 error
1 warning

Syntax check complete.


can you please check ?

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

Hi @K_Patil 

What Windchill version do you use?

btw, where the variable partName is defined? 

Do you define this variable in the workflow variable? if so, then you can not define it again in your code.

If I create global workflow variable, then I get same error as you.

HelesicPetr_0-1737618966457.png

HelesicPetr_1-1737618989909.png

 

if the variable is defined as a global then you can not define it again. 

instead of wt.vc.views.View partName = ........

use just partName = (wt.vc.views.View) part.getView().getObject();

 

HelesicPetr_2-1737619073656.png

 

PetrH