Skip to main content
12-Amethyst
December 5, 2023
Solved

'Soft' autonumbering inside a context - is there a simple way of doing this?

  • December 5, 2023
  • 1 reply
  • 1450 views

I have been contemplating a way to provide 'local' autonumbering, but inside contexts- rather than using global database sequences to drive autonumbering, is there a way of having local iterative numbering without creating as many sequences as there are contexts?

For example, you could achieve this based on whether a specific number is already in use?

e.g. a specific context might start with an unique prefix, such as a product ID, and a subtype initial e.g.
1111_DOC_*.
The rest of the number could then be determined by whether the number is already is use e.g. if 1111_DOC_001 exists, try 1111_DOC_002, then *_003, until successful.

I figured this could be possible, since when manually numbering objects, the 'number already in use' response is rather quick- though maybe not efficient enough to not overburden the system with requests when it needs to check if 900 numbers are valid to create before creating 1111_DOC_901.
You could speed up execution by writing a custom java RuleAlgorithm class that provides numbers based on existing numbers in the system, but configuration purely inside the OIR with no custom class would be even better.

I am well aware the best practice is to inject minimal intelligence into your document numbering as possible, therefore go with e.g. DOC_000001 as the number sequence. This is what I'm currently recommending as well. It does however seem relevant to want context-specific numbering in some cases, all under the same wtobject subtype so they can be searched globally.

Best answer by icelynnin

Thanks- this would amount to "writing a custom java RuleAlgorithm class that provides numbers based on existing numbers in the system" that I suggested, right?

This is very achievable but then requires the effort to know the windchill java API and classes to find how to check valid object numbers etc.

1 reply

Fadel
23-Emerald I
December 6, 2023

you can create your own custom NumberGenerator with the required logic and call it in OIR

Buiꓘa
icelynnin12-AmethystAuthorAnswer
12-Amethyst
December 6, 2023

Thanks- this would amount to "writing a custom java RuleAlgorithm class that provides numbers based on existing numbers in the system" that I suggested, right?

This is very achievable but then requires the effort to know the windchill java API and classes to find how to check valid object numbers etc.

Fadel
23-Emerald I
December 6, 2023

You can take a look at https://www.ptc.com/en/support/article/CS140636 , just start in your code and open a TS call if needed, we in TS will be glad to assist you further . 

Buiꓘa