This discussion is archived
1 2 Previous Next 29 Replies Latest reply: Aug 16, 2013 10:28 AM by ScriptMan Go to original post RSS
  • 15. Re: Assign results column to Drop Down Value List
    DougP Explorer
    Currently Being Moderated

    How about somebody provides you with a response to your actual question?  From what I understand, while you may be using the dropdown to filter something, what you are looking for right now is a way to use the data in a column as a source to populate the dropdown to begin with.  You can use this:

     

    var oRslt = ActiveDocument.Sections["Results"];

    var oCol = oRslt.Columns["Column"];

    var oDrp = ActiveDocument.Sections["Dashboard"].Shapes["DropDown"];

    var arr = new Array();

     

    for (var i = 1; i <= oRslt.RowCount; i++) {

        arr.push(oCol.GetCell(i));

    }

     

    arr.sort();

     

    for (var i = 1; i < arr.length; i++) {

        if (arr[i - 1] != arr[i]) oDrp.add(arr[i - 1]);

    }

    if (arr[i - 1] != arr[i]) oDrp.add(arr[i]);

     

    Or, if you are using IRFramework, use this:

     

    ActiveDocument.Sections["Dashboard"].Shapes["DropDown"].setList(ActiveDocument.Sections["Results"].Columns["Column"]);

     

    The code should be put in whatever event is appropriate to load your dropdown.  If you only do it each time the document is loaded, put it in OnStartup.

     

    DougP corrected code snippet.

  • 16. Re: Assign results column to Drop Down Value List
    ScriptMan Newbie
    Currently Being Moderated


    Finally, that is precisely what I was looking for ...  Thank you!  I will run this and let you know the result.  Thank you for taking the time to respond.

  • 17. Re: Assign results column to Drop Down Value List
    ScriptMan Newbie
    Currently Being Moderated

    Question on the code...I see oDrp in the variable declaration section, but I don't see it in the code procedures.  Is this an error.


  • 18. Re: Assign results column to Drop Down Value List
    DougP Explorer
    Currently Being Moderated

    Yes, see my revision to the post.

  • 19. Re: Assign results column to Drop Down Value List
    hyperion_mike91 Newbie
    Currently Being Moderated

    I would suggest inserting the script in OnStartup(), which executes when the BQY file is opened.

  • 20. Re: Assign results column to Drop Down Value List
    ScriptMan Newbie
    Currently Being Moderated

    Do you have this exact procedure working in one of your systems?  Unfortunately, I cannot get it to work.

  • 21. Re: Assign results column to Drop Down Value List
    WVanSluys Pro
    Currently Being Moderated

    Are you able to get the code to work as provided?

    where did you put the code?

    what is / is not happening?

    are there error messages in the Console Window?  go to the menubar. select View, select Console Window - this is your best friend when learning JavaScript

     

    Try dispersing

    Console.Writeln(1)

    or

    Console.Writeln("various messages")

    throughout your code to see where the last message appears.

     

    if you are trying the OnStartup event in the Document Scripts you have to invoke that event either by closing and reopening the BQY so that event is triggered or you can put a button ont he dashboard that you can assign the method OnStartup() to "Fake" the on startup and execute the script in that event.

  • 22. Re: Assign results column to Drop Down Value List
    ScriptMan Newbie
    Currently Being Moderated

    I'm usiong it in StartUp and I have ben closing and opening the .bqy file.  The syntax checks fine.  What's not happening is the drop down box simply isn't populating.  There's nothing in it, no error messages.

  • 23. Re: Assign results column to Drop Down Value List
    WVanSluys Pro
    Currently Being Moderated

    have you tried the code with a Command Button first?  Did it work?

     

    if you used the code above there are two small errors in it

     

    for (var i = 1; i < arr.length; i++) {

        if (arr[i - 1] != arr[i]) oDrp.add(arr[i - 1]);

    }

    if (arr[i - 1] != arr[i]) oDrp.add(arr[i]);

     

    should be

     

    for (var i = 1; i < arr.length; i++) {

        if (arr[i - 1] != arr[i]) oDrp.Add(arr[i - 1]);

    }

    if (arr[i - 1] != arr[i]) oDrp.Add(arr[i]);

     

    Please paste your code here. 

  • 24. Re: Assign results column to Drop Down Value List
    DougP Explorer
    Currently Being Moderated

    Yes, please post your code.  When you say "no error messages," the question arises:  Why haven't you added some logging to your code?  It sounds like you are not performing any troubleshooting.  You seem to be asking others to do all of the work for you.

  • 25. Re: Assign results column to Drop Down Value List
    ScriptMan Newbie
    Currently Being Moderated

    Mr Van Sluys ....  It is working !  This is totally working as intended.  I can't thank you enough.  You have been extremely helpful and assisted in completing a vital component to my system.  I am very appreciative !

  • 26. Re: Assign results column to Drop Down Value List
    ScriptMan Newbie
    Currently Being Moderated

    Mr DougP.  You may be confusing laziness with novice.  I'm a seasoned database developer but one whose expertise lies in VBA.  I am brand new to the JavaScript world and eager to learn from others willing to share their knowledge.  I would take an Oracle Course in JavaScript event coding is they offered one.  They don't.  But thank you for helping.

  • 27. Re: Assign results column to Drop Down Value List
    DougP Explorer
    Currently Being Moderated

    As Mr. WVanSluys said:

     

    Try dispersing

    Console.Writeln(1)

    or

    Console.Writeln("various messages")

    throughout your code to see where the last message appears.

     

    There's no indication that you did that.

     

    If you're seriously interested in learning scripting this tool and like to learn by example, there are examples out there.  I downloaded examples from ITToolbox a while ago.  I don't remember where to find them, if they even exist.  (ITToolbox overhauled the site a couple years ago.)  If you search SourceForge for IRFramework you'll find a library of object methods specifically for Interactive Reporting.  Studying the portions of the library that are specific to the IR object model (the last 60% of the code) should help you gain an understanding of scripting in IR.

     

    Not that points make me any money, but since you gave them -- you have an interesting way of awarding them.

  • 28. Re: Assign results column to Drop Down Value List
    WVanSluys Pro
    Currently Being Moderated

    You are welcome.  DougP provided the code and deserves that credit.

     

    If you review my response to many posts on this forum you will notice I try not to provide code when someone asks "tell me how to ________"

     

    I will most often refer people to the Documentation, the OnLine Help and the Samples that come with the Desktop Client Install.

     

    Many of us on the forums who have years of experience in any of the Oracle products are more than happy to Help out, but too often there are posts that do not indicate the person has even tried to work through the issue.  That is why I ask people to post their code rather than just their business requirements.

     

    so my unsolicited advice is:

    1) Use the Object Tree in the Script Editor.  If unsure about Object/Collection/Method/Property click on it in the Tree and Click the Help in lower left corner.

    2) Review the documentation

    3) Liberally use the Console.Writeln() and put it all over your code.  Before For Loops, inside For Loops, inside If/Else .  if you want to use Debug approach you can create a Boolean Global Variable in your Startup Script and flip to true for debugging/development and then false for production deployment. and then use a condition check for your ConsoleWrite().

       for example:

       if(gDebug == true) Console.Writeln("message here")

     

     

     

    Good Luck

     

    -w

  • 29. Re: Assign results column to Drop Down Value List
    ScriptMan Newbie
    Currently Being Moderated

    Thanks to both of you. Sincerely.

     


1 2 Previous Next

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points