Stonefield Query
 
Stonefield Site Map
Stonefield Support

  Overview
  Submit Support Ticket
  Forums
  Online Help Files
  Services
  Pre-Sales Support
Online Webinars
Video Demonstrations
Feature Requests
  Software Maintenance
  Support Testimonials
  FAQ's
Quick Links
Buy Now!
Download Free Trial
Watch a Video
Contact Us

 
 You are here: Support * Support Forums   Search

 Stonefield Query Support Forum

Welcome to the Stonefield Query Support Forum. Please note that in order to participate in the support forums, registration at our site is required. If you are already a member of our site, please sign-in.

 

Subject: QW & GoldMine together

Topic is locked   

Author Messages
denisv
Posts:56

05/30/2007 1:54 PM Alert 

I have created reports which at a general level pull informatoo from both QuoteWerks and GoldMine. What I want to do this time may be more tricky and I was wondering would Step6 in the advanced section 'specify afterdata code' solve my problem or is thsi possible at all.

a) I have a report that shows totals for certain products and categories grouped by the Sales Rep field in QW. It is run by runtime start and end dates and works fine.

b) I also want to show the total number of calls logged in GoldMine for the Sales Rep over the same period.

c) The possible relationship is the Value in Sales Rep for QW is the same Value as User in GoldMine

Can this be done ?

tmansuy
Posts:161

05/30/2007 3:21 PM Alert 

This can be done by adding a second detail band to the report. The report would then have to be driven by a script in the afterdata event of the report that gathers the necessary records and sets up the relationships.

Another possible solution is, provided the ONLY thing you want is the total number of calls for a sales rep, you could create a function inside a repprocs.prg file that does a lookup for a salesperson and calculates that summary. Then, simply reference this script in a calculated field on the advanced layout of the report.

Trevor

denisv
Posts:56

05/30/2007 3:35 PM Alert 
Trevor, thank you for this. In order for me to more effectively support the end-user can you direct me to any other reference area that would assist me in acheiving this.
tmansuy
Posts:161

05/30/2007 4:43 PM Alert 

Sure:

You can find more information on user defined functions in the help file under "How To->Creating and Using User defined functions", or view it online at:

http://www.stonefieldquery.com/OnlineHelp/GoldMine/_0OQ0RLAG4.htm

If you decide to go the multi detail band route, here is a guide written by one of our developers on how to do this, with some comments thrown in by me:

To create a report with a parent and multiple unrelated children in Stonefield Query, do the following:

1. Ensure the User Can Edit SQL SELECT configuration setting is turned on in the Configuration Utility (ignore this step)

2. In Stonefield Query, create a new Quick Report

3. In Step 2, select only fields from the parent table, and group on one of the fields (for example, Customer Name). Be sure to include the primary key field (for example, Customer ID) if it's reportable; if not, you can add it in the Advanced Report Designer as described later. The reason this field is required is to match up with child table records.

4. In Step 2, click the Advanced button and go to Step 6 (AfterData code). Enter code similar to the following in the edit box:

lcAlias    = alias()
loDatabase = SQApplication.DataEngine.Databases.GetMainDatabase()
lcResults  = loDatabase.ExecuteSQLStatement('select * from FIRST_CHILD_TABLE', , 'Child1')
if not empty(lcResults)
    index on FIRST_CHILD_FOREIGN_KEY_FIELD tag Child1
    lcResults = loDatabase.ExecuteSQLStatement('select * from SECOND_CHILD_TABLE', , 'Child2')
    if not empty(lcResults)
        index on SECOND_CHILD_FOREIGN_KEY_FIELD tag Child2
        select (lcAlias)
        set relation to PRIMARY_KEY_FIELD into Child1, PRIMARY_KEY_FIELD into Child2
    endif
endif
select (lcAlias)

This code creates data sets from the two child tables and creates a relationship from the parent data set into these two data sets. Thus there are three data sets loaded: one that Stonefield Query created from the parent table and the two this code created from the child tables.

In this code, substitute the name of the first child table for FIRST_CHILD_TABLE, the name of the second child table for SECOND_CHILD_TABLE, the name of the foreign key for the first child table into the parent table for FIRST_CHILD_FOREIGN_KEY_FIELD, the name of the foreign key for the second child table into the parent table for SECOND_CHILD_FOREIGN_KEY_FIELD, and the name of the primary key field in the parent table for PRIMARY_KEY_FIELD. Here's an example using Customers as the parent table and Orders and Contacts as the child tables:

lcAlias    = alias()
loDatabase = SQApplication.DataEngine.Databases.GetMainDatabase()
lcResults = loDatabase.ExecuteSQLStatement('select * from Orders', , 'Child1')
if not empty(lcResults)
    index on CustomerID tag Child1
    lcResults = loDatabase.ExecuteSQLStatement('select * from Contacts', , 'Child2')
    if not empty(lcResults)
        index on CustomerID tag Child2
        select (lcAlias)
        set relation to CustomerID into Child1, CustomerID into Child2
    endif
endif
select (lcAlias)

5. Select Step 4 (AfterRun code) and enter code similar to the following in the edit box:

use in select('Child1')
use in select('Child2')

This code closes the two child data sets after the report has been completed. Omitting this code will cause an error if you run the report a second time since the AfterData code will try to create child data sets but those data sets are already open from the previous run.

6. Close the Customize Report Wizard. In Step 5 of the Quick Report Wizard, turn on Advanced Layout and click Edit.

7. In the Advanced Report Designer, if the primary key field from the parent isn't already in the report, add a field in the Group Header band with ParentTable.PrimaryKeyField (for example, Customers.CustomerID) as the expression. Regardless of whether you selected the field in the Quick Report Wizard or added it now, if you don't want this field displayed in the report, set its Print When expression to .F.

8. Choose Optional Bands from the Report menu and click Add to create a second detail band. Click OK.

9. Double-click the Detail 1 band bar and enter "Child1" (including the quotes) as the Target Alias Expression. Also, if you want to put column heading for the second detail band below the first, turn on the Associated Header and Footer Bands setting. Click OK.

10. Double-click the Detail 2 band bar and enter "Child2" (including the quotes) as the Target Alias Expression. Click OK.

11. Add the desired fields from the first child table to the Detail 1 band, ensuring they are aliased with Child1 (for example, use Child1.OrderID).

12. Add the desired fields from the second child table to the Detail 2 band, ensuring they are aliased with Child2 (for example, use Child2.ContactName).

13. If desired, add column headings for the Detail 1 band fields to the Group Footer band and column heading for the Detail 2 band fields to the Detail Footer 1 band.

14. Save the report.

Topic is locked



ActiveForums 3.6

 
 
   Privacy Statement  |  Terms Of Use
© 1996-2008 Stonefield Software Inc. All rights reserved.