Home | Forums | Contact | Search | Syndication  
 
 [login] [create account]   Thursday, November 21, 2024 
 
How to Filter a SalesLogix Crystal Report by ID at Runtime  
Description:  This article describes how to call provide a Crystal Reports parameter to a report at runtime via a script. This example details how to feed the current OpportunityID to a report when a button is clicked.

Category:  Architect How To Articles
Author:  Mark R. Bailey
Submitted:  6/6/2007
   
Stats: 
Article has been read 32103 times

Rating: - 4.5 out of 5 by 28 users
 

fiogf49gjkf0d
How to Filter a SalesLogix Crystal Report by ID at Runtime

This article describes how to call provide a Crystal Reports parameter to a report at runtime via a script. This example details how to feed the current OpportunityID to a report when a button is clicked.


Plugins Involved

  • A launch script to call the report and create a global variable.
  • A script that launches with the report's WhenOpened event.
  • The report to print.

Launch Script

Call a script that creates a global variable with the GlobalInfoSet function, then launches a specific report via the DoInvoke function.

Sub Main
Dim oppid

    oppid = Application.BasicFunctions.CurrentOpportunityID

    Application.GlobalInfo.Add "g_TemporaryOpportunityID", oppid
    Application.BasicFunctions.DoInvoke "CrystalReportPreview","Opportunity:Placement"
End Sub


WhenOpened Script

On the report that you want to filter, for the WhenOpened event (properties of the report itself, accessible by selecting Properties with a right-click from Manage Reports in Architect), select an active script to execute and use the ReportAddCondition function to create a parameter for the report that you execute.

Sub Main
Dim oppid

    oppid = Application.GlobalInfo("g_TemporaryOpportunityID")
    With Application.BasicFunctions
         .ReportClearConditions
         .ReportAddCondition "Opportunity:OpportunityID", "=", "'" & oppid & "'" , "string", ""
         .GlobalInfoClear "g_TemporaryOpportunityID"
    End With
End Sub


Execute the Script When the Report Opens

  1. Click Manage | Reports from within Saleslogix Architect.
  2. Locate the report that you called from the launching script (example above), and double-click.
  3. On the Execution tab, specify properties for the When Open event by clicking the elipsis.
  4. For Action, select "ActiveScript."
  5. For Argument, locate and select the When Open script (like the script example above).
See the screenshot below:




Final Step

Associate the launch script with an event in Saleslogix, whether it's the clicking of a button, or a script that launches the report directly, or what not.

 

About the Author

Mark R. Bailey
Promega

fjrigjwwe9r1SiteUser:UserBio
fiogf49gjkf0d


View online profile for Mark R. Bailey
 

[ back to top] [ send to a friend]  

Rate This Article you must log-in to rate articles. [login here] 
 
Please log in to rate article.
 

Comments & Discussion you must log-in to add comments. [login here] 
 
Author Article Comments and Discussion
Susan Jack
 

Re: How to Filter a SalesLogix Crystal Report by ID at Runtime
Posted: 2/20/2008 1:00:15 PM
fiogf49gjkf0d
If I launch the report by using a launch script it all works fine.
BUT, I want to launch the report by clicking on the "Reports" icon and selecting the report from the "Reports" window. When I run the report from there it doesn't seem to call the 'When Open' script. I have even added a msgbox popup in the 'When Open' script and the popup shows when I run from the launch script, but not when I run from the "Reports" window.
 
Susan Jack
 

Re: How to Filter a SalesLogix Crystal Report by ID at Runtime
Posted: 2/20/2008 1:27:06 PM
fiogf49gjkf0d
Here I am answering my own question. It seems that the 'When Open' script does run when the report is run from the "Reports" window but the msgbox does not pop up.
 
Susan Jack
 

