2 Replies Latest reply on Jun 19, 2012 5:24 AM by 604680

    How to display Attachments on OAF page for different entities

    943687
      Hi,

      I have a requirement where I have to create an attachment page to display the attachments dynamically at run time depending upon the values passed such as Entity Name, Primary Key values, Category Id values.
      I have a query to give me the attachments related data from the tables like fnd_documents_vl, fnd_attached_documents, fnd_document_entities, fnd_document_categories_tl.

      Now, as I read on the forum, I can make use of Oracle's seeded functionality on attachments and display attachments but in my requirement I don't have one specific entity. I have below query which gives data directly with respect to all entities from fnd tables. The name of entity and primary keys will come at run time. So, how can I make use of below query and display attachments in such a case?

      I am very new to OAf and any help will be really appreciated.

      Thanks in Advance,
      Shalini

      SELECT DISTINCT ad.attached_document_id
      ,ad.document_id AS document_id
      ,ad.last_update_date
      ,ad.last_updated_by
      ,u.user_name last_updated_by_name
      ,ad.entity_name
      ,ad.pk1_value
      ,ad.pk2_value
      ,ad.pk3_value
      ,ad.pk4_value
      ,ad.pk5_value
      ,decode(d.dm_node,
      NULL,
      (SELECT short_name
      FROM fnd_dm_nodes
      WHERE node_id = 0),
      0,
      (SELECT short_name
      FROM fnd_dm_nodes
      WHERE node_id = 0),
      node.short_name) location
      ,d.document_id document_id1
      ,d.datatype_id
      ,d.datatype_name
      ,d.description
      ,decode(d.file_name,
      NULL,
      (SELECT message_text
      FROM fnd_new_messages
      WHERE message_name = 'FND_UNDEFINED'
      AND application_id = 0
      AND language_code = userenv('LANG')),
      d.file_name) file_name
      ,d.media_id
      ,d.dm_type
      ,d.dm_node
      ,d.dm_folder_path
      ,e.data_object_code
      ,e.document_entity_id
      ,'ALLOW_ATTACH_UPDATE' allow_attach_update
      ,'ALLOW_ATTACH_DELETE' allow_attach_delete
      ,ad.category_id category_id
      ,cl.user_name attachment_category_name
      ,ad.status
      ,ad.creation_date
      ,(SELECT u1.user_name
      FROM fnd_user u1
      WHERE u1.user_id = ad.created_by) attached_by_name
      ,decode(d.datatype_id,
      5,
      nvl(d.title,
      d.description) || '(' ||
      substr(d.url,
      1,
      least(length(d.url),
      15)) || '...)',
      decode(d.datatype_id,
      6,
      nvl(d.title,
      d.file_name),
      decode(d.title,
      NULL,
      (SELECT message_text
      FROM fnd_new_messages
      WHERE message_name = 'FND_UNDEFINED'
      AND application_id = 0
      AND language_code =
      userenv('LANG')),
      d.title))) file_name_sort
      ,d.usage_type
      ,d.security_id
      ,d.security_type
      ,d.publish_flag
      ,cl.category_id category_id_query
      ,ad.seq_num
      ,d.url
      ,d.title
      FROM fnd_documents_vl d
      ,fnd_attached_documents ad
      ,fnd_document_entities e
      ,fnd_user u
      ,fnd_document_categories_tl cl
      ,fnd_dm_nodes node
      WHERE ad.document_id = d.document_id
      AND ad.entity_name = e.data_object_code(+)
      AND ad.last_updated_by = u.user_id(+)
      AND cl.LANGUAGE = userenv('LANG')
      AND cl.category_id = nvl(ad.category_id,
      d.category_id)
      AND d.dm_node = node.node_id(+)
        • 1. Re: How to display Attachments on OAF page for different entities
          Peddi
          1) Create your VO with your query and bind variables
          2) In processRequest(PR) bind variables of your VO and execute the VO
          3) After executing the VO in PR, you have to set the other attributes of the attachment bean for this use oracle.apps.fnd.framework.webui.beans.OAWebBeanAttachment to set the entity map and other attributes
          I guess setEntityMappings() method fits your purpose.

          I never did this example. Just throwing my thoughts on how to implement it.

          Regards,
          Peddi.
          • 2. Re: How to display Attachments on OAF page for different entities
            604680
            Hi Peddy,

            Thanks a lot for your guidance. I tried implementing the code in PR but I am stuck at one error. I am not able to programmatically add a new Entity ID and its attributes at run time. To make it more clear: In Jdev I created an Entity and its mappings at design time. Now, I am able to use getEntitymappings() and setEntityMappings() to modify the attributes of exiting Enity but I am not able to add/append new Entity ID to the existing one. It throws - java.lang.ArrayIndexOutOfBoundsException: 1 error.

            Please any one review the below code snippet and let me know whether I am missing something to make it work.
            Below is the Code that I have written so far:

            ====================================================

            OAAttachmentTableBean attBean = (OAAttachmentTableBean)webBean.findChildRecursive("attachTable");


            Dictionary[] entityMaps = attBean.getEntityMappings();

            entityMaps[0].remove("entityId");
            entityMaps[0].put("entityId","OE_ORDER_HEADERS");
            entityMaps[0].remove("insertAllowed");
            entityMaps[0].remove("updateAllowed");
            entityMaps[0].remove("deleteAllowed");
            entityMaps[0].put("insertAllowed", false);
            entityMaps[0].put("updateAllowed", false);
            entityMaps[0].put("deleteAllowed", false);

            // Adding Second Entity

            // Getting ArrayIndexOutOfBoundsException at below line. As i saw that getEntityMappings() returns only array of size :1 and that is teh reason I am getting error, so How can I increase the size dynamically to add new Entity or is there any other way?

            entityMaps[1].put("entityId", "XX_LINK_ENTITY"); // entity id
            entityMaps[1].put("showAll", false); // show all property
            entityMaps[1].put("insertAllowed", false);
            entityMaps[1].put("deleteAllowed", false);
            entityMaps[1].put("updateAllowed", false);


            // Adding Primary Key to Second Entity
            String[] pkAttrNames = new String[1];
            pkAttrNames[0] = "Pk1Value"; // pk view attribute name
            entityMaps[1].put("pkColumns", pkAttrNames);

            // Setting Category Values for first Entity
            Integer CatValue = 1000486;

            Integer[] categories = new Integer[2]; // categories

            categories[0] = new Integer(1);
            categories[1] = CatValue;
                 
            // Setting Category Values for Second Entity
            Integer[] categories2 = new Integer[1]; // categories
            categories2[0] = new Integer(1); //MISC

            attBean.setEntityMappings(entityMaps);


            attBean.setDynamicCategoriesMap("OE_ORDER_HEADERS",categories);
            attBean.setDynamicCategoriesMap("XX_LINK_ENTITY",categories2);

            Thanks & Best Regards,
            Shalini