For Cognos 11.1.7 Trying to figure out the syntax for a macro prompt where I can set the default to be all members - cognos

Cognos 11.1.7
Need help with syntax on a macro prompt so the default can be to select all members
Here is a simple example that works
set([Generic].[Groups].[Location].[Location] -> ?Location?)
If I wanted to hard code a value I could use this as a slicer
[Generic].[Groups].[Location].[Location]->[all].[1]
What is the syntax for creating a macro prompt with a default of all members?
i.e. instead of ?Location?
Something like this:
#Prompt('Location', 'token', '[all]')#
or maybe like
#Prompt('Location', 'memberuniquename', '[all]')#
Open to using different techniques (filter, set, etc)

Fill in the default text parameter of the prompt macro.
https://www.ibm.com/docs/en/cognos-analytics/11.2.0?topic=macros-mandatory-optional-prompts
"DefaultText
This optional parameter is the text to be used by default. If a value is specified, the prompt is optional.
If you use a space and no values are provided in the Prompt Value dialog box, a Where clause is usually not generated.
If you use text and no values are provided in the Prompt Value dialog box, a Where clause is usually generated using the default value.
Ensure that the text you provide results in a valid SQL statement."
https://www.ibm.com/support/pages/using-prompt-macro-optional-andor-required
You can also set a property in the filter in FM to make it optional.

Both
#Prompt('Location', 'memberuniquename', '[Generic].[Groups].[Location].[Location]->[all].[1]')#
and
#Prompt('Location', 'token', '[Generic].[Groups].[Location].[Location]->[all].[1]')#
should work. You also have the option to set a default value on the actual prompt object.

Related

Primefaces SelectOneMenu, selection on filter

A user of one of my applications has observed a strange behaviour of the selectOneMenu of Primefaces when using filters.
I have a mask with some fields, some of them are selectOneMenues. I deliver values via a map of Strings and use a filter on them, so the user can search for specific values, in this case currencies.
I have set a default value for this field (as the value in the object behind this field).
So, imagine the following case:
User opens the mask - default value is set on the selectOneMenues
User klicks the arrow on the field and opens the list of available values
he types in some characters and a result is returned (he finds various values with it)
when this happens, in the field, the first value from the result list is set automatically
when the user now selects a random entry, it is set and everything is fine
if the user instead decides he want's the default value back he could either click somewhere on the mask and the value is resetted -> works fine
or he could decide to click on the original value, which was set as default before, in this case the selected value doesn't change but stays the first result from the filter
when now saving the entity behind the form, the original default value is saved
I assume that this happens because when the first result from the filter is set, it just set in the frontend and not in the entity behind the form/ the backend.
Is this a known bug? Do you have any idea how to fix it with a reasonable amount of effort?
I will try to convince my customer to accept this behavior, but I think it's a bit strange, although I admit this is a scenario that's not likely to happen, often. Nevertheless, they found it =)
I am using Primefaces version 5.3.11 (elite version or something like that)

Prompt Page Requires Entry, Required set to No

I have a report that I developed that utilizes render variables as described here.
My prompt page has 3 check box groups filled with variables. My first box is set to required, as it contains key information that needs to be pulled. The 2nd and 3rd have optional values. When the report runs, it requires at least one of the options in box 2 and 3 to be selected.
Any idea?
If a parameter is referenced directly in a query data item, Cognos will force it's associated prompt to be required even if you set it to 'Optional'. If this is the issue, the solution is to use a prompt macro instead of the normal ?? syntax. You set a default value to pass if the prompt isn't satisfied. This allows the prompt to act like an optional prompt.
The minimum syntax is:
#prompt('prompt_name','string','')#
The third parameter is the default value. I have just used an empty string here but you could change this to whatever you want.

Why we need the optional parameter queryItem in Cognos promptmany

In this page:
http://publib.boulder.ibm.com/infocenter/c8bi/v8r4m0/index.jsp?topic=/com.ibm.swg.im.cognos.ug_fm.8.4.0.doc/ug_fm_id9744using_macro.html
We have:
QueryItem
This parameter is optional. The prompt engine can take advantage of the Prompt Info properties of the query item. Descriptive information can be shown, although the prompt value is a code.
I am having trouble understanding this part :
The prompt engine can take advantage of the Prompt Info properties of the query item. Descriptive information can be shown, although the prompt value is a code.
The promptmany syntax will ultimately generate a where clause. So how can it use the properties of the Query Item?
The prompt generation in the front end uses this parameter, not the query engine. This parameter makes no difference to the where clause. It is basically a hint to the prompt engine to tell the front end when it tries to automatically build a prompt.
I never fill in this parameter when I use prompt macros.

Problem getting value from "Checkbox group value prompt"

