cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
3207
Views
0
Helpful
11
Replies

CUIC supports two automatic parameters?

ckulisz01
Level 1
Level 1

Based on the documentation for SP report Definitions I'm trying to link to Current User and Current User Time Zone. I cannot find any information on how to connect to those 2 Parameters. I have tried renaming parameters to 'Current User'  and 'CurrentUser' and no luck.

Any help would be appreciated.

Create a Report Definition of Type Stored Procedure

Step 11  In the Value column, enter a value for each parameter which will be substituted for the parameter variable in the query.

CUIC supports two automatic parameters Current Username and Current User Time zone which are not mandatory. While defining a Report Definition if the user selects any of the automatic parameter, then the value is replaced with the logged in Username or User timezone respectively.

1 Accepted Solution

Accepted Solutions

The version that you're using is a developer build from 11.5(1) release. The feature was probably only partially implemented. Please use an FCS box - the version is 11.5.1.10000-86.

View solution in original post

11 Replies 11

ckulisz01
Level 1
Level 1

The 2 Automatic Parameters "Current User" and "Current User Time Zone" are not usable in CUIC due to a major bug.

The bug stems from the fact that CUIC makes the SP call with Positional passing of the data

"exec sp_Mysp 'Value1','Value2' "

rather then Referential passing of the Data.

"exec sp_Mysp @Param1='Value1',@Param2='Value2' "

This Bug is aggravated with the way Automatic Parameters are assigned.

1 ) Report Definition  -> Data Source -> Create Parameters

The listing of the parameters are organized in Alphabetical Order

2) Report Definition -> Parameters

The parameters are organized in the way they map to the SP and not Alphabetical.

The assignment of the Automatic Parameters is done on the Create Parameters Screen and take the Position # based on the Alphabetical Listing.

Ex.

(1) @CU

(2) @CUTimeZone

(3) @DateFrom

(4) @DateTo

(5) @Filter1

(6) @Filter2

SP is created as

(1) @DateFrom

(2) @DateTo

(3) @Filter1

(4) @Filter2

(5) @CUTimeZone

(6) @CU

When the call will be placed the mapping will be as follows

call SP_MySP  'CurrentUser','TimeZone','Filter1',null,null,null

call SP_MySP  @DateFrom,@DateTo,@Filter1,@Filter2,@CUTimeZone,@CU

causing SQL error and lots of issues.

Ways to Fix.

1) let the Automatic Parameter Assignment happen on the Parameter Screen so that it could obtain the proper sequence.

2) Change the Call to Pass In referential Parameter Name Such as

call SP_MySP @Cu= 'CurrentUser',@CUTimeZone='TimeZone',@Filter1='Filter1',@Filter2=null,@FromDate='2016-10-01 12:30:00',@ToDate='2016-10-05 12:30:00'admin!@@@@@@@

In the parameters tab, it allows you to re-order the parameters. Does this help?

parameters.png

That is not useful in any way at all as you lose Ordering sequence from the actual SP.

You would have to rewrite the SP and put the Parameters in Alphabetical order.

That is a lot of work and in some cases not doable as you would need to create new SP's since old reports might use the same SP's.

In your scenario Reordering on the Parameter page would create the same problem but a different sequence. The parameter page has Physical sequence but once you change the order on the Parameter page you create the same problem.

So in effect parameter page is also broken. As trying to Sequence the parameter for easy presentation to the user causes you to lose positional reference to the correct Parameter location. This causes the same issue.

This all stems from the fact that you are using positional reference rather then Parameter reference.

Please Fix this Bug

to see this effect Please use your case.

@param2,@Param1,@param3 

SP has been created with sequence @Param1,@Param2,@Param3   what will happen is

@Param2 - > @Param1

@Param1 -> @Param2

@Param3 - > @Param3

If Param1 = Agents  and Param2 = Teams ... You see the problem ?

compound the problem .. Make @Param2 = Datetime field and you will have a SQL conversion error as it tried to convert

'Agent Name' into Datetime.

to see this effect Please use your case.

@param2,@Param1,@param3

SP has been created with sequence @Param1,@Param2,@Param3   what will happen is

