Customer delivery address added to the Sales invoice report

We added the customer Delivery address field to the Sales invoice report. However, we also need to add the Delivery name field.

Is this something you would be able to assist us with? Thank you!

00.jpeg

Hi,

If I understand correctly you want to add additional data (DeliveryName) to your DDSP and consequently to your template:

A small customization of the DSP class will be necessary. Below it the screenshot where and what you need to add in the DocSalesInvoiceReportDSP class:

This is the code that needs to be added:

// (3a) Add Delivery name and address
_addingRecord.addCalculatedField('DeliveryName', salesTable.DeliveryName);
_addingRecord.addCalculatedField('DeliveryAddress', salesTable.deliveryAddress().Address);

The DeliveryName field comes from the SalesTable. Since you need DeliveryAddress as well, I would recommend to add it here in the header and not at the line as you have it now. You refer to the address from the first line anyway, so it makes more sense to move it to the header. This address is read via deliveryAddress() method on the SalesTable.

​After this customization is done and compiled, you can generate the DDSP file again and you will see the two fields under the header data:

01

​I hope this helps.

Hello Jernej,

I’m trying to do a similar thing, but following some newer Docentric support advice to not modify the Docentric DSP class directly, but rather to inherit the Docentric DSP class. This helps protect our customization in the event that a DocentricAXSSRSReplicas model change is required by Docentric due to a microsoft d365 change.

Following the Docentric guidance I’ve created a new Project in Visual studio, with a new Model, which contains a single class that extends DocFreeTextInvoiceReportDSP.

My new class builds successfully, and I have edited my Docentric AX Report setup for our FreeTextInvoice report to use the new Data Source DSP class I created.

When I run the report and check the DDSP: all the usual fields come across… except for my custom fields. I figure I’m making a silly newbie mistake somewhere. But given we all start somewhere and we need a helping hand from time to time, I’m wondering if the Docentric team has an example model to follow or a suggested way to investigate why my class that extends DocFreeTextInvoiceReportDSP is not bringing across the fields I set up with these statements:


public void addDataFieldsForHeader(DocXmlRecord _addingRecord, FreeTextInvoiceHeaderFooterTmp _header)
{
	super(_addingRecord, _header);

	void addFieldsFromFreeTextInvoiceHeaderFooterTmp()
	{
		_addingRecord.addField(fieldStr(FreeTextInvoiceHeaderFooterTmp, WWIFormNotesCourier), "Payment Instructions - Courier");
		_addingRecord.addField(fieldStr(FreeTextInvoiceHeaderFooterTmp, WWIFormNotesMail), "Payment Instructions - Mail");
		_addingRecord.addField(fieldStr(FreeTextInvoiceHeaderFooterTmp, WWIFormNotesWireTransfer), "Payment Instructions - Wire");
	}
}

Reference:
This way of inheriting the DSP documented here:

Docentric suggests:
"You can customize Docentric DSP classes via:

[Recommended] Inheritance or Extensions,
Overlayering,
Directly changing the DSP classes in the Docentric AX SSRS Replicas model.

Inherit or extend DSP classes

For this approach, first create a new model, which will reference the Docentric AX, Docentric AX Extension and Docentric AX SSRS Replicas models (and all other models you will need for report customization, e.g. Application Suit).
Then, in this model you can create new DSP classes (1) by inheriting or (2) by extending the existing DSP classes from the Docentric AX SSRS Replicas model for those reports to which you want to add additional data and/or placeholders.

Both Inheritance and Extensions are recommended approaches for customizing DSP classes. However, Inheritance is more powerful approach, because you will be able to override all methods without calling the super() method."

Please make sure you selected the new DSP class in the report setup before generating the data source:

Let me know if the DDSP now contains the newly added data fields.

Hello Jernej,

Sorry, I was wordy in my above post, I did list in there that I did set the new DSP class to be the report data source.
But just to be sure I restarted my development environment, and verified, this is what I see:


Above you can see my custom DSP class: WWIFreeTextInvoiceReportDSP
Is that what you mean?
Could there be another fundamental basic I’m missing?

Thanks so much again!

Hello, thank you for bringing this missing detail to my attention.

Please send me the generated DDSP file so that I can investigate this issue further. I am aware you already added the code in your original post, but you can still include the DSP class for us to review the code.

If you have any concerns about sensitive business data in the DDSP, feel free to reach out to me via a private message or contact our support via email at support@docentric.com.

We look forward to assisting you :+1:

Hello Jernej,

Thanks will do. But at the same time I’m wary of putting too much on your team, so please don’t take on too much for me here, I’m happy being given a pointer or an example to follow.

When we figure it out, I’ll come back here and post what we found, I expect it’s a silly newbie error on my part.

  • Jim

Hello Jim, no worries at all. We are glad to help.

I would also like to thank you for suggesting posting the solution publicly, as it may help other users :+1:

Hello all,

Just a follow up on this question. Jernej and another talented Docentric support person followed up with me on email.

The error in my code was described by Docentric support as extending the addDataFieldsForHeader() and then inside of that declaring a new inline method. That was not required. Compared to my above code quote, my code now looks like this and it works!

    public void addDataFieldsForHeader(DocXmlRecord _addingRecord, FreeTextInvoiceHeaderFooterTmp _header)
    {
        super(_addingRecord, _header);
                
        _addingRecord.addField(fieldStr(FreeTextInvoiceHeaderFooterTmp, WWIFormNotesCourier), "Payment Instructions - Courier");
        _addingRecord.addField(fieldStr(FreeTextInvoiceHeaderFooterTmp, WWIFormNotesMail), "Payment Instructions - Mail");
        _addingRecord.addField(fieldStr(FreeTextInvoiceHeaderFooterTmp, WWIFormNotesWireTransfer), "Payment Instructions - Wire");
            
    }

A BIG thanks again to the Docentric support team for going to the edge and perhaps a bit beyond the edge of support scope with the that allowed me to succeed here. I’ve now been able to follow the suggested method of DSP inheritance so we don’t edit the DocentricAXSSRSReplica’s models directly, thus making future maintenance easier and more robust.

Best Regards all.