Following the Docentric method to Add Additional Data to SSRS Report

Hello community,

Building on my successful inheritance class and use of an _addingRecord.addCalculatedField method, I was trying to repeat this but for some data from Invoice Lines. This is in the context of a Free Text Invoice.

My question is: What is the correct method to use to capture Free Text Invoice line data from table CustInvoiceLine? I need to get the LineNum field I think… unless there’s another way to go about this. I’m not seeing LineNum in my ddsp output currently.

This is what I’ve tried, but while this compiles, it doesn’t seem to run in the ERP system. I’m hoping my question is a normal beginning use case example of adding a field for a report line detail, and making some simple newbie mistake.

Here is an excerpt of just the relevant details of my class:

class WWIFreeTextInvoiceReportDSP extends DocFreeTextInvoiceReportDSP

{

#ISOCountryRegionCodes

#define.FreeTextInvoiceHeader('FreeTextInvoiceHeader')

#define.FreeTextInvoiceHeaderExt('FreeTextInvoiceHeaderExt')

#define.FreeTextInvoiceLines('FreeTextInvoiceLines')

#define.TaxLines('FreeTextInvoiceLines_Tax')

#define.TaxWithholdLines('FreeTextInvoiceLines_TaxWithhold')

#define.PrepayedLines('FreeTextInvoiceLines_Prepayed')

#define.PaymSchedLines('FreeTextInvoiceLines_PaymSched')

#define.MarkupLines('FreeTextInvoiceLines_Markup')

#define.PaymentStubLines('SalesInvoicePaymentStubTmp')

#define.FreeTextInvoiceLinesLocalization('FreeTextInvoiceLocalizationLines')

#define.CustInvoiceLine('CustInoviceLine')

...(details omitted)

protected void addDataFieldsForRdpTableRecord(DocXmlRecord _addingRecord, Common _rdpTableRecord, TableName _rdpTableName)

{

CustInvoiceLine custInvoiceLine;

super (_addingRecord, _rdpTableRecord, _rdpTableName);

if (_rdpTableName == tableStr(CustInvoiceLine))

{

// Add a new calculated field from the related CustInvoiceLine table.

_addingRecord.addCalculatedField('LineNum', custInvoiceLine.LineNum, 'Line number');

}

...(details omitted)

}

...(details omitted)

}

Then this is the result in system:

I’m hoping a more experienced person will see this and say ‘oh you just missed this or that’ etc.

Any help anyone could provide would be much appreciated.

Thanks again.

Hi Jim,

The error you’re getting seems to be unrelated to the code you’re showing.

You’re getting that error because at some point in your extension you’re trying to add the “VATForCountry” field to the FreeTextInvoiceLocalizationTmp record more than once.

Please debug your code to see at what point you get the error, there is probably a loop in your extension.

Hi Jim,

I’ve just noticed that I didn’t actually answer the question at hand, sorry for that!

You can add the line numbers to the Free Text Invoice report just by extending the addDataFieldsForLine() method in your inheritance class, like so:

protected void addDataFieldsForLine(DocXmlRecord _addingRecord, FreeTextInvoiceTmp _currentLine)
    {
        super(_addingRecord, _currentLine);

        CustInvoiceTrans custInvoiceTrans = this.custInvoiceTrans(_currentLine.JourTransRecId_DR);
        _addingRecord.addCalculatedField('LineNum', custInvoiceTrans.LineNum);
    }
1 Like

Hello Nenad,

Thank-you so very kindly for your reply to my posting in the forum! You. Are. The. Best!

So on this one, I found my bad attempt at adding the LineNum was the culprit.

Once I edited the method addDataFieldsForRdpTableRecord like so:

protected void addDataFieldsForRdpTableRecord(DocXmlRecord _addingRecord, Common _rdpTableRecord, TableName _rdpTableName)
{
    /*
    CustInvoiceLine     custInvoiceLine;

    super (_addingRecord, _rdpTableRecord, _rdpTableName);

    if (_rdpTableName == tableStr(CustInvoiceLine))
    {
        // Add a new calculated field from the related CustInvoiceLine table.
        _addingRecord.addCalculatedField('LineNum', custInvoiceLine.LineNum, 'Line number');
    }
    */

Note the /* */ commented out block.

Then my Free text invoice would again run without the errors reported above.

  • Jim

Hello Nenad,

There are two parts to my reply:
1: How could I use the Docentric help to find how to use this method?
2: Deep dive into the problem that remains, the LineNum is not coming through.

1: I tried searching on ‘addDataFieldsForLine’ but found no pages that talk about it on the Docentric site.
I searched in the original model DocentricAXSSRSReplicas model class for FreeTextInvoices, and did find the method, but the usage you suggest is not shown there, it’s used differently.
My point here is I’m curious on how to learn the usage methods.

2: LineNum EDIT: Was… not observed to be coming through. BUT IT IS coming through based on new report runs, but getting a #CONVERSION_ERROR#.
And… solved that newbie error with this: Conversion error in a template

Case closed!

Just a follow up on this, can you tell me what this segment does and how I would figure that out?

In this line:

        CustInvoiceTrans custInvoiceTrans = this.custInvoiceTrans(_currentLine.JourTransRecId_DR);

How would I learn what this argument is doing?

_currentLine.JourTransRecId_DR

Hi Jim,

I’m going to try and address your question here:

How could I use the Docentric help to find how to use this method? addDataFieldsForLine

The specific method “addDataFieldsForLine” is just a helper method in this case, just so the code looks neat in the end.

Usually you’d add everything you need in the extension to the addDataFieldsForRdpTableRecord() method (if the report in question is RDP based, of course).

You can find out more about the topic here.

How would I learn what this argument is doing? _currentLine.JourTransRecId_DR

In this case, it’s just the RecId of the related custInvoiceTrans table, that we have added by extension to the freeTextInvoiceTmp table.
We just use that RecId to find the related custInvoiceTrans record and get the line numbers from there.

You would have to go through the code and see where we have added and populated this particular extension field.

We don’t really have an article or how-to manual for this, as it’s unfeasible to explain every line of code we have done, but usually it’s all well commented in the code itself.