Você está na página 1de 13
eer017 Creating Adamatc Email Corfrmations in Dynamics AX — RSM RSM Dynamics ERP Pros finvaoS 35 * Creating Automatic Email Confirmations From Dynamics AX By Rachel Profit On November 1, 2012 - Add Comment - In Dynamics AX, Microsoft Dynamics AX 2012 ‘Automating email communication and email confirmations is a great way to streamline your business process. An example of achieving this is to send out sales order confirmations when they are approved within the ERP system, You can do this through workflows if you prefer, but in this example, we will show 4 how you can add a small function to Dynamics AX that will automatically send the confirmations through your local SMTP server, without users having to even touch their e-mail system. ‘Stop 1: Make Suro SMTP Parameters Are Sot “The frst step isto make sure the SMTP server is registered and configured correctly within Dynamics AX. To do this, goto the Systom Administration ~ Setup - System — Emall Parameters Outgoing mail sewer Local computer rare SMTP port number Username Password Use NTUM: EMail settings Astachment sie iit (M8) Allow embedded data and attached fies from: c\temp “The name of the SMTP relay server Step 2: Create An E-mail Template Iitpilaynamieserporos.comfereatingautomaic-email-confirmations-rom-dynamics-axd ons. eer017 Creating Automatic Email Crfrmatons in Dynamics AX Rather than hard code the e-mail body, we are going to take advantage of the e- mail template's functionality that is built into Dynamics AX. You can find the email templates in the Organization - Setup - E-Mail templates form. Ares page > Resources > Inquiries Reports : ee sis aa > Base data ; ane > Resources > Workflow setup E-mail templates aa Hierarchy Event parameters > Organization D Global address book After you open up the form, you will want to create a new template. = [ | shew tem eat: SL Erma = Language tet Layo Then, create a new e-mail layout. Iitpilaynamieserporos.comfereatingautomaic-email-confirmations-rom-dynamics-axd 23. se8017 Creating Automatic Email Corfrmatons in Dynamics AX Sew pater ea: BD ‘Oven [eal Emi = Emalsceipion —Deleutinguagecade Sendenume Senereval Soon! Sis Order Contmation ena DymmciAX _ conaey@vp:ncberaienscom ral Emad oe Jake rthiyhoecom ‘When you open up the layout, you can paste in the e-mail body that you want to use. For the dynamic sections of the e-mail, place tokens surrounded by “%é' Iitpilaynamieserporos.comfereatingautomaic-email-confirmations-rom-dynamics-axd an se8017 Creating Automatic Email Corfrmatons in Dynamics AX File Edt View Inset Format Tools oede *Reaax ABE Norra > MialUncodeMS = domi B FU ESS i Dear %6Custome:Nam=%6, ‘Your products shipped the follwing tems) your order °éOrderNumber%, placed on % OrdeeDate's. Delivery Estimate: “DetivenDate% ‘This shipment was sent to| oC utomerName eCustomerSireet® 2eCwstomerCiy%e, CustomerStae% *iCustomerZip Unted States Order Total: S%OrderTotale ‘No more changes can be made to this order. Ifyou have questions about this ordes. inching the celer'srefind poly, you can vist np: /sharepomtfh stew Dynamics/Aw CSS Exterpriset420Portal CSS Defub aspx LEAVE FEEDBACK ON THIS ORDER Sellers appreciate fredback fiom buyers on ther shopping experience. Once your order is complete, pleaze ave edback on thes order by going to ¥ es DumamiceAwCSS1 £420PomalCSS Defi ‘Thanks for shopping with us Please note-Do not reply to this message, this ¢-mai address docs not accept incoming ¢- mal, | Norra /HTML[Predew: ead After completing this, you can preview the e-mail Iitpilaynamieserporos.comfereatingautomaic-email-confirmations-rom-dynamics-axd ans eer017 Creating Adamatc Email Corfrmations in Dynamics AX File Eat Mew Invert Format Tools Qeooe ¢boOax AG Rena Geile) so = =m Dear 9¢Custome:Name%, ‘Your products shipped the folowing item(s) in your order *sOrderNumber®é, phced on % OrderDate% Delivery Estimate: *sDelveryDate% ‘Thais shipment was sere to: eCustomerName®% eCuntomerStreet eCuntomerCey%6, *4CustomerStates %eCustomerZip"s United Seates Order Total: $%OrderToral’s ‘No more changes can be made to this order. Ifyou have questions abou this order, LEAVE FEEDBACK ON THIS ORDER. Sellers appreciate Redback ftom buyers on their shopping experience Once your order it complete, pase kane feedback on this order by going to i steal SS 220Portal CSS Defi ‘Thanks for shopping wh ws. Please note: Do not repty to this message, this e-mail address does not accept incoming ¢- mail Preview | Step 3: Find Your Form To Extend Now we want to start creating a litle bit of X++ code. But before we do that, let's find the form that we want to modify. For this example, | want to override the Confirmation button on the Sales Order form. To find the form name, | opened up the Personalization form, and it will give provide the real form name. Iitpilaynamieserporos.comfereatingautomaic-email-confirmations-rom-dynamics-axd 513 se8017 Creating Automatic Email Corfrmatons in Dynamics AX QO [Ba caeaegee ) Comm Slesoner | Set Mange Petanérct tere Geen AG 2 So) & @ 8) 2 Be ges es corona Catenion Profoens mk Seve te cenyases cfmasee fants agent ouges To Calis Soe feces Ay Jot 2 Frei, 5) an sats orate [Poetoter My ins Nw 7 eure 1 camtomerscoun time Seoty —_aicesceue sr 1 Car eat ese Bia ie (4 Common prec eee Motwetee Sarr orb Saran! te > poe Herter [i > be ronrere SET (ew) Menu ts STARA (eQ Cont: BB) Netra ls ares sys ‘tonteon 3659 4 From there, we can open up AOT and can drill down into the ActionPane items and find the Confirm button that we want to override. Iitpilaynamieserporos.comfereatingautomaic-email-confirmations-rom-dynamics-axd se8017 (Creating Automatic Email Corfrmatons in Dynamics AX File Edit’ View Build Debu =) SalesTableListPage ‘© Methods © 9 Data Sources © & Parts © 8 Designs © Bd Designtuse) © Bil HActionPane-ActionPane] © Methods © [ll tActionPeneTeb:SaiesOrder] S [lll ActionPeneTabsSell © oY Methods © S [ButtenGroup:CrecitNote] © S [ButtonGroup:SeliCharges} © S [ButtonGroup:Chargestnvoice] ® [ButtenGroup:CaleulateGroup) 5S [ButtenGroup:Generatel © Methods 2 MenulternButton:buttonUpdate Confirmation ° ¢ NE © 2 MenultemButtor:buttonProformaConfirmation ® = [ButtenGroup:ProcessGroup} © [ButtonGroup:Appiy} ® S [ButtenGroup:RelatedDocuments] © [ButtonGroup:Perform] © [ll (ActionPaneTab:Manage] © [ll ActionPaneTab:PickAndPackl © [Bl (ActionPeneTabsinvoice) © [ll (ActionPaneTsb:General] ® i (GrickGria) QZ DesignListlusr) B® Pecmissions Step 4: Create A New Project Rather than change the form directly, it's better to wrap the code within a project. So we will create a new project. Iitpilaynamieserporos.comfereatingautomaic-email-confirmations-rom-dynamics-axd ms se8017 (Creating Automatic Email Corfrmatons in Dynamics AX File Edit View Build Debt ‘SendSalesOrderConfirmatior] | BEDemotuse) 4 CandyMenutuse) {J DataModeltust L] DelitcoResProductDetailsExtendedtusr) LJ] DeliMenutusr) LJ mctAgreementHeaderindexFixtusr) “EJ mcfinventTableModuleExcellm portFixtusr) EJ mctPowerviewForm{usr} L] mcfPowerViewWebMenutust) EJ mcfProductNutritionalDetails(usr) 1] mcfSendEmailExamplefust) 5] mctSpelicheeletust) OrderDashboardMenu(ust) Ld Organicttenutusr) .L] SalesCLApprovalapprovalElement(usr} ] SalesCreditli »provalWorkflowlusr) SalesCreditLimitApprWFTypetust) 4] SeafoodMenu(usr) Bi Shred Now we will drag the form design from AOT over to the project. 8 By pcmeranctnamooge B fy icseterTennnnaras nyeanetihane 3 I icsePectordree Supconaale 2 I csetentasa Iitpilaynamieserporos.comfereatingautomaic-email-confirmations-rom-dynamics-axd ans se8017 will override the File Edit View Build Debug (Creating Automatic Email Confirmation in Dynamies AX Now we are going to add our own code to the form for the e-mail. To do this, we “clicked” method on the form. Tools Version Controt ‘Command Windows Help © ©) SalesTabletistPage ey e © (SS Parts 8 Bh Designs to Methods (9 Data Sources a TeseencteiniPae # Methods ActionPaneTabsSalesOrder] [ActionPaneTab:Sell 1 Methods S fButtonGroup:CredieNote) [ButtonGroup:SeliCharges} B S [PuttonGroup:chargestnvoice] ® S [ButtonGroup:CateulateGroup] [euttonGroup:Generate] ®@ oY Methods 2d MenuiterButton:buttonUpdateConfirma o7 ar 4 © 2 Menulter View Code © 3 totes ET] & S [eutroncreu ® S [ButtonGrou Nee Method _ BS [Buttonrou Open New Window © [BD (ActionPaneTab = © [BB [ActionPaneTab ede @ [Ml [ActionPaneTsb Add-Ins » & [il (rctionPanetab Gel (onie-srig) Provertes © Be Designtistiuse) & Permissions [eee i Description begindrag clicked contest copy cut dragleeve dragOver dragOvers dngTet top rope endDrag, filter gotFocus helpField inputSearch jumpReF lostfocus ‘menufunction mouseDbiClick mouseDown mouseEnter mouseLeave mouseMove That will open up the X++ code editor for us. Notice that the method already has a super () function that will call down to the lower level code, so here, we just need to add our own code either before or after this function. Iitpilaynamieserporos.comfereatingautomaic-email-confirmations-rom-dynamics-axd ons. se8017 Creating Automatic Email Corfrmatons in Dynamics AX Edit View Build Debug Tools Version Control Command Windows | void clickea() £ [super (ys, > To begin, we will create a couple of variables to load in the Email Template, and then set a default recipient email address. Also, after the super () function, we will perform a sendEmail. This function will create an e-mail and send it through the default SMTP server. This is a little different from the normal method which requires the e-mail to be sent through the user's e-mail package. File Fait View Build Debug Tools Version Control Command Windows Help bMerUecneCertmaton ckheg) void clicked() « Systmatita eystealité ‘socone’ str recipientEmail ~ *noenailev -junetionsolutionscon*; tuper()5 SysteallToble::sendtait( systneilla, SystoailTeble: : find(systeai1%¢) .DefeultLenguose, reciptenteeali, tre orsberi@t), foi To make this a little more dynamic, we will find the record for the customer that is referenced in the sales order, and then find their e-mail. Iitpilaynamieserporos.comfereatingautomaic-email-confirmations-rom-dynamics-axd 1013 se8017 (Creating Automatic Email Corfrmatons in Dynamics AX eae bug Tocls Version Control Command Windows Help ‘void elicrec() 4 Systmailic sycEaallta = ‘Socont* str recipientemail CartTable cuseTable; “noemal levee. junctionsolutions com"; super (ds custTable = CustTable::Fina(salests recipientEeail = custTeble-email(); SysfnalToble: :flnd(systnelitd) DeteuttLerguese, reciplenttnall, curuseria(), true) Finally, rather than just sending out a form letter with no personalization, we will create a mapping variable, and tell the system to replace all of the tokens that we have in the email confirmation with the values from the sales order. 4 File Ede View Sale Debug Tooke VerdonContol Cermmand Wind Help old elictee() e Systenlate eysteaiata str recipientinaid op sarpinas: *socene's noenailevpe.functicnsalutions com} 7 ‘supers custrapte = CustTaples:fina(SateeTasie.custsecount); recipientenaii = custranie.emaii(); smppings = new RapCtypes: string, Types: string); ‘mappings. insere(‘Custonertiane”, cust Table ramet); sappings-Anset(‘oraenwanber*,°")3 ‘peppings-tnsert(“Graerdate', Salestabie.createdate()); ‘appirgs-tnsert(‘Custoverstreet', ""); ‘nappings-tnsert(Custonercity' 7); ‘appings-tnsert(“Custoverstate’ °")s tapping dnsert‘CustonerZi0", **)5 sneppings.insert(OrderTatels °°); SysteataTaoie: :senctata( aystealtt SyaEnali abe: nd(systnel12d) fault Language, Peciptentenall, moines, Step 5: Send Your E-mail Now we can test the function. However, before testing, make sure the default e= mail address is assigned to the customer. Iitpilaynamieserporos.comfereatingautomaic-email-confirmations-rom-dynamics-axd ns. se8017 Creating Automatic Email Corfrmatons in Dynamics AX 5 Benicar tem ny ® * |3 “emaine® Tan ___ Nes fests Tonto Btce fone Masten S001: 220 Brea ame CE |e one m r atest P0be EL conte at 1 Pane — ent 1 Gone bdoemation ie one tae deiton ine Carataahdte sei ie Now we will click on the email Confirmation button and see what happens 4 MIRE eee | 2 te rants ee _ o oo % AB 2 Soc 4% S| me | is coe ra kg eg eter cops Fo ‘tm torn os ser ees ‘Alsaes cues * pees i ippanenie ave In Siete meer Sane 8 me ir a ear ence st Det Et mere cnt a (Aaa) aw = Cairne it Dee tr im + el sat Sart 3 hoe sine eterna : a res Sie Serta ya pay ot | set a break point on the function to make sure that it's running correctly, and it looks like it is. Iitpilaynamieserporos.comfereatingautomaic-email-confirmations-rom-dynamics-axd vans se8017 Creating Automatic Email Corfrmatons in Dynamics AX ow Deg Mirco Hp g[>s owettiaaaa ee SSyatnas ita ayetwacltd + Soon: "hema IOvpe, net Lonse ue sons. com” avert? ‘eevipienttnasl = custTabievenait(? mappings = ew map(typeas:steing, Type0!Strin9) 2 Sappings.anere("Customtinwe', Suse Table. awe) 3 Stopinge.snaece( ceaerifinber,"°")3 Sopings snsere(ccdsedate', SaleoTaote Sippinge snsere(\careomersefent! ‘ppings -insere( Cascomerciey", Sepinas. sepinas. mops. ace)? | Cote [ i omiSeerTeoe nPop Onsme Deiter taeto ) |*) Loc. Pat = toe, 2) ams atts aseWeson Desai. 9 Ay 89 ince 2 bancaktecont 4 butencrewsorops. © butoncreaerrchor.. fo Sarnvesceradeag.. ramieutistnconvol Nae 94 batonloursonfrn. | ForfuncerButoncol Nan 5 4 batonlourainract FomfuncerButoncetel Nan 9 butenounabadng. Faaturctoreutorcertl Nan 4 © 9 buteniournat FormtunctorButtancertl Nam Also, all of the standard logic is working as well. Iitpilaynamieserporos.comfereatingautomaic-email-confirmations-rom-dynamics-axd 1313

Você também pode gostar