
Hi all,
I'd like to know if someone has code for attaching URL to a record.
A colleague did it for 'File' document type for 2009 and that was moved to 2012 but now we would like to use the new 2012 feature that allows attaching pure URL.
Bellow is the code we are using for File attachment.
[SysEntryPointAttribute(true)]
public str attachFile(str fileNameArg, int64 journalRecIdArg)
{
DocuType docuType;
DocuRef docuRef;
FileName fileName = fileNameArg;
docuvalue docuvalue;
recid docuvaluerecid;
#File
#define.FileTypeId('File');
select firstonly docuType where docuType.ActionClassId == Classnum(DocuActionArchive) && docuType.TypeId == #FileTypeId;
if(!docuType)
{
select firstonly docuType where docuType.ActionClassId == Classnum(DocuActionArchive);
}
if(docuType)
{
ttsbegin;
docuRef.clear();
docuRef.Name = #Invoice;
docuRef.initValue();
docuRef.RefTableId = tablenum(LedgerJournalTrans);
docuRef.RefRecId = journalRecIdArg;
docuRef.RefCompanyId = curext();
docuRef.TypeId = docuType.TypeId;
docuRef.Restriction = DocuRestriction::Internal;
docuRef.insert();
docuvalue.initValue();
docuvalue.insert();
docuref.ValueRecId = docuvalue.RecId;
docuref.update();
docuvaluerecid = docuvalue.RecId;
select forupdate docuvalue where docuvalue.recid == docuvaluerecid;
docuvalue = docuvalue::writeDocuValue(docuref,fileName);
ttscommit;
return #Ok;
}
return #NotOk;
}
thanks for any help
Regards
/Guillaume
*This post is locked for comments
I have the same question (0)Solution found:
ttsbegin;
docuRef.clear();
docuRef.Name = 'InvoiceUrl';
docuRef.RefTableId = tablenum(LedgerJournalTrans);
docuRef.RefRecId = journalRecIdArg;
docuRef.RefCompanyId = curext();
docuRef.TypeId = 'URL';
docuRef.Restriction = DocuRestriction::Internal;
docuRef.Notes=url;
docuRef.insert();
ttscommit;