Tuesday, December 12, 2017

OAF Attachment : Make an attachment mandatory

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 such scenario you do a mandatory (required) check for attachment table, link and inline attachment using the below code:

    private void validateAttachment(OAApplicationModule am) {
        OAAttachmentsAMImpl attachmentAM =
            (OAAttachmentsAMImpl)am.findApplicationModule("oracle_apps_fnd_server_OAAttachmentsAM");
        OAViewObjectImpl attachVO =
            (OAViewObjectImpl)attachmentAM.findViewObject("Attach_0_FndAttachedDocumentsDomExtensionVO");
        int count = attachVO.getFetchedRowCount();
        if (count <= 0) {
            throw new OAException("Please attach supporting documents.",
                                  OAException.ERROR);
        }
    }



5 comments:

  1. Hi, Can you please suggest where i need to insert this code

    ReplyDelete
  2. OAViewObjectImpl attachVO =
    (OAViewObjectImpl)attachmentAM.findViewObject("Attach_0_FndAttachedDocumentsDomExtensionVO");
    This is returning null when callin in co

    ReplyDelete
  3. String [] vos = attachmentAM.getViewObjectNames();
    for(int i=0; i<vos.length; i++){
    debug_msg(pageContext, "Vo Name: " + vos[i]);
    }

    add this code to see the names of the view objects in the Attachment AM.

    ReplyDelete