Learn about Cognos 8 from a CX User

Report
Cognos Prompting
Prepared by Eric Urff of Daytona State College
([email protected])
Presented by Talia Brown of Graceland University
([email protected])
© 2012 Jenzabar, Inc.
Overview
Question and Answers in the following areas:
•
•
•
•
•
•
© 2012 Jenzabar, Inc.
What generates a prompt?
Building a prompt page
Which tables to use for prompting?
Specific examples as requested
Date Prompting
Tips and Tricks
What Generates a Prompt?
 Using ?Parameter? In place of a variable in a filter. The
parameter is a unique name surrounded by question marks.
 Example (Before and After):
 [Student Academic].[Course Work].[Course Work Session Code] =
'FA‘
 [Student Academic].[Course Work].[Course Work Session Code] =
?pSess?
 Suggestions:
• Use lowercase p in front of prompt name. Just a recommendation
for standards so that you can recognize prompts easily. This comes in
handy if the prompt is used in other advanced areas for reports.
• For multiple selection:
• [Course Work Session Code] in (?pSess?) << The parenthesis are not required for
this to work but recommended to keep it there for less confusion.
© 2012 Jenzabar, Inc.
Automatic Prompt Generation
To Use or NOT to Use
 Recommend to NOT use the automatic prompting
unless you have thoroughly adjusted the framework
manager. Most of us have NOT.
 So what to do??
 Create PROMPT PAGES and control what and where the
data comes from.
© 2012 Jenzabar, Inc.
4
Building Prompt Pages
1. Hover over Page Explorer area
2. Click on Prompt Pages in Page Explorer Area
3. Drag Page Icon from Insertable Objects over into
the Prompt Pages area
4. Double click on your prompt page (this will open
up the prompt page area).
Tip: Put a table in the prompt area to easily layout
your prompts as you move forward.
BIGGER Tip: Make a template for others to start
from.
Saves effort and time.
© 2012 Jenzabar, Inc.
Prompt Types
Top three most widely used
 Value Prompt – Select from a dropdown list of items
to be chosen. Can be set for single or multiple
selection.
 Text Prompt – User enters in a value or text that you
wish to be filtered on. Useful for allowing an ID
number of a specific student.
 Date Prompt – Ability to select date via a calendar
interface.
 Also:
• Select and Search Prompt – Ability to filter down on your
selections prior to selecting final values.
© 2012 Jenzabar, Inc.
Prompt Types - Creation
 Value Prompts:
• Use Collections to pre-populate set values
• (i.e. FA, SP, SU)
• Use queries to populate the values with what is
in tables.
• Use the Report Studio Prompt Queries when able.
These are usually standalone tables that have few
records in them so that the lookup is FAST.
Filter your prompt queries to limit the data that
shows up to what is desired.
© 2012 Jenzabar, Inc.
Prompt Types
Specific Examples Requested
 Filter academic calendar years to only
show previous 2 years and one ahead.
[Calendar Year] between
year(current_date)-2 and
year(current_date)+1
 How to select High Schools and show
