Tuesday, May 28, 2019

Making attachments as mandatory in OAF through CO Extension

The requirement is to stop the user from clicking next button in the TRAIN page if the attachment is not attached. The challenge i faced is attachment will not be committed to database till user click save button at the last step.

import oracle.apps.fnd.framework.webui.beans.message.OAMessageAttachmentLinkBean;

public void processFormRequest(OAPageCntext oapagecontext, OAWebBean oawebbean)
    {
      OAApplicationModule am = oapagecontext.getApplicationModule(oawebbean);
        super.processFormRequest(oapagecontext, oawebbean);
       
            if ("goto".equals(oapagecontext.getParameter(EVENT_PARAM)) || "NavBar".equals(oapagecontext.getParameter(SOURCE_PARAM))) //NavBar is used to get the even t from Train bar.
            {
            oapagecontext.writeDiagnostics(this," first IF condition passed " ,OAFwkConstants.STATEMENT) ;
            if(am != null)
            {   
                OAMessageAttachmentLinkBean localOAMessageAttachmentLinkBean = (OAMessageAttachmentLinkBean)oawebbean.findChildRecursive("Attachments");
               
                if(localOAMessageAttachmentLinkBean != null)
                {
                    String str = (String)localOAMessageAttachmentLinkBean.getAttributeValue(oapagecontext.getRenderingContext(), TEXT_ATTR);
                    oapagecontext.writeDiagnostics(this,"Printing str " +str ,OAFwkConstants.STATEMENT) ;
                    if ("None ".equals(str))
                    {
                            throw new OAException("Please Attach Required Supporting Documents To Process The Invoice.",OAException.ERROR);
                    }
                }
            }
            }

1 comment: