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 :
Finance | Project Operations, Human Resources, ...
Suggested Answer

Using data from attachments to use in X++ in D365

(0) ShareShare
ReportReport
Posted on by 70

hey so I'm trying to add more than line header comments it needs to show all 3 instead of one. 

this is the code i had before  //purchPurchaseOrderHeader.WQ_HeaderLineNotes = DocuRef::findTableIdRecId(purchTable.DataAreaId, purchTable.TableId, purchTable.RecId).Notes; - that was showing one comment

I was told to use 

public static void main(Args _args)
{

DocuRef docuRef;
DocuType DocuType;

select docuRef
// index hint RefIdx
// where docuRef.RefCompanyId == refDataareaId &&
// docuRef.RefTableId == refTableId &&
// docuRef.RefRecId == refRecId
join DocuType
where DocuType.TypeId == docuRef.TypeId &&
DocuType.TypeGroup == DocuTypeGroup::Note;



}

but I'm confused on how to code it into my class extension I already have 

4530.notes.PNG

I have the same question (0)
  • André Arnaud de Calavon Profile Picture
    301,075 Super User 2025 Season 2 on at

    Hi Robyng,

    I'm a bit confused by the screenshot you added. You are talking about adding notes, but the screenshot is highlighting an ERP logo.

    I wouldn't recommend using the code literally that was 'told to use'. It has out commented lines which will cause retrieving all notes regardless the purchase order.

    Can you explain what is the purpose of the screenshot?  

  • Robyng Profile Picture
    70 on at

    I'm trying to print out all 3 comments instead of one comment.

  • Robyng Profile Picture
    70 on at

    /purchPurchaseOrderHeader.WQ_HeaderLineNotes = DocuRef::findTableIdRecId(purchTable.DataAreaId, purchTable.TableId, purchTable.RecId).Notes;  -- this code is showing only showing one comment so

    so I need to use this to show all 3 but I'm confused on how to do so

    public static void main(Args _args)

    {

    DocuRef docuRef;

    DocuType DocuType;

    select docuRef

    // index hint RefIdx

    // where docuRef.RefCompanyId == refDataareaId &&

    // docuRef.RefTableId == refTableId &&

    // docuRef.RefRecId == refRecId

    join DocuType

    where DocuType.TypeId == docuRef.TypeId &&

    DocuType.TypeGroup == DocuTypeGroup::Note;

    }

  • André Arnaud de Calavon Profile Picture
    301,075 Super User 2025 Season 2 on at

    Hi Robyng,

    You now repeated your question instead of explaining why your screenshot has an "ERP logo" record selected.

  • Robyng Profile Picture
    70 on at

    ERP logo I was just adding data you can ignore that the one that say test and test 1 I need both of those to print out.

  • André Arnaud de Calavon Profile Picture
    301,075 Super User 2025 Season 2 on at

    Hi Robyng,

    Thanks for the clarification. Can you share the complete method where you did now retrieve the single note? Please use 'Use rich formatting' and then the code applet to paste your coding. It would be better readable on this forum then.

  • Robyng Profile Picture
    70 on at

       //purchPurchaseOrderHeader.WQ_HeaderLineNotes = DocuRef::findTableIdRecId(purchTable.DataAreaId, purchTable.TableId, purchTable.RecId).Notes;

    [quote]

    Hi Robyng,

    Thanks for the clarification. Can you share the complete method where you did now retrieve the single note? Please use 'Use rich formatting' and then the code applet to paste your coding. It would be better readable on this forum then.

    [/quote]
  • Suggested answer
    nmaenpaa Profile Picture
    101,160 Moderator on at

    You need to use a while select statement to iterate all records that the statement returns. Also it's super important that you include the range for purchTable.TableID and purchTable.RecId because otherwise it would return all Notes from the entire system!

    DocuRef docuRef;
    DocuType docuType;
    
    while select docuRef
    	where docuRef.RefTableId == purchTable.tableId
    	&& docuRef.RefRecId == purchTable.RecId
    	join docuType
            where docuType.TypeId == docuRef.TypeId &&
            docuType.TypeGroup == DocuTypeGroup::Note
    {
        info(docuRef.Notes);
    }

  • Robyng Profile Picture
    70 on at

        DocuRef docuRef;
            DocuType docuType;
    
            while select docuRef
      where docuRef.RefTableId == purchTable.tableId
       && docuRef.RefRecId == purchTable.RecId
            join docuType
       where docuType.TypeId == docuRef.TypeId &&
         DocuType.TypeGroup == DocuTypeGroup::Note;
            
     purchPurchaseOrderHeader.WQ_HeaderLineNotes = info(docuRef.Notes);
            
          
            
    
    
            // purchPurchaseOrderHeader.WQ_HeaderLineNotes = DocuRef::findTableIdRecId(purchTable.DataAreaId, purchTable.TableId, purchTable.RecId).Notes;
            return PurchPurchaseOrderHeader;
        
    
        }

    I'm getting an  error line 11 and 21 sysntax error 

    Not sure if 'm doing the docuRef to print out to header comments

  • Blue Wang Profile Picture
    on at

    Hi Robyng,

    You used while select, so where is your "{}"? not use ";".

    What does the "}" in line 21 mean?

    Please share your detailed error message, don't skimp on sharing it

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 > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 551 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 450 Super User 2025 Season 2

#3
BillurSamdancioglu Profile Picture

BillurSamdancioglu 278 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans