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

Community Tip - If community subscription notifications are filling up your inbox you can set up a daily digest and get all your notifications in a single email. X

Translate the entire conversation x

API to create Plan under Product Context

VJ_12681392
4-Participant

API to create Plan under Product Context

Version: Windchill 12.1

 

Use Case: Create Plan under product context


Description:

Hello,

I need to create Plan under product, I have tried below code but still Plan is not getting created. can someone have idea how to create Plan from code -

public static Plan createPlan(WTContainer container) throws WTException {
Plan plan = Plan.newPlan(container.getContainerReference());
PlanHelper.service.createPlan(plan);
return plan;
}



Thanks,
Vedant


@HelesicPetr 

3 REPLIES 3
Fadel
23-Emerald I
(To:VJ_12681392)

try below  : 

WTContainerRef contRef = WTContainerRef.newWTContainerRef( context );

Plan plan = Plan.newPlan( contRef );
plan.setHolder( contRef );
Fede
HelesicPetr
22-Sapphire II
(To:VJ_12681392)

Hi @VJ_12681392 

You have to add a reference to the Product where you want to show the plan.

 

Your code create the Plan, but it is referenced to the organization so you can not see it but in the database the Plan is created. 

 

Here is an example how to set all information from the context

WTContainer container = UtilToSearchTheContext.getWTContainer("AV Test Product"); // own function to get the container
Plan plan = Plan.newPlan(container.getContainerReference());
WTContainerRef reference = WTContainerRef.newWTContainerRef(container);
plan.setName("Plan Name");
plan.setHolder(reference);
plan.setContainer(container);
plan.setContainerReference(reference);
plan.setDomainRef(container.getDomainRef());
Plan newPlan = (Plan) PlanHelper.service.createPlan(plan);

In the end the plan is shown in the product plans table.

 PetrH

Hi @VJ_12681392,

 

I wanted to see if you got the help you needed.

If so, please mark the appropriate reply as the Accepted Solution. It will help other members who may have the same question.
Please note that industry experts also review the replies and may eventually accept one of them as solution on your behalf.
Of course, if you have more to share on your issue, please pursue the conversation. 

 

Thanks,
Anurag 

Announcements

Top Tags