Standard Attachments in Oracle Form
默认情况下“附件”按钮是灰色的,本文将展示如何让某个Form的附件按钮变亮,并能上传附件.
以用户Form为例,我们想让用户上传自己的照片
Pre-Setups
Help > Diagnostics > Custom Code > Personalize,记录下Function Name
并用Help > Diagnostics > Examine查看User Name字段和User ID字段对应的Field名称
我们将会在后边的步骤里使用USER_ID和USER_NAME
Setups
接下来就在Application Developer职责下,要配置Attachment
Step 1: Create document entity
Navigation: Application Developer > Responsibility > Attachments > Document Entities
(Entity:An entity is an object within Oracle Applications data, such as an item, an order, or anorder line. The attachments feature must be enabled for an entity before users can link attachments to the entity.)
Step 2: Create attachment function
Navigation: Application Developer > Responsibility > Attachment > Attachment Functions
选择Function,Name就是我们在文章刚开始时,查得的Function Name。再点Category,选择附件类型
Block,Entity为Block的名称
Entities
Step 3: Add document category
Navigation:Application Developer > Responsibility > Attachment > Document Categories
(Category:A document category is a label that users apply to individual attachments and documents. Document categories provide security by restricting the documents that can be viewed or added via a specific form or form function.
In the below example i am trying to enable the attachment funcionality for the USer form..I want to upload the approval copy for creating a user or attaching new responsibility)
Save the form. Click on Assignments button.
The default Type is Function. Add the name of the function, i.e. Users (This is the User Name of the function defined in Attachment Functions form).
这样附件的设置就算完成了。可以到用户form上,可以看到附件的按钮就变亮了。
点附件按钮,就可以上传附件了
上传之后
Query To Check
=================================================
Attachment Related Tables
1. FND_DOCUMENTS
2. FND_ATTACHED_DOCUMENTS
3. FND_DOCUMENTS_TL
4. FND_DOCUMENT_DATATYPES.
5. FND_DOCUMENT_CATEGORIES
6. FND_DOCUMENTS_LONG_TEXT (Long text type attachment).
7. FND_DOCUMENTS_SHORT_TEXT (Short text type attachment).
8. FND_DOCUMENTS_LONG_RAW
9. FND_LOBS (File type attachments).
FND_DOCUMENTS:
FND_DOCUMENTS stores language-independent information about a document. For example, each row contains a document identifier, a category identifier, the method of security used for the document (SECURITY_TYPE, where 1=Organization,2=Set of Books, 3=Business unit,4=None), the period in which the document is active, and a flag to indicate whether or not the document can be shared outside of the security type (PUBLISH_FLAG).
Other specifications in this table include: datatype (DATATYPE_ID, where 1=short text,2=long text, 3=image, 4=OLE object), image type, and storage type (STORAGE_TYPE, where 1=stored in the database, 2=stored in the file system).
The document can be referenced by many application entities and changed only in the define document form (USAGE_TYPE=S); it can be used as a fill-in-the-blanks document, where each time you use a template, you make a copy of it (USAGE_TYPE=T); or it can be used only one time (USAGE_TYPE=O).Images and OLE Objects cannot be used as templates.
FND_ATTACHED_DOCUMENTS:
FND_ATTACHED_DOCUMENTS stores information relating a document to an application entity. For example, a record may link a document to a sales order or an item. Each row contains foreign keys to FND_DOCUMENTS and FND_DOCUMENT_ENTITIES. There is also a flag to indicate whether or not an attachment was created automatically.
FND_DOCUMENTS_TL:
FND_DOCUMENTS_TL stores translated information about the documents in FND_DOCUMENTS. Each row includes the document identifier, the language the row is translated to, the description of the document, the file in which the image is stored, and an identifier (MEDIA_ID) of the sub-table in which the document is saved (FND_DOCUMENTS_SHORT_TEXT, FND_DOCUMENTS_LONG_TEXT, or FND_DOCUMENTS_LONG_RAW).
FND_DOCUMENT_DATATYPES:
FND_DOCUMENT_DATATYPES stores the document datatypes that are supported. Initial values are: short text, long text, image, and OLE Object (DATATYPE_ID=1, 2, 3, or 4). Customers can add datatypes to handle documents stored outside of Oracle and use non-native Forms applications to view/edit their documents. The table uses a “duplicate record” model for handling multi-lingual needs. That is, for each category there will be one record with the same CATEGORY_ID and CATEGORY_NAME for each language.
FND_DOCUMENT_CATEGORIES:
FND_DOCUMENT_CATEGORIES stores information about the categories in which documents are classified. For example, documents may be considered “Bill of Material Comments”, “WIP Job Comments”, etc. Document categories are used to provide a measure of security on documents. Each form that enables the attachment feature lists which categories of documents can be viewed in the form. This table uses a “duplicate record” model for handling multi-lingual needs.
FND_DOCUMENTS_LONG_TEXT:
FND_DOCUMENTS_LONG_TEXT stores information about long text documents.
FND_DOCUMENTS_SHORT_TEXT:
FND_DOCUMENTS_SHORT_TEXT stores information about short text documents.
FND_DOCUMENTS_LONG_RAW:
FND_DOCUMENTS_LONG_RAW stores images and OLE Objects, such as Word Documents and Excel spreadsheets, in the database.
FND_DOCUMENT_ENTITIES:
FND_DOCUMENT_ENTITIES lists each entity to which attachments can be linked. For example, attachments can be linked to Items, Sales Orders, etc. Since the table uses a “duplicate record” model for handling multi-lingual needs, for each document entity there will be one record with the same DOCUMENT_ENTITY_ID and DATA_OBJECT_CODE for each language.
Useful Queries
To find all Long Text attachments:
SELECT
FAD.SEQ_NUM "Seq Number",
FDAT.USER_NAME "Data Type",
FDCT.USER_NAME "Category User Name",
FAD.ATTACHED_DOCUMENT_ID "Attached Document Id",
FDET.USER_ENTITY_NAME "User Entity",
FD.DOCUMENT_ID "Document Id",
FAD.ENTITY_NAME "Entity Name",
FD.MEDIA_ID "Media Id",
FD.URL "Url",
FDT.TITLE "Title",
FDLT.LONG_TEXT "Attachment Text"
FROM
FND_DOCUMENT_DATATYPES FDAT,
FND_DOCUMENT_ENTITIES_TL FDET,
FND_DOCUMENTS_TL FDT,
FND_DOCUMENTS FD,
FND_DOCUMENT_CATEGORIES_TL FDCT,
FND_ATTACHED_DOCUMENTS FAD,
FND_DOCUMENTS_LONG_TEXT FDLT
WHERE
FD.DOCUMENT_ID = FAD.DOCUMENT_ID
AND FDT.DOCUMENT_ID = FD.DOCUMENT_ID
AND FDCT.CATEGORY_ID = FD.CATEGORY_ID
AND FD.DATATYPE_ID = FDAT.DATATYPE_ID
AND FAD.ENTITY_NAME = FDET.DATA_OBJECT_CODE
AND FDLT.MEDIA_ID = FD.MEDIA_ID
AND FDAT.NAME = \'LONG_TEXT\';
To find all Short Text attachments:
SELECT
FAD.SEQ_NUM "Seq Number",
FDAT.USER_NAME "Data Type",
FDCT.USER_NAME "Category User Name",
FAD.ATTACHED_DOCUMENT_ID "Attached Document Id",
FDET.USER_ENTITY_NAME "User Entity",
FD.DOCUMENT_ID "Document Id",
FAD.ENTITY_NAME "Entity Name",
FD.MEDIA_ID "Media Id",
FD.URL "Url",
FDT.TITLE "Title",
FDST.SHORT_TEXT "Attachment Text"
FROM
FND_DOCUMENT_DATATYPES FDAT,
FND_DOCUMENT_ENTITIES_TL FDET,
FND_DOCUMENTS_TL FDT,
FND_DOCUMENTS FD,
FND_DOCUMENT_CATEGORIES_TL FDCT,
FND_ATTACHED_DOCUMENTS FAD,
FND_DOCUMENTS_SHORT_TEXT FDST
WHERE
FD.DOCUMENT_ID = FAD.DOCUMENT_ID
AND FDT.DOCUMENT_ID = FD.DOCUMENT_ID
AND FDCT.CATEGORY_ID = FD.CATEGORY_ID
AND FD.DATATYPE_ID = FDAT.DATATYPE_ID
AND FAD.ENTITY_NAME = FDET.DATA_OBJECT_CODE
AND FDST.MEDIA_ID = FD.MEDIA_ID
AND FDAT.NAME = \'SHORT_TEXT\';
WEBPAGE ATTACHMENT
SELECT DISTINCT
AD.SEQ_NUM ,
DCT.USER_NAME ,
DAT.USER_NAME ,
D.STORAGE_TYPE ,
D.FILE_NAME ,
D.IMAGE_TYPE ,
D.USAGE_TYPE ,
AD.AUTOMATICALLY_ADDED_FLAG ,
AD.ATTACHED_DOCUMENT_ID ,
DET.USER_ENTITY_NAME ,
D.DATATYPE_ID ,
DAT.NAME ,
D.DOCUMENT_ID ,
D.START_DATE_ACTIVE ,
D.END_DATE_ACTIVE ,
D.SECURITY_TYPE ,
D.SECURITY_ID ,
D.PUBLISH_FLAG ,
AD.CREATED_BY ,
DET.USER_ENTITY_PROMPT ,
AD.ENTITY_NAME ,
AD.COLUMN1 ,
AD.PK1_VALUE ,
D.MEDIA_ID ,
D.CATEGORY_ID ,
D.URL ,
DT.TITLE
FROM FND_DOCUMENT_DATATYPES DAT,
FND_DOCUMENT_ENTITIES_TL DET ,
FND_DOCUMENTS_TL DT ,
FND_DOCUMENTS D ,
FND_DOCUMENT_CATEGORIES_TL DCT ,
FND_ATTACHED_DOCUMENTS AD
WHERE D.DOCUMENT_ID = AD.DOCUMENT_ID
AND DT.DOCUMENT_ID = D.DOCUMENT_ID
AND DCT.CATEGORY_ID = D.CATEGORY_ID
AND D.DATATYPE_ID = DAT.DATATYPE_ID
AND AD.ENTITY_NAME = DET.DATA_OBJECT_CODE
AND DAT.name = \'WEB_PAGE\';
FILE ATTACHMENT
SELECT
AD.SEQ_NUM ,
DCT.USER_NAME ,
DAT.USER_NAME ,
AD.ATTACHED_DOCUMENT_ID ,
DET.USER_ENTITY_NAME ,
DAT.NAME ,
D.DOCUMENT_ID ,
AD.ENTITY_NAME ,
AD.PK1_VALUE ,
D.MEDIA_ID ,
D.URL ,
DT.TITLE ,
DBMS_LOB.SUBSTR(L.file_data,1,10) file_data
FROM FND_DOCUMENT_DATATYPES DAT,
FND_DOCUMENT_ENTITIES_TL DET ,
FND_DOCUMENTS_TL DT ,
FND_DOCUMENTS D ,
FND_DOCUMENT_CATEGORIES_TL DCT ,
FND_ATTACHED_DOCUMENTS AD ,
FND_LOBS L
WHERE D.DOCUMENT_ID = AD.DOCUMENT_ID
AND DT.DOCUMENT_ID = D.DOCUMENT_ID
AND DCT.CATEGORY_ID = D.CATEGORY_ID
AND D.DATATYPE_ID = DAT.DATATYPE_ID
AND AD.ENTITY_NAME = DET.DATA_OBJECT_CODE
AND L.FILE_ID = D.MEDIA_ID
AND DAT.name = \'FILE\';
Find the functions using attachments
SELECT
AD.SEQ_NUM ,
DCT.USER_NAME ,
DAT.USER_NAME ,
AD.ATTACHED_DOCUMENT_ID ,
DET.USER_ENTITY_NAME ,
DAT.NAME ,
D.DOCUMENT_ID ,
AD.ENTITY_NAME ,
AD.PK1_VALUE ,
D.MEDIA_ID ,
D.URL ,
DT.TITLE ,
AF.FUNCTION_NAME ,
AF.FUNCTION_TYPE
FROM FND_DOCUMENT_DATATYPES DAT,
FND_DOCUMENT_ENTITIES_TL DET ,
FND_DOCUMENTS_TL DT ,
FND_DOCUMENTS D ,
FND_DOCUMENT_CATEGORIES_TL DCT ,
FND_DOC_CATEGORY_USAGES DCU ,
FND_ATTACHMENT_FUNCTIONS AF ,
FND_ATTACHED_DOCUMENTS AD
WHERE 1 = 1
AND D.DOCUMENT_ID = AD.DOCUMENT_ID
AND DT.DOCUMENT_ID = D.DOCUMENT_ID
AND DCT.CATEGORY_ID = D.CATEGORY_ID
AND DCU.CATEGORY_ID = D.CATEGORY_ID
AND DCU.ATTACHMENT_FUNCTION_ID = AF.ATTACHMENT_FUNCTION_ID
AND D.DATATYPE_ID = DAT.DATATYPE_ID
AND AD.ENTITY_NAME = DET.DATA_OBJECT_CODE
AND DCU.ENABLED_FLAG = 'Y';