Skip to main content

OAF Attachment : Make an attachment mandatory in R12.2

Problem
at times you want to make an EBS OAF attachment mandatory for user. We cannot use queries to retrieve if attachment is added by the user or not because attachments are not yet committed to database
In R12.1.3 below code successfully executed but in R12.2 version it dose not support.

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);                     }                 } (String)localOAMessageAttachmentLinkBean.getAttributeValue(oapagecontext.getRenderingContext(), TEXT_ATTR);----this is returning null in R12.2 butR12.1.3 it return None

Solution 
You can use javascript to resolve this
there is span id attachCount attached to attachment link. 
Captured this using javascript and put this JS on Savebutton in Process request of controller

String customJSFunction = "function attachmentcountjs() {\n" +                               
" var htmlString = document.getElementById(\"attachCount\");\n"+                            
 " if(typeof(htmlString) != 'undefined' && htmlString != null){\n"+                          
 " return true;\n" +                      
  " } else{\n"+     
  "  alert(\"Attachment Mandatory\");\n" +             
  "  return false;}" +            
   "return true;\n"+                                   "}";                                           pageContext.putJavaScriptFunction("attachmentcountjs", customJSFunction);                       OASubmitButtonBean btn = (OASubmitButtonBean) webBean.findChildRecursive("Submitbtn");       btn.setAttributeValue(UIConstants.ON_CLICK_ATTR,  "return attachmentcountjs();");


Comments