I've value prompt with ui:checkbox group
parameter: p_IsLastMonth
Name: Prompt_IsLastMonth
ItemCount: 1; UseValue:Yes, DisplayValue: LastMonth?
and two Date Prompts.
Whenever the checkbox is checked, the UseValue 'Yes' is passed to the parameter 'p_IsLastMonth'. But whenever the checkbox is left as it is, it results in an error.
Element 'selectOptions' is not valid for content model: 'All(style,defaultSelections,conditionalStyles,conditionalRender,XMLAttributes)'
I also tried giving a default value. But the default value has to be in the collection. But i want only one checkbox to be displayed.
I tried with html checkbox. But i'm not able to send the value 'either yes or no' to the parameter through javascript because however the finish button overrides the value.
Any help?
There are 2 ways you can use Parameters:
Evaluate Parameter value
Evaluate expression against Parameter value.
Either way your Parameter has some value, and no value is a kind of value. And you need to cater for empty value in some way. Eg:
If (?Parameter? <>'') then ([Selection Criteria] = 'True') Else (1=1)
OR
([Selection Criteria] = ?Parameter?) OR ?Parameter? = ''
There other ways of using parameters too. You should choose one that better suits situation and coding practices you are following.
You can use optional checkbox or text item. In Cognos 10 I get "Deselect" option under checkbox group.
Unfortunately, I don't think you can accomplish what you want to do with only one checkbox. The only way you can leave a value prompt unselected and still submit the prompt page is to make it "optional", which means no value will be passed. An option is to use two check boxes and make them "required" so that either "yes" or "no" must be selected (but this can result in both being selected, which isn't good), or preferably use a radio list with two values and "yes" as the default. There may be a javascript answer to this, but I try to avoid that as much as possible since it sometimes leaves you open to version upgrade issues. Using a radio list is your easiest option.
Well here is something that will work. I've done advanced scorecarding and dashboarding for years with Cognos and Javascript will work:
Create a real cognos parameter that has both choices you need Yes/No with no being the default. Put them perhaps in a html table somewhere off the main real-estate of the report/param canvas. Once you have the param configed you can make the size as small as you want and then make the table/checkbox invisible by turning the visible property to no. Basically the users won't see these params. Don't do box-type = non or the parameter won't even get generated. You could also wait on hidding them until we get step 3 working(Make it easier to troubleshoot).
Then create a HTML parameter that the user will use to interact with in the style that you want the users to see, and use javascript onchange events to manipulate the real hidden parameter by finding it via DOM model. You can make finding it easier by perhaps surrounding the hidden params with an HTML tag that has a unique name/ID and referencing the child items from there.
Since your cognos parameter is invisible you may not even need to use a check box... you could simply use a hidden text box that has stores Yes/No. This will make your coding simplified on the javascript until you get used to it.
Also When programming with javascript on Cognos i find using alert to echo a object's innerhtml to screen while troubleshooting to be very handy.
* One other less impressive approach if i remember right as well..
1. Leave your original cognos style checkbox alone and create another cognos prompt that is always defaulted to "-NO-" and hidden on the canvas.
2. In the expressions used to evaluate the parameters the would evaulate the concatenation values of both params and you could take logical action based on those values. So if the concatted results were "-No-" then you know the original paramater was not selected and to use "No". etc... I believe there could be a nuance to getting this to evaluate correctly in the expression editors but i have got this owrking before as well. * So i your case if the concatted results first 3 characters = "Yes" the "Yes" otherwise no.

Cognos Date Prompt Macro Error

This issues applies to Cognos Report Studio Versions 8.3 through 10.1.1.
In Report Studio 8.3, I've got this raw SQL query running against a MySQL 5.1 data source:
SELECT enc.encounterID, enc.date
FROM enc
WHERE enc.date between #prompt('textPromptStartDate')# AND #prompt('textPromptEndDate', 'date')#
This produces text prompts for the user. If the user enters dates into these prompts in the format of 'YYYY-MM-DD', e.g. '2010-01-15', the query works fine. But I want to replace the text prompts with proper Date prompts. When I try replacing the above prompts with
#prompt('datePromptStartDate', 'date') AND #prompt('datePromptEndDate', 'date')#
the query runs (no errors are generated), but I get an empty result set. I have a feeling I need to adjust the date format that the date prompt macro returns, but I'm stuck after many hours of experimentation as to how to debug this.
For dates, you need the single quotes around the value. I do this using the "sq" function:
#sq(prompt('DateParameterFromPromptPage', 'date'))#
You can create a prompt page with date prompt controls, and then bind them to the parameters in your prompt macros. I tested this out in 8.4 with MySQL 5.1 (ODBC) using the query you have above and it worked. I also had the same problem you experienced with no data being returned prior to creating a separate prompt page and binding the controls.
The steps you would take to do this are:
add a prompt page (if one doesn't exist) to your report
add 2 date prompt controls to the prompt page
in the "Parameter" property for the first date prompt, use: datePromptStartDate
in the "Parameter" property for the second date prompt, use: datePromptEndDate
When you execute the report, the new prompt page will replace the prompt page that is generated from the macro, and the parameters in the macros will be bound to the date controls.
Edit:
I forgot to add that the macros in your SQL should look like the following:
SELECT enc.encounterID, enc.date
FROM enc
WHERE enc.date between #prompt('textPromptStartDate')#
AND #prompt('textPromptEndDate')#
It is possible to create a prompt without a prompt page for the date prompts without using a prompt page. I ran into this exact problem as well on SQL Server until I ran a profile trace. The profile trace showed that Cognos wasn't passing quotes around the date value. I fixed the issue by passing the prompt as a string, replacing the default validation test string (testValue) with a real date, building the string in a variable, and then passing it to the actual query. Here's what I used to convert a date prompt into a normal DATE data type.
DECLARE #StartDate DATE = CONVERT(DATE, REPLACE(#prompt('StartDate')#, 'testValue', '1/1/2012'));

Resources