Search

Custom Search

Sunday, June 7, 2009

@prompt:




Description:
Use this function to prompt user for a value will be used during report run. For example if you want to run a monthly report against a specific month, you have to prompt the user to enter the Month or even select it from the list of value displayed.

 

Before we start:

I assume that you are familiar with BO universe designer and BO web inelegance. If you need to go through universe or Webi rich client tutorial please use the following links:

Syntax:
@prompt ('prompt text (1)', 'type (2)', 'list of values(3)', 'mono/multi(4)', 'free/constrained(5)')

 

Parameters:

Param Description Mandatory Values
1 Text used to prompt the user when he trying to run/refresh the report Yes N/A
2 Type of the expected value entered by the user and also must be same type of the object that we will use the prompt return value to compare with Yes A: alphanumeric
C: string
D: Date
N: Number
U: Unicode
3 List of values that will displayed to the user if he click on the Values button when he prompted to enter a value No Object defined to retrieve list of values
4 Number of valued allowed No Mono: user can select one value only
Multi: user can select Multi Values
5 User can edit enter a value by himself or not. No Free: user can type his own value
Constrained: user must select from list of values.

 


 

Where to use this function:
You can use this function anywhere; this is some places that you can use this function
  • Filter: you can use this function to prompt the user for a value that will use in filtering the retrieved data. [Click here for more information about conditions & Pre-defined filters in BO]
  • Where clause: when you create an object you can use this function in the where clause.
  • Select clause: you can use this function even in the select clause see examples.
  • Derived table: you can use this function in your derived table query. [Click here for more information about how to use prompt with derived tables]

     

 

Tips and Tricks:
  • You can use the same prompt in more than one place; just make sure that the prompt text exactly the same when you use it with other universe objects.
  • You can use data conversion function to convert the prompt returned value before using it. For example if the prompt return "Jan09" and you want to compare it with a Date column in database you have to convert it before using it. In our case we will use to_date (@prompt(,,,,,),'MONYY').
  • If your prompt will return multi value use IN operation instead of equal (=)
  • Note that not all users having permission to view list of values while they trying to run or refresh the report by default. The administrator should grant this permission to this user.
  • If you will use the free mode (user can type what he want) you should give a hint in the prompt text message about the data format expected. For example if the user should enter month in format (MON YY) then the prompt message should be descriptive like "Please enter month like Jan 09".

 


 


 

Example # 1 (simple prompt):
We need to create a new condition that will prompt user to enter a valid date to display data related to this date in our report.
Create a new condition with the specification below [Insert --> Condition]
  • Name: As of Date prompt
  • Description: Prompt user to enter a specified as of date value
  • Where:

    @select(Dimensions/As of Date) = @prompt (
    'Enter As of Date:', 'D', ['Dimensions/As of Date'], mono, constrained)
Notes:
  • Red single quote places. It will give you error message "Parse failed: invalid definition UNV0023"

     

 

Example # 2 (Prompt returns multi values):
We need to create a new condition that will prompt user to select cities that he wants to display revenue data
Create a new condition with the specification below [Insert --> Condition]
  • Name: Cities prompt
  • Description: Prompt user to select one or multiple cities to filter data according to
  • Where:

    @select(Dimensions/City) IN @prompt (
    'Select one or more cities from the list:', 'C', ['Dimensions/City'], Multi, constrained)
Notes:
  • We used Multi key word instead of mono this time this to indicate that the prompt will return one or more values.
  • Note also we used the IN operator instead of equal. This is because the return value is a collection of values not one single value as the previous example.

 

Example # 3 (user type Free Prompt):
We need to create a new condition that will prompt user to type the city that he want to display report data for.
Create a new condition with the specification below [Insert --> Condition]
  • Name: City prompt
  • Description: Prompt user to select or type a city
  • Where:

    @select(Dimensions/City) = @prompt (
    'Type a City name:', 'C', ['Dimensions/City'], mono, free)
Notes:
  • Note that we have used free key word instead of constrained. This will give the user the flexibility to type the city name directly without need to select form list of values.
  • Note that if the user type Paris while the stored value in @select(Dimensions/City) is PARIS then the query will return no data. To solve this issue you can use the Upper or lower function that will return the given string in upper case format or lower case format.
    UPPER(@select(Dimensions/City)) = UPPER(@prompt (
    'Type a City name:', 'C', ['Dimensions/City'], mono, free))
  • If you want the user to type multiple cities use this form
    @select(Dimensions/City) IN @prompt (
    'Type Cities name:', 'C', ['Dimensions/City'], Multi,
    free)
    Please note that user will enter values comma separated without space Like: (Paris,London,Roma,Cairo)

     


     
Example # 4 (From To prompt):
We need to create a new condition that will prompt user to enter "From Date" and "To Date" to display data related to this period in our report.
Create a new condition with the specification below [Insert --> Condition]
  • Name: From To prompt
  • Description: Prompt user to enter a specified period
  • Where:

    @select(Dimensions/As of Date) Between @prompt (
    'From Date:', 'D', ['Dimensions/As of Date'], mono, constrained) AND @prompt ('To Date:', 'D', ['Dimensions/As of Date'], mono, constrained)

 

Example # 5 (Use prompt with dimensions):
We need to create a new dimension that will display customer segment description based on what language user will select.
Prerequisites:
  • Language dimension Created.
  • Segment English Description created.
  • Segment France Description created.
  • Segment Dutch Description created.
  • Segment Arabic Description created.
Create a new Dimension with the specification below [Insert --> Dimension]
  • Name: Customer Segment Description
  • Description: Customer Segment Description based on the user selected language.
  • Select:
    Decode(@prompt (
    'Select Language:', 'C', ['Dimensions/Language'], mono, constrained),
    'EN', @select(Dimensions/Segment English Description),
    'FR', @select(Dimensions/Segment France Description),
    'DE', @select(Dimensions/Segment Dutch Description),
    'AR', @select(Dimensions/Segment Arabic Description), @select(Dimensions/Segment English Description))

Other information about Prompt:

Similar functions & Useful Links: