Pick up custom query string parameters?

(12 posts) (2 voices)

Tags:

  1. duane, Member

    Hi.

    I'd like to use some custom query string parameters that I can reference in the code, but which doesn't come up in the parameter list.

    For instance if I have three defined variables: InA, inB and inC and I want to add inD=123 to the URL as a query parameter but not to the function (or at least not show up to the user when show.parameters is active), how can I reference inD in the code? Or how could I make the inD parameter invisible and only available in the URL?

    Cheers,

    Duane

  2. myDBR Team, Key Master

    Duane,
    not sure if I understood your question.

    The parameters that show up as editable parameters to user are the 'u' and 'e'-parameters. To use parameters that are in the URL, but are not user editable are the protected ('p'). See the different parameters in documentation.

    If this does not answer your question, could you show example what is it you are trying to achieve.
    --
    myDBR Team

  3. duane, Member

    OK - let me try again :-)

    First, I'm not where p variables are used or if they are callable in the dbr function.

    I have a report with a number of user-configurable u variables and it also uses some automatic variables (e.g. inLogin). But to make the report as re-usable as possible, I also wish to include variables not exposed to the user. Normally this can be done by appending it to the URL as a query parameter (&myHiddenValues=1234)

    So a report with url https://mydomain/report.php?r=206&u4=A&u5=B&u6=C&u7=D&u8=E&u9=F&m=1&h=0123456789abcdef

    Makes all 'u' parameters visible to the user: none can be hidden so they can't be change via the interface

    The only way I currently know how to add a unlisted/hidden variable would be to append the url like:
    https://mydomain/report.php?r=206&u4=A&u5=B&u6=C&u7=D&u8=E&u9=F&m=1&h=0123456789abcdef&Z=4567

    Then in the report code I'd like to call it to use like
    sp_DBR_myfunction (inA, inB, inC, inD, inE, inF) BEGIN

    SELECT inA, inB, inC, inD, inE, inF, Z;

    END

    But I don't know how to access query variable 'Z' for the report to use it.

    Another option would be to make 'hidden'/'unlisted' a possibility for the 'u' variables, but that requires more coding on your end and I was trying to find a way to reference query variables without changes on your side.

    If there is a way to do this with 'p' variables then let me know how I'd call it in the 'myfunction' code.

    Does that clarify?

  4. myDBR Team, Key Master

    Duane,
    the first question is that what would create such an URL with extra parameters? myDBR has it's format for parameters it knowns and it knows how to handle them (u for user enterable, p for protected etc) and knows how to create the URLs.

    Secondly, even if you would introduce extra parameters (like z) and myDBR would somehow understand it (accessible inside the report and not showing it in parameters), that would still work just like the 'u'-parameter as nothing would prevent user just changing the parameter value in URL.

    Thirdly, in your example code you have the Z inside the procedure, but you are not passing in the value for it as parameter. How would the database engine recognize the value?

    So, to clarify:

    - What is the problem you are trying to solve?
    - Where does these extra parameter get their values from (who is generating the URL)
    - Why not use the 'p'-parameters as they do exactly what you are asking?

    --
    myDBR Team

  5. duane, Member

    > - What is the problem you are trying to solve?

    I'm trying to make a report using templates that when a url variable is set to 'email' excludes some text and includes other (into to the report not needed on the page) that can be used for both emails and as a page so I don't have to maintain two separate report codes and template codes. With a few IF statements I can include/exclude the necessary content.

    > - Where does these extra parameter get their values from (who is generating the URL)

    I provide it in the url. I know users could change it, but it isn't security related. This way I can provide a link to the page for viewing on a webpage and use the same link with a different parameter to send the main content via email.

    > - Why not use the 'p'-parameters as they do exactly what you are asking?

    Perhaps I can - I just tried:
    1) adding it to the url (&p2=abc+123) but it gave a "Report security hash does not match. Report execution aborted" error
    2) Once I got past that people, would I reference it in the function with 'p2' or with 'abc' to get the value?

  6. myDBR Team, Key Master

    When you say "I provide it in the url", what does it mean? Is it outside myDBR?

    Why not just use the 'p' parameter and let myDBR handle that for you. The 'p'-parameters are included in the hash calculation (the 'h'-parameter). If you simply add a 'p' parameter of your own, it will not be included in the hash calculation and you will get the report security notification.

    You can still use the same report as email and as normal report if you let myDBR to generate the URL.

    If you are fine for user changing the URL, you could even use the 'u'-parameter and just hide it when parameters are shown. The usage of the 'p'-parameter would still be the recommended choise.

    --
    myDBR Team

  7. duane, Member

    > When you say "I provide it in the url", what does it mean? Is it outside myDBR?

    No - within mydbr - but sometimes not through the linking functions as I can't always get them to behave as I want.

    > Why not just use the 'p' parameter and let myDBR handle that for you. The 'p'-parameters are included in the hash calculation (the 'h'-parameter).

    OK - how do I add this to a report call? The documentation mentions they can be used but not how. Any examples?

  8. myDBR Team, Key Master

    No - within mydbr - but sometimes not through the linking functions as I can't always get them to behave as I want.

    OK. Mabye this would be the best place to start.

    You should be able use linked reports and the linked reports will handle the parameter passing and hash calculation for you automatically. Can you show what is the problem you are facing with the linked reports?

    --
    myDBR Team

  9. duane, Member

    I'll raise the display issues with you another time as they are minor and separate from what I am working on now.

    > If you are fine for user changing the URL, you could even use the 'u'-parameter and just hide it when parameters are shown.

    If I'm to hide specific parameter rows, I'd need a class or id value in addition to the 'param_row' - right now there doesn't seem to be one for each row (e.g. row_u1) that I can hide with css.

    ..unless there is a way I can add a param_row class or id (I didn't find one in the documentation or settings).

  10. myDBR Team, Key Master

    If I'm to hide specific parameter rows, I'd need a class or id value in addition to the 'param_row' - right now there doesn't seem to be one for each row (e.g. row_u1) that I can hide with css.

    You can hide the rows with JavaScript in the report parameters.

    As for the other issue, If you open a support ticket / describe what you are trying to do in the forum, we'll help you out.
    --
    myDBR Team

  11. duane, Member

    > You can hide the rows with JavaScript in the report parameters.

    OK. I'll try that.

    A few suggestions to make it easier for people who aren't js developers (like me):

    1. Add an id to each parameter row so instead of <tr class="param_row"> it would be <tr class="param_row" id="row_u1"> (or something) - otherwise no-one can use css (easier than js) to custom style the row. Also adding this at the label level so that <td class="input_label" style=""> (why the empty style??) can become <td class="input_label" id="input_u1" style=""> would allow for more granular styling and js manipulation as needed.
    2. OR on the parameter options when editing the report add a section for 'custom class' and 'custom id' as the param_row and label level (you already have id=u1 at the input field level)

    Then people would be able to choose their method of maniputlation: css or js.

  12. myDBR Team, Key Master

    Styling of rows/individual items can be done with JS (you can use pure JavaScript or use jQuery).

    What kind of styling would you like to apply and into which elements? Just that we understand what is it that you are trying to achieve.

    Note that need for things like hiding rows are very rare. There is in almost all cases better way of doing things.

    We've added a rownum to parameter rows. Note that layout is diifferen in mobile view.
    --
    myDBR Team


Reply

You must log in to post.