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

Community Tip - Help us improve the PTC Community by taking this short Community Survey! X

Can we make the Attachment section required?

OnurNalbantgl
12-Amethyst

Can we make the Attachment section required?

Hello,

When creating a problem report, can we make the Attachment section required?

 

OnurNalbantgl_0-1698047173388.png

 

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @OnurNalbantgl 

The article is for ECR, and I have made the necessary modifications according to your requirements. Please refer to the following steps

 

Step1:

Unzip the file, place it in your IDE environment (such as Eclipse),be sure to place the Java files in this directory <Windchill_Home>\src\formProcessor, and then compile it. Place the compiled file in this directory Windchill\codebase\formProcessor\SecondaryAttachment.class

Rocket__2-1698142732493.png

 

Rocket__4-1698142819100.png

 

If you do not have a IDE, you can also compile it with Windchill, run this commad in Windchill Shell, be sure to place the Java files in this directory <Windchill_Home>\src\formProcessor, a file with the same name will be generated, but the format is class, Place the compiled file in this directory Windchill\codebase\formProcessor\SecondaryAttachment.class

ant -f bin/tools.xml class -Dclass.includes=SecondaryAttachment.java -Dclass.source=%WT_HOME%\src\formProcessor

Rocket__5-1698143051399.png

 

Step2:

Find Windchill\codebase\config\actions\Custom-actions.xml and add below content

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE listofactions SYSTEM "actions.dtd">
<listofactions>
    <objecttype name="attachments" class="wt.content.ContentHolder" resourceBundle="com.ptc.windchill.enterprise.attachments.attachmentsResource">
      <action name="attachments_step" uicomponent="ATTACHMENTS" ajax="row" postloadJS="preAttachmentsStep" preloadWizardPage="false">
        <command class="formProcessor.SecondaryAttachment" windowType="wizard_step"/>
         <includeFilter name="hideFromDTI" />
         <includeFilter name="EDACompareFilter" />
      </action>
      </objecttype>
</listofactions>

Rocket__6-1698143225873.png

 

Step3:

Restart Windchill and test

Rocket__1-1698142096986.png

 

Good luck for you

 

View solution in original post

10 REPLIES 10

Hello @OnurNalbantgl 

OOTB does not have such a function, you need to customize it. Please refer to https://www.ptc.com/en/support/article/CS306962

 

great support.

But I don't know where to apply them.

Where do I apply the sample code?

to an xml in codebase? Or should I define it as an expression within the stream?

Your help will be unforgettable for me.

Hi @OnurNalbantgl 

Then you need to learn how to customize the Windchill. 

CS212271 - Windchill PLM - Customization

 

CS60345 - Windchill PLM - Customization Guides

 

PetrH

Hello @OnurNalbantgl 

I will try to make one, but it will take time

hi @Rocket_Max 

 

I can wait forever. 🙂

Hi @OnurNalbantgl 

The article is for ECR, and I have made the necessary modifications according to your requirements. Please refer to the following steps

 

Step1:

Unzip the file, place it in your IDE environment (such as Eclipse),be sure to place the Java files in this directory <Windchill_Home>\src\formProcessor, and then compile it. Place the compiled file in this directory Windchill\codebase\formProcessor\SecondaryAttachment.class

Rocket__2-1698142732493.png

 

Rocket__4-1698142819100.png

 

If you do not have a IDE, you can also compile it with Windchill, run this commad in Windchill Shell, be sure to place the Java files in this directory <Windchill_Home>\src\formProcessor, a file with the same name will be generated, but the format is class, Place the compiled file in this directory Windchill\codebase\formProcessor\SecondaryAttachment.class

ant -f bin/tools.xml class -Dclass.includes=SecondaryAttachment.java -Dclass.source=%WT_HOME%\src\formProcessor

Rocket__5-1698143051399.png

 

Step2:

Find Windchill\codebase\config\actions\Custom-actions.xml and add below content

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE listofactions SYSTEM "actions.dtd">
<listofactions>
    <objecttype name="attachments" class="wt.content.ContentHolder" resourceBundle="com.ptc.windchill.enterprise.attachments.attachmentsResource">
      <action name="attachments_step" uicomponent="ATTACHMENTS" ajax="row" postloadJS="preAttachmentsStep" preloadWizardPage="false">
        <command class="formProcessor.SecondaryAttachment" windowType="wizard_step"/>
         <includeFilter name="hideFromDTI" />
         <includeFilter name="EDACompareFilter" />
      </action>
      </objecttype>
</listofactions>

Rocket__6-1698143225873.png

 

Step3:

Restart Windchill and test

Rocket__1-1698142096986.png

 

Good luck for you

 

C can not believe my eyes.

Great work. Thank you very much.

 

I will try this as soon as possible. 🤝

Hello @Rocket_Max

This is a great solution and it definitely works, but I have to ask something.

Do you think I can do this for a single issue report subtype?

For example, I have 4 problem report type forms. I want to use this obligation only in the ticket type.

Is it possible?

Hi @OnurNalbantgl 

Yes it is possible.

You throw an error if the object type is your specific type.

You need to get the information from NmCommandBean and then use a condition if it is your subtype. 

 

PetrH 


Hello, @HelesicPetr @Rocket_Max 

Should I add the code I will add here within this field?

Do you have an example for a sub type?

 

package formProcessor;
import java.util.List;
import com.ptc.core.components.beans.ObjectBean;
import com.ptc.core.components.forms.FormProcessingStatus;
import com.ptc.core.components.forms.FormResult;
import com.ptc.core.components.util.FeedbackMessage;
import com.ptc.netmarkets.util.beans.NmCommandBean;
import com.ptc.windchill.enterprise.attachments.forms.SecondaryAttachmentsSubFormProcessor;
import wt.change2.WTChangeIssue;
import wt.util.WTException;

public class SecondaryAttachment extends SecondaryAttachmentsSubFormProcessor{

@Override
public FormResult preProcess(NmCommandBean commandBean, List<ObjectBean> objectBeans) throws WTException {
System.out.println("Hello PTC");
for ( ObjectBean objectBean : objectBeans ) {
List attachments= objectBean.getAddedItemsByName("attachments.list.editable");

if(objectBeans.size() > 0){
objectBean = objectBeans.get(0);
if(objectBean != null)
{
Object obj = objectBean.getObject();
if(attachments.isEmpty() && obj.getClass().isAssignableFrom(WTChangeIssue.class))
{
FormResult result;
FeedbackMessage errors= new FeedbackMessage();
errors.addMessage("Please add secondary attachments to submit Problem Report form.");
result = new FormResult(FormProcessingStatus.FAILURE);
result.addFeedbackMessage(errors);
return result;
}
}
}
}

return super.preProcess(commandBean, objectBeans);
}

}

Top Tags