Alpha Software Mobile Development Tools:   Alpha Anywhere    |   Alpha TransForm subscribe to our YouTube Channel  Follow Us on LinkedIn  Follow Us on Twitter  Follow Us on Facebook

Announcement

Collapse

The Alpha Software Forum Participation Guidelines

The Alpha Software Forum is a free forum created for Alpha Software Developer Community to ask for help, exchange ideas, and share solutions. Alpha Software strives to create an environment where all members of the community can feel safe to participate. In order to ensure the Alpha Software Forum is a place where all feel welcome, forum participants are expected to behave as follows:
  • Be professional in your conduct
  • Be kind to others
  • Be constructive when giving feedback
  • Be open to new ideas and suggestions
  • Stay on topic


Be sure all comments and threads you post are respectful. Posts that contain any of the following content will be considered a violation of your agreement as a member of the Alpha Software Forum Community and will be moderated:
  • Spam.
  • Vulgar language.
  • Quotes from private conversations without permission, including pricing and other sales related discussions.
  • Personal attacks, insults, or subtle put-downs.
  • Harassment, bullying, threatening, mocking, shaming, or deriding anyone.
  • Sexist, racist, homophobic, transphobic, ableist, or otherwise discriminatory jokes and language.
  • Sexually explicit or violent material, links, or language.
  • Pirated, hacked, or copyright-infringing material.
  • Encouraging of others to engage in the above behaviors.


If a thread or post is found to contain any of the content outlined above, a moderator may choose to take one of the following actions:
  • Remove the Post or Thread - the content is removed from the forum.
  • Place the User in Moderation - all posts and new threads must be approved by a moderator before they are posted.
  • Temporarily Ban the User - user is banned from forum for a period of time.
  • Permanently Ban the User - user is permanently banned from the forum.


Moderators may also rename posts and threads if they are too generic or do not property reflect the content.

Moderators may move threads if they have been posted in the incorrect forum.

Threads/Posts questioning specific moderator decisions or actions (such as "why was a user banned?") are not allowed and will be removed.

The owners of Alpha Software Corporation (Forum Owner) reserve the right to remove, edit, move, or close any thread for any reason; or ban any forum member without notice, reason, or explanation.

Community members are encouraged to click the "Report Post" icon in the lower left of a given post if they feel the post is in violation of the rules. This will alert the Moderators to take a look.

Alpha Software Corporation may amend the guidelines from time to time and may also vary the procedures it sets out where appropriate in a particular case. Your agreement to comply with the guidelines will be deemed agreement to any changes to it.



Bonus TIPS for Successful Posting

Try a Search First
It is highly recommended that a Search be done on your topic before posting, as many questions have been answered in prior posts. As with any search engine, the shorter the search term, the more "hits" will be returned, but the more specific the search term is, the greater the relevance of those "hits". Searching for "table" might well return every message on the board while "tablesum" would greatly restrict the number of messages returned.

When you do post
First, make sure you are posting your question in the correct forum. For example, if you post an issue regarding Desktop applications on the Mobile & Browser Applications board , not only will your question not be seen by the appropriate audience, it may also be removed or relocated.

The more detail you provide about your problem or question, the more likely someone is to understand your request and be able to help. A sample database with a minimum of records (and its support files, zipped together) will make it much easier to diagnose issues with your application. Screen shots of error messages are especially helpful.

When explaining how to reproduce your problem, please be as detailed as possible. Describe every step, click-by-click and keypress-by-keypress. Otherwise when others try to duplicate your problem, they may do something slightly different and end up with different results.

A note about attachments
You may only attach one file to each message. Attachment file size is limited to 2MB. If you need to include several files, you may do so by zipping them into a single archive.

If you forgot to attach your files to your post, please do NOT create a new thread. Instead, reply to your original message and attach the file there.

When attaching screen shots, it is best to attach an image file (.BMP, .JPG, .GIF, .PNG, etc.) or a zip file of several images, as opposed to a Word document containing the screen shots. Because Word documents are prone to viruses, many message board users will not open your Word file, therefore limiting their ability to help you.

Similarly, if you are uploading a zipped archive, you should simply create a .ZIP file and not a self-extracting .EXE as many users will not run your EXE file.
See more
See less

