Skip to main content
1-Visitor
July 12, 2023
Solved

How to get sequence number in Windchill through API?

  • July 12, 2023
  • 3 replies
  • 2218 views

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.! 

Best answer by HelesicPetr

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

3 replies

HelesicPetr
22-Sapphire II
22-Sapphire II
July 12, 2023

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

18-Opal
July 12, 2023

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. 😀

 

1-Visitor
July 13, 2023

@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.  

13-Aquamarine
July 13, 2023

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.