Description:
Adding attachment against the product in x++
Setup file path
Step 1. Go to Organization and administration
Step 2. Go to setup
Step 3. Document management node
Step 4. Open Document type menu
Step 5. Select file option in the for grid
Step 6. Select attachment directory like “c:\TEMP\folder name”
X++ Code:
// this method will be created bom attachment and bom description
public static void documentAttachmentForBom(Args _args)
{
// declaration
DocuRef docuRef;
DocuActionArchive docuArchive;
DocuType docuType;
Filename fileNameWithPath;
BOMTable bomTable = BOMTable::find(“000003”);
//getting current file directory location
select docuType
where docuType.Name == 'File'
&& docuType.FilePlace == DocuFilePlace::Archive;
if(docuType.RecId)
{
fileNameWithPath = docuType.ArchivePath + fileName;
info(fileNameWithPath);
}
//field mapping
ttsbegin;
docuRef.clear();
docuRef.TypeId = 'File';
docuRef.Name = fileNameWithPath;
docuRef.Notes = “Attachment description”;
docuRef.Restriction = DocuRestriction::External;
docuRef.RefTableId = tableNum(BomTable);
docuRef.RefRecId = bomTable.RecId;
docuRef.RefCompanyId = curext();
docuRef.insert();
//Code to attach file
docuArchive = new DocuActionArchive();
docuArchive.add(docuRef, fileNameWithPath);
ttscommit;
No comments:
Post a Comment