students that attended selected HS.
© 2012 Jenzabar, Inc.
Date
Prompting
Default today
Default one year ago
Default one week ago
Default 1st day of
previous month
Default Last day of
previous month
All of the dates are set
in the html item that is
included on the page
© 2012 Jenzabar, Inc.
<SCRIPT language="javascript">
function setTextBoxPromptValue(promptName, promptValue)
{ // *** This function assigns the promptName variable the value that is specified in promptValue *** //
var SpotOnTargetControl = G_PM_THIS_.getControlByName(promptName);
var SpotOnPCType=SpotOnTargetControl._type_;
if(SpotOnPCType == "cognos.Prompt.Control.Text")
{ SpotOnTargetControl.bParse(promptValue,"");
SpotOnTargetControl.setCurrentValue();
SpotOnTargetControl.checkData();
}
}
function dtFormat(inDate, inFormat)
{ var yyyy = inDate.getYear(); var d=inDate.getDate();
var m = inDate.getMonth()+1;
var newformat;
var dd = d; var mm = m;
if (dd < 10) {dd = "0" + dd; }
if (mm < 10) {mm = "0" + mm; }
if (inFormat == "YYYY-MM-DD")
{return (yyyy + "-" + mm + "-" + dd);
}
if (inFormat == "MM/DD/YYYY")
{ return (mm + "/" + dd + "/" + yyyy);
}
return (inStr);
} // End of function
</SCRIPT>
© 2012 Jenzabar, Inc.
Java Script Dates:
Used to pre-populate
fields on prompt page
<SCRIPT>
// ****** Use to set the date variables to specific formats *******
var start;
JavaScript Dates
(Continued )
if (!start) // This is forces the routine to only be executed when the screen is first loaded (not subsequent updates
{
// in the event of cascading prompts).
var d;
d = new Date();
// ** Here we are going to set pDate1 to Current Date
d.setDate(d.getDate());
// One Day Ago
pickerControlpDate1.setValue( dtFormat(d, "YYYY-MM-DD") );
// THIS IS THE FORMAT TO SET A DATE PICKER .. THE NAME FIELD
MUST BE SET ON THE PARAMETER
d=new Date();
// Default pDate2 to one year ago
d.setYear(d.getYear() -1);
// Previous Year
setTextBoxPromptValue("pDate2", dtFormat(d, "YYYY-MM-DD") ) ; // Put todays date into pDate2 (YYYY-MM-DD format)
d = new Date();
// ** Here we are going to set pDate3 to 7 days prior to today
d.setDate(d.getDate()- 7); // 7 Days Ago
setTextBoxPromptValue("pDate3", dtFormat(d, "MM/DD/YYYY") ) ;
d = new Date();
// ** Here we are going to set pBegDate to 1st day of previous Month
d.setDate(1);
// First Day of month
d.setMonth(d.getMonth() -1); // Previous Month
pickerControlpBegDate.setValue( dtFormat(d, "YYYY-MM-DD") );
// THIS IS THE FORMAT TO SET A DATE PICKER .. THE NAME FIELD
MUST BE SET ON THE PARAMETER
d = new Date();
// ** Here we are going to set pEndDate to last day of previous month
d.setDate(1);
// Set date to first day of current month
d.setDate(d.getDate() -1);
// and subtract one day to get last day of previous month
pickerControlpEndDate.setValue( dtFormat(d, "YYYY-MM-DD") );
}
start=1;
</SCRIPT>
© 2012 Jenzabar, Inc.
Date Prompting - (My Default Layout)
File:
DatePromptPage.txt
***********************************
***********************************
****
***** Best done using NOTEPAD
*****
***** 1. Select all from below the cut line
and copy into clipboard *****
***** 2. Go into cognos report
*****
***** 3. Hover of Page Explorer - Click on
Prompt Pages Folder
*****
***** 4. Click on right side in blank area of
Prompt Pages
*****
***** 5. Paste contents of clipboard
<CTRL-V>
*****
***********************************
***********************************
****
*****
COPY AND PASTE FROM BELOW
NEXT LINE TO END OF FILE
*****
***********************************
***********************************
****
© 2012 Jenzabar, Inc.
Cascading Prompts
 Cascading prompting can be used to fill
prompts after another prompt has been
filled.
 Be careful in using the auto-submit property.
The report may start up before you are ready.
 Instead add a Reprompt Button on the page
to reset other prompts if they are based on
previous values.
 Each query can be driven by a prompt
selected in a previous query.
© 2012 Jenzabar, Inc.
TIPS / Tricks
 Create Templates for Prompt Pages
 Click NO on main query for property ‘Use for
Parameter Info’
• Can use a user defined table for generated prompts
that may be more useful.
• *A user can copy objects between different reports
 The date prompt page may be loaded from the .txt
files that are enclosed. Cut and paste as described
at beginning of the file.
© 2012 Jenzabar, Inc.
Any Questions?
© 2012 Jenzabar, Inc.

similar documents