Hell Team,
How to assign the user name using to a parameter using Java script so that that parameter can be used in calculations.
Thanks...
There's already a parameter for username. You don't need to use anything to assign it to a parameter.
#sq($account.personalInfo.userName)#
Thanks for your response.
We are using (#sq($account.personalInfo.userName). But need Java script code to assign it to a parameter.
Hi Raja,
I see your other post about this parameter and substring() with MDX. I assume you're looking to pass the substring value as a parameter, which makes sense to me now.
There are a couple of solutions for this. A good starting point that outlines these solutions is the following page:
http://cognosknowhow.blogspot.ca/2013/04/how-to-dynamically-set-up-default-value.html?cm_mc_uid=44957120532814660888625&cm_mc_sid_50200000=1472480762
Once you start with a solution, let me know if you run into issues with the javascript and I can help out.
Thanks Jai,
You are correct my posts are related. I will try the solution that you have recommended.
Have fun,
Raj
Hello Jay,
I am stuck at passing a macro value, user ID, to a variable in Javascript that is meant to pass value to a value prompt?
Please help
Thanks,
Raj
Quote from: raja_krp on 29 Aug 2016 07:50:30 PM
Hello Jay,
I am stuck at passing a macro value, user ID, to a variable in Javascript that is meant to pass value to a value prompt?
Please help
Thanks,
Raj
I wrote and tested this right now using a text box prompt. The
Name property of the prompt is 'JayPrompt'.
<script type= "text/javascript">
var oCR = cognos.Report.getReport("_THIS_");
var oP = oCR.prompt. getControlByName( 'JayPrompt' );
oValues = [{'use': 'Jay', 'display': 'Jay'}];
oP.addValues( oValues );
</script>
Take a look in my recent post history for JavaScript posts. I recently helped someone get a value from a hidden DIV on the page to use in JavaScript. You will need to do the same to get the username and use it in the
oValues JavaScript variable above.
Note: Tested in 10.1.1. As always, exercise caution with use of JavaScript, as upgraded reports are not guaranteed to work in future releases of Cognos (Prompt API could change).
Jay
You didn't state a business requirement, you stated a technical solution. Step back for a minute.
Are you sure you need to set the value of a parameter? How about just using the results from the macro expression directly in a filter or case statement, as if it is the parameter?
Yes !
@ raja_krp - What's the purpose of the parameter? To set security in the report?
Quote from: cognostechie on 30 Aug 2016 12:33:11 PM
Yes !
@ raja_krp - What's the purpose of the parameter? To set security in the report?
The issue is in his post history here:
http://www.cognoise.com/index.php/topic,31415.msg102353.html#msg102353
In that case, I don't want to comment on this as I do not support these kind of workarounds. The right way to do it would be to get the proper name in
the cube itself. Hardcoding the 'M' in the report could result in wrong data if the user name changes later on.
@Jay & Raja
I have also received a similar kind of requirement.
Let me provide a brief description of my requirement.
I have got a report where there is Prompt named User Name,Client wants that whoever logs in and try to execute that report his Username should automatically gets captured in that Username Prompt.
Thereafter the report gets filtered and shows the record related to that user.
I would appreciate if either of you or anybody can provide me the step by step details on what needs to be done to meet this requirement.
Gracias
Vinny
Quote from: CogDevloper on 30 Aug 2016 04:02:24 PM
@Jay & Raja
I have also received a similar kind of requirement.
Let me provide a brief description of my requirement.
I have got a report where there is Prompt named User Name,Client wants that whoever logs in and try to execute that report his Username should automatically gets captured in that Username Prompt.
Thereafter the report gets filtered and shows the record related to that user.
I would appreciate if either of you or anybody can provide me the step by step details on what needs to be done to meet this requirement.
Gracias
Vinny
Hi Vinny, it's best to start your own thread. You'll need to use a Macro Prompt with a default value of the username parameter. Set the filter to optional.