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

Community Tip - Want the oppurtunity to discuss enhancements to PTC products? Join a working group! X

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

manoj_dokku2
12-Amethyst

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

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

 

ACCEPTED SOLUTION

Accepted Solutions

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

 

 

View solution in original post

9 REPLIES 9

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

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

You can use same above API by replacing 

WTChangeActivity2Master.class 

by WTObject. 

Hello @Ajit_Kulkarni 

I'm not sure if this object has a number clasification that can be return by query

The object has just three methods that can be returned 

getDisplayIdentity ()

getDisplayType ()

getDisplayIdentifier()

 

I will check. 

 

PetrH

I agree with you. My point was to use the basic or root object. So in your case you may use Persistable 

hello @Ajit_Kulkarni and @manoj_dokku2 

Unfortunately the WTObject.class can not be used to search by number. 

 

error are presented in two cases

A persistence error occurred. System message follows:

one case searchcondition contains subtype WTChangeRequest2Master> 
Nested exception is: wt.introspection.WTIntrospectionException: number column not found for V_ChangeIssueResource.

second case search condition contains root object WTObject> 
Attribute "number" is not a member of class "class wt.fc.WTObject" Nested exception is: wt.util.WTPropertyVetoException: Attribute "number" is not a member of class "class wt.fc.WTObject" Nested exception is: wt.pom.PersistenceException: A persistence error occurred. System message follows: Nested exception is: wt.introspection.WTIntrospectionException: number column not found for wt.fc.WTObject --> N/A.

 

So if you need to search all existing objects, you have to define all subtypes in the query.

Also some type of object has a condition parameter number and some of them has master>number

and this will case may troubles.

 

So In my opinion a general API to search in all unique numbers in the system do not exist.

You have to write own function where you define all master types. 

 

PetrH

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

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

 

 

I will share the solution which i have attained.

Announcements

Top Tags