Learning how to Add Additional Data to SSRS Report using the Docentric method

Hello all,

Building off my last experience in Following the Docentric method to Add Additional Data to SSRS Report - #6 by JTWWI I have more fields to find or add.

Here’s my 2 part question:
Part 1: When faced with a form that has a fasttab that contains a grid table to which the user can add additional columns, how do you find out the underlying field, and table that stores that data?
Part 2: Then… how do you find the appropriate Docentric x++ methods and arguements to bring that into your document?

In my current case I’m trying to bring in data that appears to be on the ‘Intercompany free text invoice’ to the FreeTextInvoice DDSP.

When I right click on a table row column and select the form information I see:
image

Part 1:
How do I track something like: SysGen_{73E8D238-96-4FDF-AEBE-E1EA39CA0F4F} down to a field and table?

Part 2:
Then when I find that how do I find the appropriate Docentric x++ methods and arguements to bring that into your document?

Thanks again.

Hi Jim,

Part 1: Finding fields:

This is not specifically Docentric related, but whenever a form control on the UI has a name like “SysGen…” this means that it was added to the form via the form personalization feature of D365FO (link to MS documentation here).

You can find the underlying table just by searching up the table label that is shown in the “Insert columns” form dialog. For example, here it’s “Intercompany free text invoice lines for project”:

PART 2: Adding fields to Docentric:

To add any field or even record to Docentric you just need to use the addCalculatedField() and addCalculatedChildRecord() methods, these will allow you to add anything you want to the Docentric template.

First you would create a table buffer, then you would populate it in the standard way, by finding the appropriate relation between different tables and then writing the appropriate select statement.

After you have the populated buffer, you would just add the field you want by using the addCalculatedField() method in your extension of the DSP class, either in the extended addDataFieldsForRdpTableRecord() method or in the extended addAdditionalDataFieldsForQueryRecord() method.

An example of adding fields to an RDP based report can be found here, and the same but for query based report can be found here.

1 Like

Hello again!

Building on this discussion above…

Has anyone obtained data for DocFreeTextInvoiceReportDSP from CustInvoiceLineInterProj for Intercompany Project Invoices?

I would post to MS Community, but since the DSP class objects seem to be Docentric items I was hoping it was okay to post here? Apologies if it’s not a good place, any suggestions?

After a long pause to fully learn Electronic reporting, I’m back at this task with more experience with more training completed.

Looking at what works in Electronic reporting to obtain the ProjId from the CustInoviceLineInterProj table the I need a path similar to this Electronic Reporting path… but I need to traverse this within my custom FreeTextInvoiceReportDSP class:
ER path: CustInvoiceJour/$CustInvoiceTrans_OrderByLineSeqNum.‘$CustInvoiceLine’.‘<Relations’.CustInvoiceLineInterProj.ProjId

I was using the method addDataFieldsForLine but the following code is not working, note I’ve invoked the findByCustInoviceLine method of the CustInoviceLineInterProj table. But given the path I found in Electronic Reporting my methods are not working, I’m thinking I maybe have to use a different method as addDataFieldsForLine is accepting a FreeTextInvoiceTmp item. .I know I know, not the Electronic Reporting path is may not to be informative to try and do the same thing in X++ but I’m using whatever resource I can find.

Anyway here’s the methods I have created or modified:

// Testing to add CustInvoiceLineInterProj table to the FreeTextInvoiceTmp table
protected CustInvoiceLineInterProj custInvoiceLineInterProj(RecId _custInvoiceLineInterProjRecId)
{
CustInvoiceLineInterProj custInvoiceLineInterProj;

    if (_custInvoiceLineInterProjRecId)
    {
        custInvoiceLineInterProj = CustInvoiceLineInterProj::findByCustInvoiceLine(_custInvoiceLineInterProjRecId);
    }
    return custInvoiceLineInterProj;
}

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

    // Get the related CustInvoiceTrans record using JourTransRecId_DR which is the InvoiceId.
    CustInvoiceTrans custInvoiceTrans = this.custInvoiceTrans(_currentLine.JourTransRecId_DR);
    
    // This works; LineNum comes through.. Get the related CustInvoiceTrans record using JourTransRecId_DR (InvoiceId).
    _addingRecord.addCalculatedField('LineNum', custInvoiceTrans.LineNum);

    // Testing to add CustInvoiceLineInterProj table to the FreeTextInvoiceTmp table 
    // using the InvoiceId as the joining field
    // this doesn't work... trying to figure out what silly mistake I must be making... 
    CustInvoiceLineInterProj custInoviceLineInterProjItem;
    custInoviceLineInterProjItem = this.custInvoiceLineInterProj(_currentLine.JourTransRecId_DR);
    _addingRecord.addCalculatedField('InterProjProjId', custInoviceLineInterProjItem.ProjId);
}

Hi Jim,

This is a little out of scope of Docentric support, but I’m going to try to help you and it might also benefit the community.

From the code it looks like you’re using all the Docentric specific methods correctly and that you have successfully made a class that inherits the Free text invoice DSP class, nicely done!

I think the problem here is just that the CustInvoiceLineInterProj::findByCustInvoiceLine() method is expecting the RecId of the CustInvoiceLine record which is associated with the CustInvoiceLineInterProj record.

There’s nothing Docentric specific about finding out the relations between tables. I’ll post some quick tips on how to do this, by using your use case as an example:

  1. We first need to find out what relation we’re looking for. By going to the definition of the method, we can see that it is looking for a CustInvoiceLine RecId:

  2. We can then go to the CustInvoiceLineInterProj table and search for the field, to find if there are any relations using that field:
    image

Now we know that we need the RecId of the CustInvoiceLine, but the problem is that we don’t have the CustInvoiceLine.RecId when reading the FreeTextInvoiceTmp table, because the temporary table that’s used for printing has different RecIds than the original lines.

So here we need to find a way to get the CustInvoiceLine records, in this case you have already found the related CustInvoiceTrans record, so we can use that, by using the CustInvoiceTrans.SourceDocumentLine field.

There might be other ways to find the CustInvoiceLine record you need, but I hope this one will suffice.

Below’s a working example that you can use as a basis for your customization:

    protected CustInvoiceLineInterProj custInvoiceLineInterProj(RecId _custInvoiceLineRecId)
    {
        CustInvoiceLineInterProj custInvoiceLineInterProj;

        if (_custInvoiceLineRecId)
        {
            custInvoiceLineInterProj = CustInvoiceLineInterProj::findByCustInvoiceLine(_custInvoiceLineRecId);
        }
        return custInvoiceLineInterProj;
    }

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

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

        _addingRecord.addCalculatedField('LineNum', custInvoiceTrans.LineNum);

        CustInvoiceLineInterProj custInoviceLineInterProjItem;
        custInoviceLineInterProjItem = this.custInvoiceLineInterProj(CustInvoiceLine::findBySourceDocumentLine(custInvoiceTrans.SourceDocumentLine).RecId);
        _addingRecord.addCalculatedField('InterProjProjId', custInoviceLineInterProjItem.ProjId);
    }

Hope this helps!

1 Like

Hello Nenad,

Thanks for going beyond the usual support and as you said it may benefit the community.

I carefully read your response, implemented it, and voila! I have the data I need and I think I understand how it was achieved.

With great emphasis I thank-you for this forum post that has enabled me to meet my goal.

Very best regards,

  • Jim