Community Tip - If community subscription notifications are filling up your inbox you can set up a daily digest and get all your notifications in a single email. X
Hi Community,
I need to check the Attachments table on launched streams.
How can I find out how many files are in the table from Expression? I will check the number of files that need to be uploaded according to this quantity.
For example, in the task step, the user needs to upload 3 PDFs, but he uploaded only one. How can I prevent that task from closing by having it checked?
Solved! Go to Solution.
This was just my solution. There may be others that are easier but this should allow you to create that hook or place to insert your custom logic. I modified the create and edit jsp wizards for WTDocument to add the following custom step.
<%-- adds attachments to the document --%>
<jca:wizardStep action="attachments_step" type="attachments" />
<%--- Customizations for Electrical Eng Docs --%>
<%-- process if matches drawings as documents --%>
<jca:wizardStep action="process_drw_docs" type="document" />
The action "process_drw_doc" is a reference that I then defined in config/actions/custom-actions.xml:
<objecttype name="document" class="wt.doc.WTDocument" resourceBundle="com.ptc.windchill.enterprise.doc.documentResource">
<action name="process_drw_docs" preloadWizardPage="false" hidden="true">
<command class="customization.electrical.DrawingDocumentProcessorDelegate" windowType="no_content"/>
</action>
</objecttype>
That "delegate" class is executed but noticed that hidden=true so users never see this step. This is the basic form of that class implementing the postProcess method where you can put your checks.
public class DrawingDocumentProcessorDelegate extends DefaultObjectFormProcessorDelegate {
/**
* Delegate uses only postProcess hook to inspect WTDocument. postProcess
* will evaluate the type against list in ee.properties.
* @param bean NmCommandBean
* @param list Object Bean list
* @return FormResult
* @throws wt.util.WTException
*/
@Override
public FormResult postProcess (NmCommandBean bean, List list) throws WTException
{
log.debug("entering postProcess");
...
You can get the reference to the WTDocument from the list which are ObjectBeans and finding the one that has the WTDocument on it.
/**
* returns WTDocument associated with CreateEdit Form. Should only be called from Edit.
* @param list Object Bean list
* @return WTDocument
*/
private WTDocument getDoc(List list)
{
//should be only one document, therefore one object bean
for (Iterator<ObjectBean> beans=list.iterator();beans.hasNext();)
{
ObjectBean objBean=beans.next();
//if object on bean is a WTDocument, continue
if ((objBean.getObject() != null)&&(objBean.getObject() instanceof WTDocument))
return((WTDocument)objBean.getObject());
}
log.debug("Could not find WTDocument. Returning null");
return null; //WTDocument not found in bean.
}
From there its standard method to inspect attachments. If they violate your rules, return a FormResult that indicates such.
What kind of object are you checking? I was able to add hidden steps to a WTDocument wizard that can read the uploaded files and in your case, validate that there are 3. Should be easy enough to have it kick back a WTException which would provide the user a message indicating that 3 files are required.
Hi @avillanueva ,
How can I create a WTDocument wizard that can read uploaded files and verify that there are 3.
This was just my solution. There may be others that are easier but this should allow you to create that hook or place to insert your custom logic. I modified the create and edit jsp wizards for WTDocument to add the following custom step.
<%-- adds attachments to the document --%>
<jca:wizardStep action="attachments_step" type="attachments" />
<%--- Customizations for Electrical Eng Docs --%>
<%-- process if matches drawings as documents --%>
<jca:wizardStep action="process_drw_docs" type="document" />
The action "process_drw_doc" is a reference that I then defined in config/actions/custom-actions.xml:
<objecttype name="document" class="wt.doc.WTDocument" resourceBundle="com.ptc.windchill.enterprise.doc.documentResource">
<action name="process_drw_docs" preloadWizardPage="false" hidden="true">
<command class="customization.electrical.DrawingDocumentProcessorDelegate" windowType="no_content"/>
</action>
</objecttype>
That "delegate" class is executed but noticed that hidden=true so users never see this step. This is the basic form of that class implementing the postProcess method where you can put your checks.
public class DrawingDocumentProcessorDelegate extends DefaultObjectFormProcessorDelegate {
/**
* Delegate uses only postProcess hook to inspect WTDocument. postProcess
* will evaluate the type against list in ee.properties.
* @param bean NmCommandBean
* @param list Object Bean list
* @return FormResult
* @throws wt.util.WTException
*/
@Override
public FormResult postProcess (NmCommandBean bean, List list) throws WTException
{
log.debug("entering postProcess");
...
You can get the reference to the WTDocument from the list which are ObjectBeans and finding the one that has the WTDocument on it.
/**
* returns WTDocument associated with CreateEdit Form. Should only be called from Edit.
* @param list Object Bean list
* @return WTDocument
*/
private WTDocument getDoc(List list)
{
//should be only one document, therefore one object bean
for (Iterator<ObjectBean> beans=list.iterator();beans.hasNext();)
{
ObjectBean objBean=beans.next();
//if object on bean is a WTDocument, continue
if ((objBean.getObject() != null)&&(objBean.getObject() instanceof WTDocument))
return((WTDocument)objBean.getObject());
}
log.debug("Could not find WTDocument. Returning null");
return null; //WTDocument not found in bean.
}
From there its standard method to inspect attachments. If they violate your rules, return a FormResult that indicates such.