How to use Indexed-Search webject to return objects filtered by access permissions in Windchill PDMLink?

How to use Indexed-Search webject to return objects filtered by access permissions in Windchill PDMLink?

Add Comment
1 Answer(s)
  • Use the Search-Index webject in conjunction with Search-Objects by sending to the later the ufids returned by the former for filtering
  • Example:
<?xml version="1.0" standalone="yes"?>
<%@taglib uri="http://www.ptc.com/infoengine/taglib/core" prefix="ie"%>
<%@page access="internal|http"%>


   <% String searchTypes="wt.doc.WTDocument";%>
   <% String searchAttribs="number,name,versionInfo.identifier.versionId,iterationInfo.identifier.iterationId,containerName";%>
   <%
      Integer MAX_RESULTS = 30;
      Integer start = 1;
      Integer count = MAX_RESULTS;
      if(count.intValue() <= 0) count = null;
      
      String keyword = (String)getParam("keyword");
      String ufids = "";
      if(!(keyword.equals("*") || keyword.equals("%") || keyword.equals("")))
      {
   %>
         <ie:webject name="Indexed-Search" type="OBJ">
            <ie:param name="INSTANCE"      data="${@FORM[]supporting-adapter[*]}" valueSeparator=";" delim=";" default="ts.ptc.wncx24.Windchill"/>
            <ie:param name="KEYWORD"       data="${@FORM[]keyword[]}"/>
            <ie:param name="LIBRARIES"      data="${@FORM[]LIBRARIES[]}" delim=","/>
            <ie:param name="ATTRIBUTE_TYPE_CONTEXT" data="${@FORM[]attributeTypeContext[*]}" default="wt.fc.Persistable"/>
            <ie:param name="AND_OR_OPERATOR" data="SIMPLEALL" />
            <ie:param name="TYPE"         data="${@FORM[]SearchTypes[]}" delim="," default="<%=searchTypes%>"/>
            <ie:param name="GROUP_FORM"    data="@FORM"/>
            <ie:param name="FILTER_ACCESS" data="true" />
            <ie:param name="group_out" data="index_search"/>
            <ie:param name="UNFORMATTED" data ="java.sql.Timestamp" />
         </ie:webject>
      <%
         Group index_results = getGroup("index_search");
         int idx_count = index_results.getElementCount();
         for(int i = 0; i < idx_count; i++)
         {
            String ufid = (String)index_results.getElementAt(i).getValue("obid");
            if(ufid != null && ufid.length() > 0)
            {
               if(ufids.length() > 0) ufids += ",";
               ufids += ufid;
            }
         }
      }
   %>
   <ie:webject name="Search-Objects" type="OBJ">
     <ie:param name="INSTANCE" data="${@FORM[]supporting-adapter[*]}" valueSeparator=";" delim=";" default="windchill"/>
     <ie:param name="ATTRIBUTE" data="${@FORM[]SearchAttributes[]}" delim="," default="<%=searchAttribs%>"/>
     <ie:param name="ATTRIBUTE_TYPE_CONTEXT" data="${@FORM[]attributeTypeContext[*]}" default="wt.fc.Persistable"/>
     <ie:param name="TYPE" data="${@FORM[]SearchTypes[]}" delim="," default="<%=searchTypes%>"/>
     <% if(ufids.length() == 0) { %>
      <ie:param name="KEYWORD" data="${@FORM[]keyword[]}"/>
     <% } %>
     <ie:param name="PAGE_OFFSET" data="<%=start%>" />
     <% if (count != null ) { %><ie:param name="PAGE_COUNT" data="<%=count+1%>" /><% } %>
     <ie:param name="WHERE" data="(${@FORM[]AttributeFilter[]})" />
     <ie:param name="GROUP_FORM" data="@FORM"/>
     <ie:param name="group_out" data="output"/>
     <ie:param name="FORMAT" data="true"/>
     <ie:param name="INCLUDE_DESCRIPTORS" data="false"/>
     <ie:param name="UNFORMATTED" data ="java.sql.Timestamp" />
     <% if(ufids.length() > 0) { %><ie:param name="OBJECT_REF" data="<%=ufids%>" delim="," /><% } %>
                 <ie:param name="SORTBY" data="${@FORM[]SortBy[*]}" delim="," default="name" />
                 <ie:param name="SORTED" data="${@FORM[]SortDirection[]}" default="ASC" />

   </ie:webject>

 

Answered on February 12, 2019.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.