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

Community Tip - Learn all about the Community Ranking System, a fun gamification element of the PTC Community. X

How to get sequence number in Windchill through API?

JH_10735852
2-Explorer

How to get sequence number in Windchill through API?

Hello,

 

I want to know that how to get sequence number for WT.Part or Wt.Document in windchill through API?

When I create WT.Part number automatically generated. But I can not find any method that returns the next number. I am using Info.Engine. Please help me to fix. Any suggestions would be appreciated. Thanks.! 

ACCEPTED SOLUTION

Accepted Solutions

Hi @JH_10735852 

this is example, how to do so...

you need to know type of object and container reference because it takes a rules from OIR

 

WTContainerRef containerReferencetest = nmCommandBean.getContainerRef();
WTDocument doc = WTDocument.newWTDocument();
TypeDefinitionReference tdr = TypedUtility.getTypeDefinitionReference("my.Own.SubType");
if (tdr == null)
{
tdr = TypedUtility.getTypeDefinitionReference("com.ptc.ReferenceDocument");
	}
	try
	{
	doc.setTypeDefinitionReference(tdr);
} catch (WTPropertyVetoException e)
{
			e.printStackTrace();
		}
try
{
	String generatedNumber = EnterpriseHelper.getNumber(doc, containerReferencetest);
} catch (WTException ex)
{
}

 

Hope this can help

 

PetrH

View solution in original post

4 REPLIES 4

Hi @JH_10735852 

this is example, how to do so...

you need to know type of object and container reference because it takes a rules from OIR

 

WTContainerRef containerReferencetest = nmCommandBean.getContainerRef();
WTDocument doc = WTDocument.newWTDocument();
TypeDefinitionReference tdr = TypedUtility.getTypeDefinitionReference("my.Own.SubType");
if (tdr == null)
{
tdr = TypedUtility.getTypeDefinitionReference("com.ptc.ReferenceDocument");
	}
	try
	{
	doc.setTypeDefinitionReference(tdr);
} catch (WTPropertyVetoException e)
{
			e.printStackTrace();
		}
try
{
	String generatedNumber = EnterpriseHelper.getNumber(doc, containerReferencetest);
} catch (WTException ex)
{
}

 

Hope this can help

 

PetrH

If it were me, I would write code that connects directly to the dB and queries the sequences in question.

In the example below I pass the object name (wtpart and wtdocument - the code is case insensitive) I'm interested in, and the next number in the sequence is returned.

Here's the thing, Windchill is not even running and you still get the data as long as the dB is running.

The code is very simple and it's bombproof.

d_graham_1-1689191594838.png

The OIR will have the final say of course in the object's number, but if you're looking for the next number in the sequence, well, numbers don't lie. 😀

 


@JH_10735852 wrote:

Hello,   mcdvoice

 

I want to know that how to get sequence number for WT.Part or Wt.Document in windchill through API?

When I create WT.Part number automatically generated. But I can not find any method that returns the next number. I am using Info.Engine. Please help me to fix. Any suggestions would be appreciated. Thanks.! 


@HelesicPetr Thanks for the quick and best response. Really your answer is worked well for me. I appreciate your solution.  

Would you consider to mark this thread as solved, giving @HelesicPetr the credit he deserves and helping others with a similar problem later? Thanks. It's all for the community.

Announcements


Top Tags