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

Primary key value when using Dialog to insert new record

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

    Primary key value when using Dialog to insert new record

    Hi
    I am using a dialog component to insert and edit rows in a grid. Backend DB is Sql Server. In this specific table, i have a primary key set as identity, auto-increment.
    When inserting a new record, is there a way to show the user what value has been generated by SQL ? I would like to just show an OrderID field with either the value of the OrderID we are editing or the new OrderID being generated in case of insert.

    Thanks
    Jaime

    #2
    Re: Primary key value when using Dialog to insert new record

    bump!
    (been bitten by this one in a different scenario) :-(

    Comment


      #3
      Re: Primary key value when using Dialog to insert new record

      You should be able to see the value of every field in an existing record. You cannot see the value of the primary key until the record is saved. When you save the record, if you stay in the dialog the primary key value will show after record is saved. Maybe I am misunderstanding your question?

      Comment


        #4
        Re: Primary key value when using Dialog to insert new record

        Thank you for your help.
        Well, in my current scenario, in my dialog, i run a submit() then an action script to send the email with the newly created reservation.
        I set the subject to "Thank you for your order, number {OrderID}" ( this is built using the genie when picking up a field ), and in the mail i do not see the newly generated number. I also do not see that number when staying in the dialog...Is there some type of refresh i have to manually run after submitting?

        Comment


          #5
          Re: Primary key value when using Dialog to insert new record

          What type of control is OrderID? Is it set as Updateable?

          Comment


            #6
            Re: Primary key value when using Dialog to insert new record

            OrderID is numeric, set as entity with auto-increment, and set as updateable. It is set as Primary key in the dialog . The only 'abnormal' issue here is that i set the control to disabled and invisible ( 1=2 in both show/hide and enable properties )
            I just saw in another thread a post by DavidK where he mentions the javascript getKey('MYTABLEALIAS') function, which i intend to test prior to sending the email but after it's saved, i'll see if i can catch it this way..

            Comment


              #7
              Re: Primary key value when using Dialog to insert new record

              I am reposting this since something seems weird with this thread ( i see Garry's is the last post, but when i get in, i see mine...)

              Jaime

              OrderID is numeric, set as entity with auto-increment, and set as updateable. It is set as Primary key in the dialog . The only 'abnormal' issue here is that i set the control to disabled and invisible ( 1=2 in both show/hide and enable properties )
              I just saw in another thread a post by DavidK where he mentions the javascript getKey('MYTABLEALIAS') function, which i intend to test prior to sending the email but after it's saved, i'll see if i can catch it this way..

              Comment


                #8
                Re: Primary key value when using Dialog to insert new record

                Well, i still can't get the generated new value in the OrderID primary key after submit. I put a debug(1) after submit and prior to the email send, tried to look at all the objects, and didn't find the value for orderID. The only place where i found it is deep inside some javascript object or string.
                This is a very basic and common scenario, i do not understand how i got just a response from 1 guy in 3 months...

                Thanks
                Jaime

                Comment


                  #9
                  Re: Primary key value when using Dialog to insert new record

                  I am running into the same problem here and cant seem to find the solution.

                  1. In a dialog, I am using the primary key as orderid (auto increment sql table)

                  2. After the dialog has been submitted, I need to retrive the newly created ID in some way so I can use it in the confirmation email (also sent by the dialog).

                  Bassically I need to get the newly created orderid somewhere between the ExecuteServerSideAction("Save Data::") and ExecuteServerSideAction("Send E-mail Message::") scripts...

                  Robert

                  Comment


                    #10
                    Re: Primary key value when using Dialog to insert new record

                    Usually there is an sql statement to get the last id that was entered.

                    I don't know what it is for a particular flavor of SQL, but the SQL vendor's help file should provide it.

                    So you do 2 calls to the database. One to insert the row, the next to get the id that was just assigned.

                    YMMV
                    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


                      #11
                      Re: Primary key value when using Dialog to insert new record

                      hello

                      if you are using sql backend, dialog to capture the data and when you submit (if after validate has no errors and submission is successful) you should be able to get the primary key by using the connection.CallResult.LastInsertedIdentity. there is a whole article on xbasic with sql in the wiki. take a look.

                      thanks for reading

                      gandhi

                      version 10.5
                      mysql backend
                      thanks for reading

                      gandhi

                      version 11 3381 - 4096
                      mysql backend
                      http://www.alphawebprogramming.blogspot.com
                      [email protected]
                      Skype:[email protected]
                      1 914 924 5171

                      Comment


                        #12
                        Re: Primary key value when using Dialog to insert new record

                        I believe you can query the last indentity field by querying '@@identity'. My recollection is this is the SQL system field that stores the last used identity number for a given table.

                        I have uses this many times, but I do have to query for it, so I have something like "Select @@identity from tblname" . I am not sure of the A5 query syntax... I am still working on trying to learn Xbasic and finding it much harder than it should be. (sigh)
                        Regards,

                        John W.
                        www.CustomReportWriters.net

                        Comment


                          #13
                          Re: Primary key value when using Dialog to insert new record

                          The last inserted primary key value is made available in
                          Code:
                          e.rtc.lastPrimaryKeyValue
                          in the AfterDialogValidate server side event.
                          Jim Coltz
                          Alpha Custom Database Solutions, LLC
                          A5CustomSolutions.com
                          [email protected]

                          Comment


                            #14
                            Re: Primary key value when using Dialog to insert new record

                            Originally posted by Jim Coltz View Post
                            The last inserted primary key value is made available in
                            Code:
                            e.rtc.lastPrimaryKeyValue
                            in the AfterDialogValidate server side event.
                            thanks!!!!!!!

                            I could actually put this straight into the email HTML body of my confirmation email. Something like:

                            Thank you, your order ID is {e.rtc.lastPrimaryKeyValue}

                            Robert

                            Comment


                              #15
                              Re: Primary key value when using Dialog to insert new record

                              Originally posted by Jim Coltz View Post
                              The last inserted primary key value is made available in
                              Code:
                              e.rtc.lastPrimaryKeyValue
                              in the AfterDialogValidate server side event.
                              thanks!!!!!!!

                              I could actually put this straight into the email HTML body of my confirmation email. Something like:

                              Thank you, your order ID is {e.rtc.lastPrimaryKeyValue}

                              Robert

                              Comment

                              Working...
                              X