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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Export Customer Print Management

(0) ShareShare
ReportReport
Posted on by 333

I am having a hard time extracting the Customer print management destination emails from the Customer Invoice Print Mgmt Settings.

Here is my code and i have attached screen-shots of the field i am trying to extract.

Any help would be appreciate!

{

CustTable custTable;
PrintMgmtSettings printMgmtSettings;
PrintMgmtDocInstance printMgmtDocInstance;
PrintJobSettings printJobSettings;



while select AccountNum from CustTable

{

while select DocumentType from PrintMgmtDocInstance

join PrintJobSettings from PrintMgmtSettings

where CustTable.RecId==PrintMgmtDocInstance.ReferencedRecId

&& PrintMgmtDocInstance.RecId==PrintMgmtSettings.ParentId

{

PrintJobSettings=new PrintJobSettings(PrintMgmtSettings.PrintJobSettings);

info printJobSettings;

pause;

}
}
}

2017_2D00_09_2D00_14_5F00_7_2D00_36_2D00_09.png2017_2D00_09_2D00_14_5F00_7_2D00_36_2D00_32.png

2017_2D00_09_2D00_14_5F00_7_2D00_35_2D00_28.png

*This post is locked for comments

  • Suggested answer
    István Orosz Profile Picture
    2,137 on at

    Hi,

    First comment: using embedded while select is generally not an efficient coding habit, consider using join for the CustTable.

    What was the aim of your code? Info requires a text, not a container, so right now I cannot see what do you want to write in the infolog, and why is there a pause? Do you want to have a short break after each line or what?

    Regards,

    István

  • ScorpioDax Profile Picture
    333 on at

    I am attempting to export the customer name and account along with the Email that is in the Destination Field on the print management settings for the original invoice.  The export can be in text or excel anything really.  We are just trying to compile a list of the emails.

  • Verified answer
    Chaitanya Golla Profile Picture
    17,225 on at

    Hi,

    You can use the following job to extract and export the customer email that is set in print management settings related to sales invoice(as highlighted below).

    CustomerPrintJob_2D00_Email.jpg

    static void CustPrintMgmtMails(Args _args)
    {
        CustTable               custTable;
        PrintMgmtSettings       printMgmtSettings;
        PrintMgmtDocInstance    printMgmtDocInstance;
        PrintJobSettings        printJobSettings;
        SRSPrintDestinationSettings srsPrintDestinationSettings;
        CommaIO                 commaIO;
        FileName                fileName;
        #File
        
        fileName = @"C:\\Cust.csv";
        commaIO = new CommaIO(filename , #io_write);
        
         // Writes header
        commaIO.write("AccountNum", "Email");
        
        while select DocumentType, Name, ReferencedRecId from printMgmtDocInstance
        where printMgmtDocInstance.DocumentType == PrintMgmtDocumentType::SalesOrderInvoice
            && printMgmtDocInstance.PrintType == PrintMgmtDocInstanceType::Original
        join  custTable          
        where custTable.RecId == printMgmtDocInstance.ReferencedRecId
            && printMgmtDocInstance.ReferencedTableId == tableNum(custTable)
            && (custTable.AccountNum == "XYZ") // specify customer account here, if needed
        join PrintJobSettings from PrintMgmtSettings
            where printMgmtDocInstance.RecId == printMgmtSettings.ParentId
        {
            srsPrintDestinationSettings = new SRSPrintDestinationSettings(printMgmtSettings.PrintJobSettings);
            commaIO.write(custTable.AccountNum, srsPrintDestinationSettings.emailTo()); //Outputs data to csv file
            //info(strFmt("AccountNum: %1, Email: %2", custTable.AccountNum, srsPrintDestinationSettings.emailTo(), printMgmtDocInstance.Name));
        }
    }


  • Suggested answer
    István Orosz Profile Picture
    2,137 on at

    This jobs looks suitable for the original request, only one comment: instead AccountNum field in the CustTable, maybe the name() display method would fit better to the requester need.

    Regards,

    István

  • ScorpioDax Profile Picture
    333 on at

    Hi Chaitanya,

    That worked!

    One other thing if i may ask.  How can i return all the accounts?  I am able to specify the customer account but how can i have it return all records?

  • Suggested answer
    Chaitanya Golla Profile Picture
    17,225 on at

    Hi,

    Just comment the line, where we specified the customer account in the above code.

    This whole line "&& (custTable.AccountNum == "XYZ")".

  • Suggested answer
    ScorpioDax Profile Picture
    333 on at

    Exactly what i did and that worked perfectly!

    Thank you so much for that help.  Greatly appreciated!

  • Chaitanya Golla Profile Picture
    17,225 on at

    Hi,

    NP.Could you please mark helpful answers as verified.

  • ScorpioDax Profile Picture
    333 on at

    Done.  Thank again!

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the August Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans