Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX (Archived)

Export Customer Print Management

(0) ShareShare
ReportReport
Posted on by 331

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

  • ScorpioDax Profile Picture
    ScorpioDax 331 on at
    RE: Export Customer Print Management

    Done.  Thank again!

  • Chaitanya Golla Profile Picture
    Chaitanya Golla 17,225 on at
    RE: Export Customer Print Management

    Hi,

    NP.Could you please mark helpful answers as verified.

  • Suggested answer
    ScorpioDax Profile Picture
    ScorpioDax 331 on at
    RE: Export Customer Print Management

    Exactly what i did and that worked perfectly!

    Thank you so much for that help.  Greatly appreciated!

  • Suggested answer
    Chaitanya Golla Profile Picture
    Chaitanya Golla 17,225 on at
    RE: Export Customer Print Management

    Hi,

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

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

  • ScorpioDax Profile Picture
    ScorpioDax 331 on at
    RE: Export Customer Print Management

    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
    István Orosz Profile Picture
    István Orosz 2,137 on at
    RE: Export Customer Print Management

    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

  • Verified answer
    Chaitanya Golla Profile Picture
    Chaitanya Golla 17,225 on at
    RE: Export Customer Print Management

    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));
        }
    }


  • ScorpioDax Profile Picture
    ScorpioDax 331 on at
    RE: Export Customer Print Management

    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.

  • Suggested answer
    István Orosz Profile Picture
    István Orosz 2,137 on at
    RE: Export Customer Print Management

    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

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Verified Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,391 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,445 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans