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

List Control selected record's primary key - Insert New Record to other table.

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

    List Control selected record's primary key - Insert New Record to other table.

    Hi,

    I'm very new to Alpha and programming for that matter. Tried to get started two other times since 2005 but now it might stick as I am home quite a bit after a car accident.
    I'm currently an IT manager and I do have some basic knowledge of VB, Powershel, MS Access and SQL.
    I'm playing around with some data and following some of the videos I've seen but I've come across a stumbling block.

    First of all I have two tables in SQL (express). Customer and Booking. Both tables have auto-increment Primary Key fields.

    I have a UX with a List Control displaying the data from the Customer table. On the list control I have a button called "New Booking".

    The goal of the New Booking button is to take the PrimaryKey from the selected row of the list control, add a new record to the Booking table with the Customer PrimaryKey and then return the new PrimaryKey from the Booking table.

    Second goal is to open up a new UX for the new Booking with the Customer Name and allow the user to enter in the Date and Time of the booking.

    I have created an AJAX Callback on the New Booking button and assumed that if I checked "Submit Data from List Controls" I would get the data from the selected record in JSON. That doesn't seem to be the case as I've used the Xbasic debugger and there is nothing in there.

    Suggestions, help, guidance or a slap in the head would be greatly appreciated.

    Thanks
    Rob

    #2
    Rob,
    You are on track, but I would submit the data from the selected record in the callback (in blue) so it gets passed into Xbasic. Here's an example of that:

    var lObj = {Dialog.object}.getControl('list1');
    var _d = lObj._data;
    var len = _d.length;
    var arr = [];
    for (i=0;i<len;i++){
    arr.push(_d[i].Id);
    }
    {dialog.Object}.ajaxCallback('','','updateCustomerNumber','', "_idList="+arr);
    While this may seem overwhelming, what it is doing is going through the list and getting the ID numbers, putting them into an array, then sending that array to the Xbasic AJAX callback.
    The array is available in the Xbasic function as e._idList

    Using this method, you can send the appropriate value(s) to a stored procedure which creates the record in the Booking table, and returns the new Primary Key from the Booking table.

    The Primary key that is returned can then be placed in a new UX (or better yet, a different PanelCard on the same UX) with the info you want. Hope that helps.
    Jay
    Jay Talbott
    Lexington, KY

    Comment


      #3
      Thanks so much for the response Jay. Yes a little overwhelming indeed. I was doing quite a bit between documentation, videos, old forum questions and google until now.

      So if I understand this correctly your code goes behind the button on the record on this list control.

      Now the last line
      {dialog.object}.ajaxCallback(",",'updateCustomerNumber',","_idList="+arr);
      I assume this takes the place of the Action Javascript for the Ajax Callback?

      As far as the stored procedure... am I better off using that then creating the Insert Record in Xbasic?

      Oh and also.... 'updateCustomerNumber' is my Xbasic function?

      Rob

      Last edited by rgibson; 09-13-2020, 01:43 PM.

      Comment


        #4
        Rob,
        Technically, this :
        {dialog.object}.ajaxCallback(",",'updateCustomerNumber',","_idList="+arr);
        is the AJAX callback, just in javascript form. (If you were to take your action javascript and convert it to text, this is pretty much what you would see, with a little more text added.)
        You can insert the record either way, Xbasic or a Stored Procedure. Xbasic has a function to get the last autoincrement number from a table. Here's one way to do it:

        https://documentation.alphasoftware....nt%20Field.xml

        In place of the array in my first example, you will want to replace the array with the primary key of the customer table.

        Let us know how you make out.
        Jay
        Jay Talbott
        Lexington, KY

        Comment


          #5
          I don't understand what you are doing, is this the scenario - you have say a Hotel on your books and someone wants to book accommodation, you want to click on the Hotel in the List Control (select the Hotel). Then enter the new booking details in the say bookings calendar in another List Control, for the selected Hotel, is that right?
          Insanity: doing the same thing over and over again and expecting different results.
          Albert Einstein, (attributed)
          US (German-born) physicist (1879 - 1955)

          Comment


            #6
            Hi Pete, that's for the reply. I have benefited from some of your replies to other questions.

            The full explanation...

            This is a boarding kennel my wife owns on our property. Here usual booking process is... she searches her list of customers' owners, picks the right one then picks the animals names (usually they are all coming but occasionally not). Then fills out the details like In and Out Date, pickup and drop off time, if one or more will be getting bath and nails done while they're here, if any of them need extra walks, etc.

            Any suggestions are welcome. As I've stated I'm new to this.

            Thanks
            Rob

            Comment


              #7
              Gee the dogs get it good, I don't think I've ever had that stuff done. Anyhow I'll look at it and get back to you - its not an issue.
              Pete
              Insanity: doing the same thing over and over again and expecting different results.
              Albert Einstein, (attributed)
              US (German-born) physicist (1879 - 1955)

              Comment


                #8
                Originally posted by peteconway View Post
                Gee the dogs get it good, I don't think I've ever had that stuff done. Anyhow I'll look at it and get back to you - its not an issue.
                Pete
                We have a dog kennel out our way that has televisions in each room playing all day. It's crazy what some people will spend on their dogs.

                Comment


                  #9
                  Insanity: doing the same thing over and over again and expecting different results.
                  Albert Einstein, (attributed)
                  US (German-born) physicist (1879 - 1955)

                  Comment


                    #10
                    Well I got the first part done and I'm pretty happy.

                    First the AJAX Callback

                    [QUOTE]{dialog.object}.ajaxCallback('','','createNewBoard','', "_currentID="+currentID);/QUOTE]


                    Then the Xbasic.

                    2020-09-14_23-02-45.png


                    Learned a lot from this and feeling pretty accomplished.

                    Pete, if you have another way of doing this please let me know. I'll keep playing with this for now.
                    Attached Files

                    Comment


                      #11
                      Nice work. Thanks for sharing.
                      Al Buchholz
                      Bookwood Systems, LTD
                      Weekly QReportBuilder Webinars Thursday 1 pm CST

                      Occam's Razor - KISS
                      Normalize till it hurts - De-normalize till it works.
                      Advice offered and questions asked in the spirit of learning how to fish is better than someone giving you a fish.
                      When we triage a problem it is much easier to read sample systems than to read a mind.
                      "Make it as simple as possible, but not simpler."
                      Albert Einstein

                      http://www.iadn.com/images/media/iadn_member.png

                      Comment

                      Working...
                      X