web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

[AX 2012] Attach URL in X++

(0) ShareShare
ReportReport
Posted on by 110

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)
  • Verified answer
    Guillaume Cassegrain Profile Picture
    110 on at

    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;

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans