cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - When posting, your subject should be specific and summarize your question. Here are some additional tips on asking a great question. X

Translate the entire conversation x

How to get the view of the WTPart in workflow ?

K_Patil
10-Marble

How to get the view of the WTPart in workflow ?

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 ?
ACCEPTED SOLUTION

Accepted Solutions
HelesicPetr
22-Sapphire II
(To:K_Patil)

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

View solution in original post

5 REPLIES 5
HelesicPetr
22-Sapphire II
(To:K_Patil)

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

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
(To:K_Patil)

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

Hi @HelesicPetr , 

 

Thank you so much, resolved the issue. 

avillanueva
22-Sapphire III
(To:K_Patil)

Great job @HelesicPetr 

Announcements
Top Tags