How to getKey (Primary Key) in XBASIC

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    How to getKey (Primary Key) in XBASIC

    Good Morning!

    I set the PrimaryKey of my Dialog Controls in JavaScript with
    Code:
    //Set the primary key for the INVOICE_ITEMS alias in row 3 of the Repeating Section to ['23','11'].;
    {dialog.Object}.setKey('INVOICE_ITEMS',['23','11'],3);
    To retrieve the Key in JS I would do
    Code:
    //Get the primary key for the INVOICE_ITEMS alias in row 3 of the Repeating Section.;
    {dialog.Object}.getKey('INVOICE_ITEMS',3);
    But how can I retrieve the stored Primary Key from XBASIC ?
    I could not find any etry for "getKey" in this Forum.
    Thank you!

    #2
    Re: How to getKey (Primary Key) in XBASIC

    Can't find setKey or getKey... Where are these... I can't find any mention of them anywhere. What version are they in?

    Comment


      #3
      Re: How to getKey (Primary Key) in XBASIC

      Hi David,

      I have the Build 2353_3857 (Prerelease) and the method could be found beneath the Javascript functions under insert.... insert method. But there is now a general update from 16 JAN 2012 09:31 Build 2365_3859 should be in there as well I am just downloading it.

      Comment


        #4
        Re: How to getKey (Primary Key) in XBASIC

        For desktop here are a few places to start;-

        .INDEX_PRIMARY_GET()
        .INDEX_PRIMARY_PUT()
        .INDEX_NAME_GET()
        .INDEX_POINTER()
        <INDEX> as P = <TBL>.QUERY_CREATE( [ .Options [, .Filter [, .Order ]]] )

        dim tbl as P
        tbl = table.open("customer")
        i = tbl.order("lastname")
        i.type_get() ⇒ 2.00000 'indicates that Alpha Five selected an index

        Comment


          #5
          Re: How to getKey (Primary Key) in XBASIC

          Thank you Ray,

          but as we are in the web Application part of the Forum I am looking for the Web App solution. Thanks anywaya, could have been similar.

          Comment


            #6
            Re: How to getKey (Primary Key) in XBASIC

            yeh I skipped the part where I should first read the question properly

            Comment


              #7
              Re: How to getKey (Primary Key) in XBASIC

              the .getKey() method is a method of the dialog object to read the value of the key from the javascript object that is part of the dialog object.
              so, it is a Javascript method that executes on the client.

              xbasic, as you know, executes on the server. it executes in response to an ajax callback.
              when an ajax callback happens the e object that is passed to your xbasic function has all of the keys in it.

              so, if you run your dialog in working preview and you put debug(1) into your xbasic function and then examine the

              e._state.keys

              object, you will see the primary keys for every table that the dialog is bound to.

              Comment


                #8
                Re: How to getKey (Primary Key) in XBASIC

                And thank you once again! That was just what I have been looking for. If its not in the wiki and no one else knows it, you always do! Thank you for that.

                Comment


                  #9
                  Re: How to getKey (Primary Key) in XBASIC

                  probably the reason that it is not in the wiki is that it is not a generic feature of the dialog.

                  the primary keys are only in the e._state object only by convention because the server side action script that loads a record into the Dialog puts them there.
                  if you write you own event handler to load data into the dialog, then it would be your own responsibility to choose where to store the primary key.

                  if, when you use server side action scripting to load a dialog with data from a table, you turned on the option to show debugging information, you would see that the javascript response that is sent to the client includes code to store the key in the state object.

                  the state object is sent back to the server as part of every callback.

                  the {dialog.object}.setStateInfo() method - which is the generic way of storing state information in the Dialog, is documented in the genie that allows you to insert a method when you are writing a javascript function.


                  http://wiki.alphasoftware.com/Grid%2...t=setstateinfo

                  Comment


                    #10
                    Re: How to getKey (Primary Key) in XBASIC

                    Thank you for the explanation!

                    Comment


                      #11
                      Re: How to getKey (Primary Key) in XBASIC

                      Hi Selwyn,

                      I am having trouble overwriting my key values or rather retrieving the new key value in XBasic - in JavaScript it works fine with getKey().
                      To show you what I mean I created a sample component: Test_populateRS_20120131_gamma.zip
                      Following situation:
                      - I have a Dialog with a repeating section.
                      - When the RS is populated the initial Keys are set, in this Example the first column (project) the Keys are set to "0" for the initial 8 Rows.
                      - Now click on the "and populate again with more rows" button. This lets the RS expand to 10 rows and populates the first column anew, setting the key values (PID_1 to PID10) to the number the column is now displaying. For PID_1 in this case it is "12".
                      - Now enter anything into the repeating section to make it dirty.
                      - Click on Submit.
                      - In the afterDialogValidate event I try to retrieve the Keys, but having a look at e._state.keys (see picture) we can see that only the keys of the 2 new rows (PID_9 and PID_10) have been set and all the other rows which previously have been set to "0" are still "0" although they have been processed in the same way and at the same time the new rows have.

                      2012-01-31_statekeysNotSet_gamma.png

                      Why can I not see the new key value in e._state.keys but can retrieve it in JavaScript with the getKey() function? Is there some refresh I am missing?
                      Thank you for your help!

                      Comment


                        #12
                        Re: How to getKey (Primary Key) in XBASIC

                        Hi,
                        does anybody have a solution for the Problem in post #11?
                        Thank you!

                        Comment


                          #13
                          Re: How to getKey (Primary Key) in XBASIC

                          i tried to look at your example, but gave up because it was too complex. it would have taken too long to figure our what you are trying to do.
                          can you try to come up with a much simpler example?

                          Comment


                            #14
                            Re: How to getKey (Primary Key) in XBASIC

                            Hi Selwyn,

                            next try. here is a simpler component (I can�t make it simpler to show what I mean).
                            Test_setKeys_gamma_20120207.zip
                            1. Open the dialog in the Working Preview
                            2. The dialog initializes and populates the first column and the currently existing two rows with "0" and sets the keys for this field to "0" like
                            Code:
                            {dialog.Object}.setKey('PId_1', 0);
                            3. Click on "and populate again with more rows". This will extend the repeating section to 5 rows and set a new Primary key like
                            Code:
                            {dialog.Object}.setKey('PId_1', 1);
                            4. Write anything in one of the Textbox1 fields to make the grid dirty.
                            5. Click on submit. you will stop at the breakpoint in the afterDialogValidate event.

                            6. enter
                            Code:
                            e._state.keys
                            as an expression and see A5_e_State_keys_20120207.png as you can see the key values of the initial two rows have not changed (still "0").

                            The question is: Why can I not overwrite the key? I really need to.
                            Thank you for your help!
                            Attached Files

                            Comment


                              #15
                              Re: How to getKey (Primary Key) in XBASIC

                              This video explains your issue in a much simpler form.
                              We have made a change to the order in which the dialog emits javascript commands on an ajax callback, so your test case will now work (you will need tomorrow morning's pre-release build)
                              However, the video also discusses a much simpler approach to your problem


                              http://screencast.com/t/EyLPsgrKw

                              Comment

                              Working...
                              X