Skip to main content
1-Visitor
July 5, 2013
Solved

setContainer in a Workflow

  • July 5, 2013
  • 6 replies
  • 2875 views

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

Best answer by KD_01

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

6 replies

KD_0112-AmethystAnswer
12-Amethyst
July 5, 2013

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

MaBau1-VisitorAuthor
1-Visitor
July 8, 2013

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.

12-Amethyst
July 9, 2013

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.