Hi Durga,
there are 2 options for this:
- You can create an external Java class with a method that can be invoked from the transition tab. This allows you to modify the logic and apply changes to all running workflows after a server restart
- You can write the code directly in the transition tab, but if you need to modify the logic it will not apply to running workflows and you need to specify full package path for each class
For the first option you can create a Java class with the following code:
package your.java.package;
import java.beans.PropertyVetoException;
import java.util.Vector;
import wt.content.ApplicationData;
import wt.content.ContentHelper;
import wt.content.ContentHolder;
import wt.fc.PersistenceHelper;
import wt.fc.WTObject;
import wt.util.WTException;
public class TestCheckAttachment {
public static void checkAttachment(WTObject primaryBusinessObject) throws WTException, PropertyVetoException {
primaryBusinessObject = (WTObject) PersistenceHelper.manager.refresh(primaryBusinessObject);
ContentHolder contentHolder = ContentHelper.service.getContents((ContentHolder) primaryBusinessObject);
Vector attachmentsVector = ContentHelper.getApplicationData(contentHolder);
boolean isAnyAttachment = false;
for (int i = 0; i < attachmentsVector.size(); i++) {
Object obj = attachmentsVector.get(i);
if (obj instanceof ApplicationData) {
isAnyAttachment = true;
break;
}
}
if (!isAnyAttachment) {
throw new WTException("Please attach required documents");
}
}
}
and invoke it from the transition tab just with:
your.java.package.TestCheckAttachment.checkAttachment(primaryBusinessObject);
If you prefer the second option, you can write something like this directly in the transition tab:
wt.content.ContentHolder contentHolder = wt.content.ContentHelper.service.getContents((wt.content.ContentHolder) primaryBusinessObject);
java.util.Vector attachmentsVector = wt.content.ContentHelper.getApplicationData(contentHolder);
boolean isAnyAttachment = false;
for (int i = 0; i < attachmentsVector.size(); i++) {
Object obj = attachmentsVector.get(i);
if (obj instanceof wt.content.ApplicationData) {
isAnyAttachment = true;
break;
}
}
if (!isAnyAttachment) {
throw new wt.util.WTException("Please attach required documents");
}
Regards