Showing results for 
Search instead for 
Do you mean 
Community Home Request Access Read Blogs Share Your Ideas Search Community View My Settings
Reply
Nickel Contributor
Posts: 93
Registered: ‎01-02-2010
Accepted Solution

Command button to preview report

If someone could point me in the right direction, it would be much appreciated.

 

I want to add a button to the Ticket Details form which opens a specific Crystal Report in preview mode, selecting the current ticket only (so somehow I have to pass the current TicketID to the reporting engine as a filter).

 

Sounds simple enough, but what's the best way of achieving this?

 

Many thanks.

Employee
Posts: 629
Registered: ‎04-24-2009

Re: Command button to preview report

[ Edited ]

If you have 7.5.2 or higher you can add the following JavaScript to the OnClientClick event handler associated with the button:

 

 

javascript:ShowReport("Ticket:My Detail Report", "TICKET", "tDEMOA00001N");

 

 

OR

 

// This will display the report using the current Ticket entity id (if on a Ticket detail view).

 

javascript:ShowReportByName("Ticket:My Detail Report");

 

Please see ShowReportUtil.js; there are many ways to display a detail report.

 

/* Shows the report defined by ReportNameOrId using the EntityTableName and EntityId values. */
/* The ReportNameOrId can be a FAMILY:NAME value or a PLUGIN.PLUGINID value. */
/* The EntityTableName should be the main table associated with the report (i.e. the main entity). */
function ShowReport(ReportNameOrId, EntityTableName, EntityId)

 

/* Displays the default report for the current view and entity, if a report has been associated with the view. */
function ShowDefaultReport()

 

/* Displays a report by FAMILY:NAME. The report should be based on the main table associated with the current view. */
function ShowReportByName(ReportName)

 

/* Displays a report by PLUGIN.PLUGINID. The report should be based on the main table associated with the current view. */
function ShowReportById(ReportId)

 

Thanks

 

Mike

 

Nickel Contributor
Posts: 93
Registered: ‎01-02-2010

Re: Command button to preview report

Mike

 

That worked a treat, thank you very much.

 

Phil

Employee
Posts: 629
Registered: ‎04-24-2009

Re: Command button to preview report

Glad to help.

 

Thanks

 

Mike

Copper Super Contributor
Posts: 104
Registered: ‎06-29-2009

Re: Command button to preview report

Hello,

 

I'd like to use a LinkButton on the taskpane (only with Contact).

How Can I use these scripts to execute a crystal report.

Exemple, i'm on a list of contact and in the taskpane, I click on the link and want to have a specific report with all contacts in the list.

When I click on the link I have all contactid in a string and then ?

How can I call the function PopulateGlobals with parameters ?

 

Thanks for your help !

 

Ben

Employee
Posts: 629
Registered: ‎04-24-2009

Re: Command button to preview report

The EntityId parameter in PopulateGlobals() can be a single EntityId or a string of comma-separted ids. This means that the EntityId parameter in ShowReport(ReportNameOrId, EntityTableName, EntityId) should work for you. I don't think this support was in the original version, but should be in 7.53.

 

You can add it to earlier versions (I think 7.52 is the earliest), by updating PopulateGlobals() as follows:

 

function PopulateGlobals(ReportId, EntityTableName, EntityId) {
    var strWSql;
    var strKeyField = EntityTableName + "." + EntityTableName + "ID";
    var strSqlQry = "SELECT " + strKeyField + " FROM " + EntityTableName;

    if (EntityId.indexOf(",") == -1) {
        strWSql = "(" + strKeyField + " = '" + EntityId + "')";
    }
    else {
        var arrIds = EntityId.split(",")
        var strIds = "'" + arrIds.join("','") + "'"
        strWSql = "(" + strKeyField + " IN (" + strIds + "))";
    }

    GLOBAL_REPORTING_PLUGINID = ReportId;
    GLOBAL_REPORTING_KEYFIELD = strKeyField;
    GLOBAL_REPORTING_RSF = "";
    GLOBAL_REPORTING_WSQL = strWSql;
    GLOBAL_REPORTING_SQLQRY = strSqlQry;
    GLOBAL_REPORTING_SORTFIELDS = "";
    GLOBAL_REPORTING_SORTDIRECTIONS = "";
    GLOBAL_REPORTING_SS = (GLOBAL_REPORTING_URL.toUpperCase().indexOf("HTTPS") == -1 ? "0" : "1");
}

 

 

Thanks

 

Mike

Nickel Contributor
Posts: 58
Registered: ‎03-31-2009

Re: Command button to preview report

Hi Mike,

 

Have you got the code to get this to work on Disconnected Web Clients?

Regards,

Steve Robertson
Senior CRM Consultant
Collier Pickard Ltd
Employee
Posts: 629
Registered: ‎04-24-2009

Re: Command button to preview report

It looks like there is a defect running the ShowReport() JavaScript API in a Disconnected Web Client environment; it's still running against the reporting server instead (based on studying the code). I'll send an e-mail to QA and have them validate.

 

Thanks

 

Mike

Highlighted
Nickel Contributor
Posts: 58
Registered: ‎03-31-2009

Re: Command button to preview report

Good News - fixed in Sage SalesLogix Version 7.5 Service Pack 3 Web Hot Fix Package 09; now works on Disconnected Web Clients!

 

11083631 In the Disconnected Web Client with Remote Web Reporting, user receives errors when clicking ShowDefautReport().

 

 

Regards,

Steve Robertson
Senior CRM Consultant
Collier Pickard Ltd
Employee
Posts: 629
Registered: ‎04-24-2009

Re: Command button to preview report

With regard to other versions, I believe the fix is slated for 7.5.4 Web Update 04. The fix, of course, will also be in 8.0.

 

Thanks

 

Mike