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

Web URL search query by 'NUMBER'

SOLVED
rpugliese
Newbie

Web URL search query by 'NUMBER'

Hi,

My company use Windchill 10.0, i'm looking for a method to perform a URL based request that searches for a document by its 'number'.

It can either bring up the search results as it does when you use 'advanced search' or provide the direct link to the document (ie. ...infoPage?oid=VR%3Awt.doc.WTDocument%3A7513658&u8=1)


I've tried this URL request, but I get an error;

https://(server)/Windchill/app/#ptc1/tcomp/infoPage?oid=OR%3Awt.doc.WTDocument?number="CR107*"


Error:

Status Code: 501

Message: Object "{0}" is not persistent.


Thanks

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Web URL search query by 'NUMBER'

I don't think you can pass on the search criteria to any of the existing Windchill URLs. I think the best option is to create a JSP file which receives the document name, lookup the object and construct a URL and direct the page information page. Below is a code snippet which gives you the URL to latest version of wtdocument.

try {

  System.out.println("Entered Search Method");

  QuerySpec qSpec = new QuerySpec(wt.doc.WTDocumentMaster.class);

  qSpec.appendWhere(new SearchCondition(wt.doc.WTDocumentMaster.class, WTDocumentMaster.NAME , SearchCondition.EQUAL, "First Test Document in Production"), null);

  QueryResult qResult = PersistenceHelper.manager.find((StatementSpec)qSpec);

  System.out.println("Number of Master Results found : " + qResult.size());

  while (qResult.hasMoreElements()) {

  wt.doc.WTDocumentMaster obj = (wt.doc.WTDocumentMaster)qResult.nextElement();

  QueryResult qLatest = ConfigHelper.service.filteredIterationsOf(obj,new LatestConfigSpec());

  if(qLatest.hasMoreElements())

  {

     wt.doc.WTDocument latObj = (wt.doc.WTDocument) qLatest.nextElement();

     if(latObj!=null){   

  wt.doc.WTDocument latDoc = (wt.doc.WTDocument)wt.vc.VersionControlHelper.service.getLatestIteration(latObj,true);       

  com.ptc.netmarkets.model.NmOid objectID = new com.ptc.netmarkets.model.NmOid("WTDocument", latDoc.getPersistInfo().getObjectIdentifier());

  com.ptc.netmarkets.util.beans.NmURLFactoryBean URLbean = new com.ptc.netmarkets.util.beans.NmURLFactoryBean();

  String url = NetmarketURL.buildURL(URLbean, "object", "view", objectID);

  System.out.println("URL to document " + latDoc.getName() + "  is : " + url);

  }

  }

  }

  }

  catch(WTException e)

  {

  e.printStackTrace();

  }

  }

View solution in original post

6 REPLIES 6

Re: Web URL search query by 'NUMBER'

Roberto,

PTC Live Global section it is not the right place to get an answer for your request.

I'll ask Ryan Kelley‌ to move your discussion in Windchill section.

Marco

Re: Web URL search query by 'NUMBER'

Thanks for notifying me Marco, I've moved this discussion into our PTC Windchill‌ product community.

Re: Web URL search query by 'NUMBER'

I don't think you can pass on the search criteria to any of the existing Windchill URLs. I think the best option is to create a JSP file which receives the document name, lookup the object and construct a URL and direct the page information page. Below is a code snippet which gives you the URL to latest version of wtdocument.

try {

  System.out.println("Entered Search Method");

  QuerySpec qSpec = new QuerySpec(wt.doc.WTDocumentMaster.class);

  qSpec.appendWhere(new SearchCondition(wt.doc.WTDocumentMaster.class, WTDocumentMaster.NAME , SearchCondition.EQUAL, "First Test Document in Production"), null);

  QueryResult qResult = PersistenceHelper.manager.find((StatementSpec)qSpec);

  System.out.println("Number of Master Results found : " + qResult.size());

  while (qResult.hasMoreElements()) {

  wt.doc.WTDocumentMaster obj = (wt.doc.WTDocumentMaster)qResult.nextElement();

  QueryResult qLatest = ConfigHelper.service.filteredIterationsOf(obj,new LatestConfigSpec());

  if(qLatest.hasMoreElements())

  {

     wt.doc.WTDocument latObj = (wt.doc.WTDocument) qLatest.nextElement();

     if(latObj!=null){   

  wt.doc.WTDocument latDoc = (wt.doc.WTDocument)wt.vc.VersionControlHelper.service.getLatestIteration(latObj,true);       

  com.ptc.netmarkets.model.NmOid objectID = new com.ptc.netmarkets.model.NmOid("WTDocument", latDoc.getPersistInfo().getObjectIdentifier());

  com.ptc.netmarkets.util.beans.NmURLFactoryBean URLbean = new com.ptc.netmarkets.util.beans.NmURLFactoryBean();

  String url = NetmarketURL.buildURL(URLbean, "object", "view", objectID);

  System.out.println("URL to document " + latDoc.getName() + "  is : " + url);

  }

  }

  }

  }

  catch(WTException e)

  {

  e.printStackTrace();

  }

  }

View solution in original post

Re: Web URL search query by 'NUMBER'

I agree with Binesh.  You can implement this by creating a custom JSP file.  I have implemented something like this several months ago.  It works well, but you'll need to keep in mind that anyone with this link might not be able to actually view it due to permissions after they log in.  In addition, it is truly getting you the latest - even if it is not in your RELEASED or PRODUCTION state.

An example of my URL:

http://server:port/Windchill/netmarkets/jsp/Custom/InfoPageLatestVersion.jsp?number=EXAMPLEDRAWING.D...

where InfoPageLatestVersion.jsp is my JSP file in that location, and type can be epmDoc or wtDoc, for example.

Re: Web URL search query by 'NUMBER'

We are implementing something similar to what Ben and Binesh have mentioned. We are writing a QueryBuilder report and calling it from a custom JSP. We are using this custom JSP for launching other Query Builder reports as well, so the JSP just takes in the name of the Query Builder report and launches it. Once the criteria page for the report displays, the user can enter the document number they want.

Re: Web URL search query by 'NUMBER'

Thanks All, that's exactly what I was after.

Announcements