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

setContainer in a Workflow

SOLVED
Newbie

setContainer in a Workflow

Hi everyone,

i would like to set the container for an object within an Workflow. Can I use the "setContainer" methode and declare the path for the container directly in that methode? And how do I phrase such a path declaration for a container ?

(I do not want to use the primaryBusinessObject for this)

Can anybody please help me?

Thank you for your help.

Best Regards,

Willi

1 ACCEPTED SOLUTION

Accepted Solutions

Re: setContainer in a Workflow

Hello Willi,

Suppose your container is PDMLinkProduct and the object is WTPart.

Then you can do it like.

ReferenceFactory factory = new ReferenceFactory();

ObjectReference objRef = (ObjectReference)factory.getReference("OR: wt.pdmlink.PDMLinkProduct:162524”);

PDMLinkProduct product=(( PDMLinkProduct) objRef.getObject());

part.setContainer(product);

Where "wt.pdmlink.PDMLinkProduct:162524" is the object reference or OR of the product.

To use the setContainer method you have to give the object of WTContainer.

If you know only the name of the container then you can also use QuerySpec to get the object

View solution in original post

6 REPLIES 6

Re: setContainer in a Workflow

Hello Willi,

Suppose your container is PDMLinkProduct and the object is WTPart.

Then you can do it like.

ReferenceFactory factory = new ReferenceFactory();

ObjectReference objRef = (ObjectReference)factory.getReference("OR: wt.pdmlink.PDMLinkProduct:162524”);

PDMLinkProduct product=(( PDMLinkProduct) objRef.getObject());

part.setContainer(product);

Where "wt.pdmlink.PDMLinkProduct:162524" is the object reference or OR of the product.

To use the setContainer method you have to give the object of WTContainer.

If you know only the name of the container then you can also use QuerySpec to get the object

View solution in original post

Re: setContainer in a Workflow

Hi kaushik das,

thanks for your quick response. Your answer does make sense. I tried to implement the code in an expression robot, but as soon as I started to check the syntax the compiler issued an error, saying that he cannot find the symbol. I posted the error message below:

d:\ptc\Windchill\temp\WfExpression300436.java:29: cannot find symbol

symbol : method newReferenceFactory()

location: class wt.fc.ReferenceFactory

wt.fc.ReferenceFactory fac = wt.fc.ReferenceFactory.newReferenceFactory();

^

1 error

I tried to change the package request as follows, but it didn't help:

wt.fc.ReferenceFactory fac = wt.fc.ReferenceFactory.newReferenceFactory();

He still cannot find the symbol.

Do you have any idea how to implement the code?

Thanks again for your help.

Re: setContainer in a Workflow

Hello Willi,

Try it like this wt.fc.ReferenceFactory factory = new wt.fc.ReferenceFactory();

You are calling the constructor not any static method.

When you write like this wt.fc.ReferenceFactory fac = wt.fc.ReferenceFactory.newReferenceFactory();

It means you are calling a static method named newReferenceFactory() of ReferenceFactory class.

Hope this will solve your problem.

Re: setContainer in a Workflow

Hi kaushik das,

that solves my problem, thank you!

Earlier, in your other post, you mentioned that I can use QuerySpec to get the object I need, if I only know the name of the container and not the number.

How do I have to phrase the code in order to use QuerySpec for a product container?

Thank you again for your help.

I appreciate it.

Willi

Re: setContainer in a Workflow

HI Willi Hartmann,

If you dont know the OR but you know the name then you can use the following code to get an object of PDMLinkProduct.

QuerySpec qs = new QuerySpec(PDMLinkProduct.class);

PDMLinkProduct pt = null;

qs.appendWhere(new SearchCondition(PDMLinkProduct.class,PDMLinkProduct.NAME,SearchCondition.EQUAL,"PRODUCT NAME"),new int[] { 0 });

QueryResult qr = PersistenceHelper.manager.find((StatementSpec)qs);

System.out.println(qr.size());

while(qr.hasMoreElements())

{

pt = (PDMLinkProduct)qr.nextElement();

}

Thanks

Kaushik

Re: setContainer in a Workflow

Hi Kaushik,

thanks a lot for your response and the useful code. That really solved my problem. You saved my life

Thanks again.

Willi