@Param2 - > @Param1

@Param1 -> @Param2

@Param3 - > @Param3

If Param1 = Agents  and Param2 = Teams ... You see the problem ?

compound the problem .. Make @Param2 = Datetime field and you will have a SQL conversion error as it tried to convert

'Agent Name' into Datetime.

So, with the order I have in my image, the SP's 1st parameter will get the value of param2 in the RD (report definition), 2nd parameter will get the value of param1 in the RD and so on. And it will result in the error you mentioned.

But you can always re-order the RD's parameters to match what you have in the Stored Proc. So I am not seeing where the issues is.

If you have an example stored procedure for which this is not working, please give me the definition of it and I will try to see how it can be resolved. May be I'm missing something in this form of communication.

GO

CREATE procedure [dbo].[Test222]

@From datetime = null,

@To Datetime = null,

@DayWeek nvarchar(200) = null,

@TimeZone nvarchar(100) = null

as

select @From as FromDate,@to as ToDate,@DayWeek as dw ,@TimeZone TZ

GO

Create Report Definition.

CUIC_test1.PNG

Configure the Parameters

CUIC_test2.PNG

Create report for the report definition.

Select the parameters

CUIC_test3.PNG

Expected results

DW = "Mon:Tue:Wed:Thu:Fri", TZ="UTC"  , From="10/12/16". To="10/12/16"

Real Results in error.

{call [Test222]('2016-10-12 00:00:00','2016-10-12 23:59:59','UTC','TEST')}

CUIC_test4.PNG

Per your suggestion reordering Parameters in Parameters tab.

CUIC_test5.PNG

Run Report same parameters.

{call [Test222]('UTC','2016-10-12 00:00:00','TEST','2016-10-12 23:59:59')}

Report execution fails SQL error

Msg 8114, Level 16, State 5, Procedure Test222, Line 0

Error converting data type varchar to datetime.

CUIC_test6.PNG

Now do you understand what I have been trying to explain?

Also Anonymous Block does not support Automatic parameters "Current User Timezone and Current Username"

So I cannot use Anonymous block as the mapping of the Parameters to call the SP.

declare

@From Datetime =:From,

@To datetime =:To,

@DayOfWeek nvarchar(200) =:DayWeek,

@TimeZone nvarchar(100) =:TimeZone

exec Test222 @From,@To,@DayOfWeek,@TimeZone

Let me test this out and get back to you.

Also Please explain how it was created as an automatic parameter and yet it's prompting me to enter a value.

If I make it null able then it gives me Null. So it gets overwritten. For an Automatic Parameter I should not be getting any prompt at all since the system will be passing in the value.

Here are the steps I used and I didn't face any issues for the same stored procedure:

(By the way, what version of CUIC are you using? I am looking at 11.5(1) - yours look like 11.0(1) or older).

01 - Create the fields:

01-create-fields.png

02 - Fields List (second tab on Report Definitions):

02-fields-list.png

03 - Parameters List (I made sure that TimeZone is the last parameter - because the SP has it as the last one):

03-params-list.png

04 - Created a report and then ran it - Choosing Filters (Notice the timezone being automatically picked):

04-choose-filter.png

05 - Show SQL on the executed report (TimeZone is the last parameter):

05-show-sql.png

So you are saying the issue has been fixed in 11.5  the current version i'm running is

Version11.0(1) build 1 (11_5_0_99000_546)

Also looking at your test case I have a slight worry as the Date range selected is "Today"

and the dates passed in are

From :'2016-10-17 00:00:00',

To: '2016-10-17 00:00:00'


Should the date range not be passed in as

From :'2016-10-17 00:00:00',

To: '2016-10-17 23:59:59' 

Your day Range is pretty short as only records happening  between '2016-10-17 00:00:00' and '2016-10-17 00:00:00'

which means not much.

Also is your TimeZone on the Datasource different or the same as your user Timezone as I do not see any offset.

Please validate if this is a bug.

The version that you're using is a developer build from 11.5(1) release. The feature was probably only partially implemented. Please use an FCS box - the version is 11.5.1.10000-86.

Yes issue has been fixed in 11.5 or later releases!