guru@windchillguru.com's Profile

2670
Points

Questions
15

Answers
26

  • Asked on April 9, 2019 in Windchill PLM.

    Unfortunately, Windchill has no API’s to change the Creator once the object is created, but you can change the session user before the object is persisted, then the persistence layer will consider the user from Session.

    • 246 views
    • 1 answers
    • 0 votes
  • Asked on April 4, 2019 in Windchill PLM.

    Hello,

     

    As per the windchill architecture, WFBlock’s can contain one or more activities and these activities can be general AssignedActivity or AdhocActivity, so in order to get the access for AdhocActivities you need to first provide “Read” access to WFBlock and then if you have provided “Read” access to AdhocSctivity then the user will not get the above-mentioned error.

    Hope this helps.

    • 162 views
    • 1 answers
    • 0 votes
  • Asked on February 12, 2019 in Windchill PLM.

    There is no Supported API’s to perform Operations involving sharing objects to project link.

    below is a sample that can be used.

    wt.inf.sharing.DataSharingHelper.service.createShares() 
    public WTCollection createShares(WTCollection objsToShare, WTContainerRef to_container_ref, Folder to_folder, ShareKind kind, State state, boolean is_shortcut) throws WTException

    Example Usage:

    ObjectIdentifier oid = null;
    try {
      oid = ObjectIdentifier.newObjectIdentifier("wt.part.WTPart:XXXXX");
      wt.part.WTPart record = (wt.part.WTPart) PersistenceHelper.manager.refresh(oid);
      oid = ObjectIdentifier.newObjectIdentifier("wt.projmgmt.admin.Project2:XXXX");
      WTContainerRef projRef = WTContainerRef.newWTContainerRef(oid);
      WTSet objs = new WTHashSet(1, CollectionsHelper.OBJECT_IDENTIFIER);
      objs.add(record);
      WTCollection share = DataSharingHelper.service.createShares(objs, projRef, null, ShareKind.OBJECT, null, false);
    } catch(WTException e) { 
    // TODO Auto-generated catch block                   
    e.printStackTrace();            
    }

     

    • 306 views
    • 1 answers
    • 0 votes
  • Asked on February 12, 2019 in Windchill PLM.
    • 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>

     

    • 456 views
    • 1 answers
    • 0 votes
  •  

     

    String parentPartNumber;
    String ParentPartName;
    String partNumber;
    String PartName;
    
    QuerySpec spec = new QuerySpec();
    
    spec.setAdvancedQueryEnabled(true);
    
    int WTPartMasterIndex = spec.addClassList(wt.part.WTPartMaster.class, true);
    
    int WTPartUsageLinkIndex = spec.addClassList(wt.part.WTPartUsageLink.class, true);
    
    int partIndex = spec.appendClassList(wt.part.WTPart.class, true);
    
    SearchCondition where = new SearchCondition(new ClassAttribute(wt.part.WTPartMaster.class,
      "thePersistInfo.theObjectIdentifier.id"), SearchCondition.EQUAL,
     new ClassAttribute(wt.part.WTPartUsageLink.class, "roleBObjectRef.key.id"));
    
    spec.appendWhere(where, new int[] {
     WTPartMasterIndex,
     WTPartUsageLinkIndex
    });
    
    spec.appendAnd();
    
    SearchCondition where2 = new SearchCondition(new ClassAttribute(wt.part.WTPartUsageLink.class,
      "roleAObjectRef.key.id"), SearchCondition.EQUAL,
     new ClassAttribute(wt.part.WTPart.class, "thePersistInfo.theObjectIdentifier.id"));
    
    spec.appendWhere(where2, new int[] {
     WTPartUsageLinkIndex,
     partIndex
    });
    
    spec.appendAnd();
    
    spec.appendWhere(new SearchCondition(wt.part.WTPart.class, "checkoutInfo.state", SearchCondition.NOT_EQUAL, "wrk"), partIndex);
    spec.appendAnd();
    spec.appendWhere(new SearchCondition(wt.part.WTPart.class, "iterationInfo.latest", "TRUE"), partIndex);
    spec.appendAnd();
    spec.appendWhere(new SearchCondition(wt.part.WTPart.class, wt.part.WTPart.LIFE_CYCLE_STATE, SearchCondition.NOT_EQUAL, "CANCELLED"), partIndex);
    if (parentPartNumber != null && parentPartNumber.trim().length() != 0) {
     spec.appendAnd();
     spec.appendWhere(new SearchCondition(wt.part.WTPart.class,
      "master>number", SearchCondition.LIKE, parentPartNumber + "%"), partIndex);
    }
    
    if (ParentPartName != null && ParentPartName.trim().length() != 0) {
     spec.appendAnd();
     spec.appendWhere(new SearchCondition(wt.part.WTPart.class,
      "master>name", SearchCondition.LIKE, ParentPartName + "%"), partIndex);
    }
    
    if (partNumber != null && partNumber.trim().length() != 0) {
     spec.appendAnd();
     spec.appendWhere(new SearchCondition(wt.part.WTPartMaster.class,
      "number", SearchCondition.LIKE, partNumber + "%"), WTPartMasterIndex);
    }
    
    if (PartName != null && PartName.trim().length() != 0) {
     spec.appendAnd();
     spec.appendWhere(new SearchCondition(wt.part.WTPartMaster.class,
      "name", SearchCondition.LIKE, PartName + "%"), WTPartMasterIndex);
    
    }
    QueryResult result = PersistenceHelper.manager.find(spec);
    while (result.hasMoreElements()) {
     wt.fc.Persistable persistables[] = (wt.fc.Persistable[]) result.nextElement();
     wt.part.WTPart parentPart = (wt.part.WTPart) persistables[partIndex];
     wt.part.WTPartUsageLink usageLink = (wt.part.WTPartUsageLink) persistables[WTPartUsageLinkIndex];
     wt.part.WTPartMaster subPartMaster = (wt.part.WTPartMaster) persistables[WTPartMasterIndex];
    }

     

    • 376 views
    • 1 answers
    • 0 votes
  • public static void sendEmail( String cSVfileName, String fileName2) throws WTException, IOException {
    
      String thePath = null;
      Properties prop = new Properties();
      FileInputStream input = null;
      String theWTCodebaseHome = WTProperties.getLocalProperties().getProperty("wt.codebase.location");
      theWTCodebaseHome = theWTCodebaseHome.replace('\\', '/');
      thePath = theWTCodebaseHome + "/ext/email.properties";
      input = new FileInputStream(thePath);
      prop.load(input);
      String to  = prop.getProperty("EMAIL.TO", "123@test.com").trim();
      // Sender's email ID needs to be mentioned
      String from = prop.getProperty("EMAIL.FROM", "postMaster@abc.com").trim();
      // Assuming you are sending email through relay.jangosmtp.net
      String host = prop.getProperty("EMAIL.HOST", "localhost").trim();
      Date date = new Date();
      SimpleDateFormat sdf = new SimpleDateFormat("MM-dd-yyyy hh:mm:ss");
      sdf.setTimeZone(TimeZone.getTimeZone("America/Chicago"));
      String strDate = sdf.format(date);
      Properties props = new Properties();
      props.put("mail.smtp.auth", "false");
      props.put("mail.smtp.starttls.enable", "false");
      props.put("mail.smtp.host", host);
      props.put("mail.smtp.port", "25");
      // Get the Session object.
      Session session = Session.getInstance(props);
      try {
      // Create a default MimeMessage object.
      Message message = new MimeMessage(session);
      // Set From: header field of the header.
      message.setFrom(new InternetAddress(from));
      // Set To: header field of the header.
      message.setRecipients(Message.RecipientType.TO, InternetAddress.parse(to));
      // Set Subject: header field
      message.setSubject("EMAIL SUBJECT - " + strDate);
      // Create the message part
      BodyPart messageBodyPart = new MimeBodyPart();
      // Now set the actual message
      messageBodyPart.setText("Please see the attached files.");
      // Create a multipar message
      Multipart multipart = new MimeMultipart();
      // Set text message part
      multipart.addBodyPart(messageBodyPart);
      // Part two is attachment
      messageBodyPart = new MimeBodyPart();
      boolean zipExist = false;
      boolean csvExist = false;
      File tempFile = new File(fileName2);
      if (tempFile.exists()) {
      System.out.println(fileName2);
      DataSource source = new FileDataSource(fileName2);
      messageBodyPart.setDataHandler(new DataHandler(source));
      messageBodyPart.setFileName(strDate + ".zip");
      multipart.addBodyPart(messageBodyPart);
      zipExist = true;
      }
      tempFile = new File(cSVfileName);
      if (tempFile.exists()) {
      messageBodyPart = new MimeBodyPart();
      // String filename = "D:\\temp\\test.zip";
      System.out.println(cSVfileName);
      cSVfileName = createXLSFile(cSVfileName);
      DataSource source = new FileDataSource(cSVfileName);
      messageBodyPart.setDataHandler(new DataHandler(source));
      messageBodyPart.setFileName(strDate + ".xls");
      multipart.addBodyPart(messageBodyPart);
      csvExist = true;
      }
      // Send the complete message parts
      message.setContent(multipart);
      Address[] allrec = message.getAllRecipients();
      for (Address ad : allrec) {
      System.out.println(ad);
      }
      // Send message
      Transport.send(message);
      System.out.println("Sent message successfully....");
      } catch (MessagingException e) {
      throw new RuntimeException(e);
      }
      }

     

    Or If you would like to use Windchill API’s to send an email attaching windchill objects ( not external file attachments ) use below code snippet.

    wt.fc.ObjectIdentifier oid = wt.fc.ObjectIdentifier.newObjectIdentifier("wt.part.WTPart:xxxxx");
    wt.part.WTPart wtpart = (wt.part.WTPart)PersistenceHelper.manager.refresh(oid);
    EMailMessage localEMailMessage=EMailMessage.newEMailMessage();
    localEMailMessage.setOriginator(wtpart.getModifier());
    localEMailMessage.addRecipient(wtpart.getModifier()); 
    localEMailMessage.setSubject("ext.customization.CustomResource","EMAIL_SUBJECT",new String[]{wtpart.getName()}); 
    localEMailMessage.addPart("ext.customization.CustomResource","EMAIL_SUBJECT",new String[]{retMsg},"text/plain");
    localEMailMessage.send(true);

     

     

    • 503 views
    • 1 answers
    • 0 votes
  • Asked on January 3, 2019 in Windchill PLM.
    • Definitions are stored:
    BooleanDefinition 
    FloatDefinition  
    IntegerDefinition 
    RatioDefinition 
    ReferenceDefinition 
    StringDefinition
    TimestampDefinition 
    UnitDefinition
    URLDefinition
    • Values are stored:
    BooleanValue 
    FloatValue  
    IntegerValue 
    RatioValue 
    ReferenceValue 
    StringValue
    TimestampValue 
    UnitValue
    URLValue
    • 593 views
    • 1 answers
    • 0 votes
  • Asked on November 5, 2018 in Windchill PLM.

    Follow Below Steps to Deploy Custom Web Application in Windchill Tomcat.

    • Copy the war to a directory say /app01/windchill11/Windchill/tomcat/webapps/sample
    • Open a Windchill shell run the command, navigate to /app01/windchill11/Windchill/tomcat and run the below command, appName is the what you use after server name to access the application. This will install the web app on Windchill Tomcat
    ant -f config.xml installWebApp -DappName=sample -DdocBase=/app01/windchill11/Windchill/tomcat/webapps/sample
    • Now you have two options either to enable direct HTTP access on tomcat to access the app or use web server directives direct the traffic to tomcat. if you want to enable
      • direct access add below line to /app01/windchill11/Windchill/tomcat/conf/server.xml.default
      • <Connector port="8080" protocol="HTTP/1.1"  connectionTimeout="20000" redirectPort="8443" />

         

    • Now restart Windchill and access the page – http://localhost:8080/sample
    • 518 views
    • 1 answers
    • 0 votes
  • Asked on October 26, 2018 in Windchill PDMLink.

    Below are the link objects in Windchill.

     From object
       Link object   To object 
    wt.doc.WTDocument   wt.doc.WTDocumentUsageLink   wt.doc.WTDocumentMaster
    wt.doc.WTDocument   wt.doc.WTDocumentDependencyLink   wt.doc.WTDocument
    wt.doc.WTDocument   wt.part.WTPartDescribeLink   wt.part.WTPart
    wt.part.WTPart   wt.part.WTPartUsageLink   wt.part.WTPartMaster
    wt.part.WTPart   wt.part.WTPartReferenceLink   wt.doc.WTDocumentMaster
    wt.part.WTPart   wt.epm.EPMBuildRule   wt.epm.EPMDocument
    wt.part.WTPart   wt.epm.EPMDescribeLink   wt.epm.EPMDocument
    wt.part.WTPart   wt.epm.structure.EPMDescribeLink   wt.epm.EPMDocument
    wt.part.WTPartMaster   wt.part.WTPartAlternateLink   wt.part.WTPartMaster
    wt.part.WTPartUsageLink   wt.part.WTPartSubstituteLink   wt.part.WTPartMaster
    wt.epm.EPMDocument   wt.epm.structure.EPMMemberLink   wt.epm.EPMDocumentMaster
    wt.epm.EPMDocument   wt.epm.structure.EPMReferenceLink   wt.epm.EPMDocumentMaster
    wt.epm.EPMDocument   wt.epm.structure.EPMVariantLink   wt.epm.EPMDocumentMaster
    wt.change2.WTChangeOrder2   wt.change2.AddressedBy2   wt.change2.WTChangeRequest2
    wt.change2.WTChangeActivity2   wt.change2.IncludedIn2   wt.change2.WTChangeOrder2
    • 709 views
    • 1 answers
    • 0 votes
  • Asked on October 26, 2018 in Windchill PDMLink.

    There are two ways to add a custom state in Windchill;

    • Via enumCustomize tool
    • By changing the stateRB.rbinfo file

    Method 1:

      1. Open Windchill shell. Type enumCustomize. Hit Enter.
      2. enumCustomize tool will open. Browse <Windchill>\codebase\wt\lifecycle\StateRB.RB.ser and open it.
      3. Add your custom state.
      4. Build the changes by saving the changes.
      5. Stop the Windchill server.
      6. Run the MakeJar command from codebase directory ant -f MakeJar.xml custUpdatE
      7. Restart Windchill to see the changes.

    Method 2:

    1. Open src/wt/lifecycle/stateRB.rbinfo file.
    2. Add your custom state manually.
    3. Run the build command.
      ant –f tools.xml bundle_custom –Dbundle.input=registry
    4. Run the MakeJar command from codebase directory.
      ant  -f MakeJar.xml
    5. Restart Windchill
    • 516 views
    • 1 answers
    • 0 votes