Thursday, September 14, 2017

How to extend receipt using custom fields

Hello it has been a while since my last post. Today I want to guide you thru on extending the receipt layout using custom fields. This is great if the business wanted to see additional fields or information on the receipt. If you follow this guide you will become a pro/expert on modifying the receipt :P

1. Open up the AOT and go to RetailLangaugeText table, open it and fill in the column “languageId” to “en-us”, Text to how you want it to show up on the receipt designer and uniqe TextId. You can close the AOT after you’re done.




2. Go to Retail > Setup > POS > Profiles > Custom fields and add your custom field and assign a unique Caption text ID that you created earlier in the AOT.

3. We want to add the new Custom field on the Receipt layout. Go to receipt designer and add the field to the correct section of the receipt. In my case I added "Discount Price" to the "Lines" section of the receipt. Click “Save” at the top and close this form.


4.  Open up your Retail SDK and open up your Commerce Run-time solution. If you don't have the Retail SDK you would need to install this component using AX Setup.

5. On the Solution Explorer type in “ReceiptService.cs” into the search bar and open that class.

6.  The receipt layout has 3 sections: Header, Line, Footer. Depending on where you are planning to put your custom field matter in this case. If you are using the custom field in Header or Footer, the method you want to use is GetInfoFromTransaction(). If you are using the field in the Lines section then the method you want to code in is GetInfoFromSaleLineItem(). In my case I’m planning to put mine on the Lines of the receipt so I will be putting my custom code in GetInfoFromSaleLineItem().

7. This method contains numerous case statements. What I’m trying to achieve on the receipt is to show the discounted price of the item instead of the original price.


8. Navigate to where the Reference folder and we want to copy these DLLs.


9.  Open IIS and we want to stop the “RetailServer”.


10. Paste the DLLs into this folder. After this is done don’t forget to start IIS back up!

11. Open mPOS and login. Go back to Visual Studio and we want to attach the process.

12. Attach the following processes, click Attach if you get a warning. We want to make sure that our symbols get loaded for debugging. We can see this if you see a red circle where you put the breakpoint. If you see a white circle, then that mean the symbol did not load.

13.  From here you can debug and test your code to see if it working correctly.

14.  I was able to get the discounted price to show instead of the original price. For the customer they would like to know how much they have saved so I included the Regular and Saving fields. This will let the customer know the amount they have saved.