Reports and Graphs using Key Attribute Data

Hints, Tips and Tricks

Technical Hints Tips and Tricks that cover customization and development using Sage CRM. API usage and coding are covered.

Reports and Graphs using Key Attribute Data

  • Comments 7
  • Likes
Reports and Report Charts can only be built from views. So If we want to create a Report Chart that uses Key Attribute Data then we must first create the view.

The structure of the tables that holds the key attribute data is complex and trying to work this out on our own to build a view would be a deeply unpleasant task. There is, however, a trick we can use.

Groups (or sometimes called Target Lists) work in a similar way as Reports. The code that creates them has a lot of overlap and both the definitions of Groups/Target Lists and Reports are held in the same meta data tables.

The trick to get the SQL for our view requires us to build a Group (target list) that uses the Key Attributes in which we are interested.

We can use the standard demo system for this and create a view that uses the existing demo Key Attribute Category 'Installed Software' that is linked to the company table. We can find this under the Key Attribute tab when looking at a Company.

We need to create a new Group for the Company entity based on the standard CompanyGroup. We want to create a pie chart to show the numbers of Companies using software of each type.

We then need to include from the Key Attributes (Installed Software) the field that you want (Existing Enterprise Software) against the company entity. The Key Attribute Data should be associated with the Group Contents and the Search Criteria. If we are wanting to plot a chart against all data then each of the options in the selection list should be chosen when answering the question 'Matches any of the values'.

Once the Group definition has been saved. If we are logged on to the system as the System Administrator then we will be able to see the Advanced Button at the bottom right of the screen.

If we click this button we will have access to the underlying SQL of this Group. Which may look something like this:

SELECT DISTINCT Comp_CompanyId, comp_name, addr_city, comp_emailaddress,
comp_website, comp_secterr, V6.OutputString DDFld_16x5 FROM vtargetlistcompany
INNER JOIN vDynamicData V6 on Comp_CompanyId = V6.DData_EntityID AND
(V6.DData_Entity=5 and V6.DData_FieldID=16) AND
(V6.DData_ShortStr IN (N'2', N'3', N'1', N'4'))
WHERE Comp_CompanyId IS NOT NULL

We can now use this SQL to create a new view against the Company entity. This will have to be done through the interface

Administration>Customization>Company and then choose the View tabs. We should only put the SQL that we need in place so I will edit the view SQL to drop the DISTINCT

CREATE VIEW vCompanyKA
AS
SELECT Comp_CompanyId, comp_name, addr_city, comp_emailaddress, comp_website,
comp_secterr, V6.OutputString DDFld_16x5 FROM vtargetlistcompany INNER JOIN
vDynamicData V6 on Comp_CompanyId = V6.DData_EntityID AND (V6.DData_Entity=5
and V6.DData_FieldID=16) AND (V6.DData_ShortStr IN (N'2', N'3', N'1', N'4'))
WHERE Comp_CompanyId IS NOT NULL

The SQL above assumes that the view was created with the name vCompanyKA.

Now that we have the view created we need to make sure that it is marked in the definition screen as available for reports.

Once we have saved the view we can then build the report. This report can have graphs that make use of the Key Attribute data and these graphs in turn can be included and called from user dashboards.
Comments
  • I have tried this twice and I get the same result - the report throws an error like 'An error occurred while running the report. '_187' is not a valid integer value'. My first two reports using Key Attribute Data and both do not run. That's 100% failure. Someone said not to use KAD as it was flakey when it came to reporting. I'm starting to believe them.

    Is there any way of debugging the error? There is nothing in the SQL log in Sage. The SQL runs fine, retrieving the recordset. The view was accepted by Sage. The only place '_187' appears in the SQL is in the field name 'V6.OutputString DDFld_187x13'.

  • I followed this to the letter but with the Person table. I designed two reports and both reports did not run. Both reports complain about a string not being a valid number. The error was:

    An error occurred while running the report. '_187' is not a valid integer value

    It turned out the report did not like the alias created by Sage for the OutputString field in the system view vDynamicData. The SQL generated by Sage gives the field the alias ‘DDFld_187x13’. It is this alias that causes the report to not run – to fail with the error message above.

    To resolve the issue I changed the alias to ‘getsalerts’. The report now works as expected.

  • Dean,

    I have been out of the office and have just read your comments.  I am glad that you have sorted everything out.

  • HI Jeff,

    I have followed these steps in Version 7.1 and the graphic is appearing with the ddata_shortstr code rather then the translation.  Eg:  '1' instead of 'Software Brand name' for Expense Software Installed.  I have linked the custom captions table in my view but this isn't making any difference.  Is this a bug or am I doing this wrong?

    Thanks Jeff.

    Regards,

    Penny Vaskess

    RDA Group

  • Penny

    I am not sure.  Have you checked whether there are translations for the values in the ddata_shortstr field?  It is probably not a bug because the Dynamic Data would not have been designed to be used for this.

  • I am having the same issue. I get the short code and not the translated value. I have poured through the tables and cannot find any place the translated values are stored.

  • Hi Dadeitch,

    I didn't resolve this and don't use KAD now - as reports are crucial on my clients sites.  

    Cheers.