Re: How to Filter a SalesLogix Crystal Report by ID at Runtime
Posted: 2/20/2008 4:50:55 PM
fiogf49gjkf0d
OK one more time, after much testing and frustration it seems that when the report is run from the "Reports" window that the 'When Open' script doesn't run.
 
Susan Jack
 

Re: How to Filter a SalesLogix Crystal Report by ID at Runtime
Posted: 2/20/2008 4:51:19 PM
fiogf49gjkf0d
OK one more time, after much testing and frustration it seems that when the report is run from the "Reports" window that the 'When Open' script doesn't run.
 
Robert Levine
 

Re: How to Filter a SalesLogix Crystal Report by ID at Runtime
Posted: 5/12/2008 5:34:36 PM
fiogf49gjkf0d
From what I am now learning, Slx version 7.2 uses a new report viewer which doesn't allow the use of the "When" events that are defined in a report's properties. I'm now trying to figure out how to set up filters in code to replace our old method. Any ideas, or can you direct me to the appropriate document?
 
Paul DeSaro
 

Re: How to Filter a SalesLogix Crystal Report by ID at Runtime
Posted: 6/10/2008 8:46:54 AM
fiogf49gjkf0d
Is the problem with 7.2 confirmed?
 
Kevin
 

Re: How to Filter a SalesLogix Crystal Report by ID at Runtime
Posted: 7/21/2008 8:26:56 AM
fiogf49gjkf0d
I just tried this in v7.2.1 and it worked perfectly! Thanks for the well-written article.
 
JJE
 

Re: How to Filter a SalesLogix Crystal Report by ID at Runtime
Posted: 10/14/2008 12:50:04 PM
fiogf49gjkf0d
Hello,

I just tried this on 7.2.2 and it worked only once.
When I close the report and tried to reopen it, it doesn't work...nothing happens!
 
Guy Barrett
 

Re: How to Filter a SalesLogix Crystal Report by ID at Runtime
Posted: 8/11/2009 7:09:23 AM
fiogf49gjkf0d
How does this work if I need to use the "in" operator rather than "=" or "<" etc...?

I have tried, but can't seem to get it to work. eg...

Application.BasicFunctions.ReportAddCondition "PRODUCT:PRODUCTID", "in", "('XXXXXXXXXXXX','YYYYYYYYYYYY')" , "String", "AND"
 
Samantha Knigge
 

Re: How to Filter a SalesLogix Crystal Report by ID at Runtime
Posted: 9/28/2009 10:10:53 AM
fiogf49gjkf0d
I'm having the same issue that JJE reported. It works one time when the report is actually printed, but then slx has to closed before the button will work again. Did anybody ever figure out a solution for this?
 
Samantha Knigge
 

Re: How to Filter a SalesLogix Crystal Report by ID at Runtime
Posted: 9/28/2009 10:11:04 AM
fiogf49gjkf0d
I'm having the same issue that JJE reported. It works one time when the report is actually printed, but then slx has to closed before the button will work again. Did anybody ever figure out a solution for this?
 
JJE
 

Re: How to Filter a SalesLogix Crystal Report by ID at Runtime
Posted: 9/28/2009 10:37:20 AM
fiogf49gjkf0d
Samantha,

I never found really what happens, so I write a little Function to call my reports and made a Post about this here: http://www.slxdeveloper.com/forum.aspx?forumid=2000&postid=19254

It works with one or more conditions.
I hope this will help you.
 
 

       Visit the slxdeveloper.com Community Forums!
Not finding the information you need here? Try the forums! Get help from others in the community, share your expertise, get what you need from the slxdeveloper.com community. Go to the forums...
 



 slxdeveloper.com is brought to you courtesy of Ryan Farley & Customer FX Corporation.
 This site, and all contents herein, are Copyright © 2024 Customer FX Corporation. The information and opinions expressed here are not endorsed by Sage Software.

code of conduct | Subscribe to the slxdeveloper.com Latest Article RSS feed
   
 
page cache (param): 11/21/2024 12:04:38 PM