Skip to main content
12-Amethyst
April 25, 2022
Solved

Is there any API to get any object from a given number which is unique.

  • April 25, 2022
  • 1 reply
  • 4741 views

Is there any API to get any object from a given number which is unique.

 

it should show results of objects, for the given (any unique)number as shown in the advanced search.

 

Dokku_Manoj_0-1650891558422.png

 

Best answer by HelesicPetr

Hi @manoj_dokku2 

I don't think so. It is not easy as you think.

The helper has a getPersistable() function where String is input but this string is defined as a type identification and OID it is not object Number

example> OR:wt.part.WTPart:26891877

 

Also if the advanced search is activated in a explorer, there is full list of searchable types as a parameter in a function. And the function is hardcoded :D.

 

I can't see simple function there that just search for Numbers.

 

PetrH

 

 

1 reply

HelesicPetr
22-Sapphire II
22-Sapphire II
April 25, 2022

Hello @manoj_dokku2 

If you define correctly QuerySpec defintion, then you can use 

 

PersistenceHelper.manager.find(QuerySpec QS)

 

QuerySpec spec = new QuerySpec(WTChangeActivity2Master.class);
spec.appendWhere(new SearchCondition(WTChangeActivity2Master.class,
WTChangeActivity2Master.NUMBER, SearchCondition.EQUAL, number), new int[]{0});

QueryResult qr = PersistenceHelper.manager.find((StatementSpec) spec);
if (qr.hasMoreElements())

 

I don't know another universal API.

I would define all types if I need to search all objects. 

 

PetrH

12-Amethyst
April 25, 2022

Thanks for the reply @HelesicPetr , I'm looking for generic query which will give the object if we pass the number(any) from Windchill.

12-Amethyst
April 26, 2022

@HelesicPetr , I think it can be done through "com.ptc.windchill.enterprise.search.server.SearchHelper"