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

Auto Increment Help

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

  • Auto Increment Help

    Hello, using the below code when a user presses "New" button a new field ticket is created with a field ticket id of the next highest number (ie if last field ticket was JKFT00151 when "new" button is pressed next field ticket id is JKFT00152).

    my_id = tablemax("tbl_fieldticket","left(Field_Ticket_Id,4) = 'JKFT'","Field_Ticket_Id")
    new_id = increment_value(my_id)
    topparent.new_record()
    topparent:Field_Ticket_Id.value = new_id

    What I would like to accompish is when user presses "duplicate" button a new field ticket is created and given the current field ticket's id plus ".1" and I can't figure how to add the ".1" to the field ticket id.

    For example, if the user wants to duplicate field ticket JKFT00151 then a dupicate field ticket is created with the field ticket id being JKFT00151.1 then if user want to duplicate JKFT00151.1 a duplicate field ticket is created with field ticket id JKFT00151.2 etc....... I can manually go back to the field "Field Ticket ID" on the form and change the id numbers and add ".1", ".2" etc but I would like this be done using code.

    Here's another issue. When I manually change the field ticket id to JKFT00151.1 and user presses "new" button a new field ticket is created with a field ticket id of JKFT00151.2 and I would like it to be JKFT00152. In other words, NO ".#"

    Thank you in advance... JON

  • #2
    Re: Auto Increment Help

    For the new record the line

    new_id = increment_value(my_id)

    would be

    new_id = increment_value(word(my_id,1,"."))
    There can be only one.

    Comment


    • #3
      Re: Auto Increment Help

      I can't figure how to add the ".1" to the field ticket id.
      The logic would be

      if there is a period in the id then it has been duplicated previously, just increment it
      if not, add ".1" to the end as in

      new_id = my_id+".1"
      There can be only one.

      Comment


      • #4
        Re: Auto Increment Help

        Thanks Stan for the quick response and "working solution" for "New" button. Any ideas on the following:

        When user presses "duplicate" button a new field ticket is created and given the current field ticket's id plus ".1" and I can't figure how to add the ".1" to the field ticket id.

        For example, if the user wants to duplicate field ticket JKFT00151 then a dupicate field ticket is created with the field ticket id being JKFT00151.1 then if user want to duplicate JKFT00151.1 a duplicate field ticket is created with field ticket id JKFT00151.2 etc....... I can manually go back to the field "Field Ticket ID" on the form and change the id numbers and add ".1", ".2" etc but I would like this be done using code.

        Comment


        • #5
          Re: Auto Increment Help

          Stan I implemented you suggestion on the duplicate button and when pressed it duplicates currently field ticket with same field ticket id without ".1". Here is the code for duplicate button:

          my_id = tablemax("tbl_fieldticket","left(Field_Ticket_Id,4) = 'JKFT'","Field_Ticket_Id")
          new_id = my_id+".1"
          topparent.new_record()
          topparent:Field_Ticket_Id.value = new_id

          I would like user to find field ticket they wish to duplicate (ie JKFT00200) press duplicate button and a duplicate field ticket is created and given a field ticket id (ie JKFT200.1)

          Comment


          • #6
            Re: Auto Increment Help

            my_id = tablemax("tbl_fieldticket","left(Field_Ticket_Id,4) = 'JKFT'","Field_Ticket_Id")

            is probably returning the field value in Field_Ticket_Id with the trailing spaces leaving no room to store the ".1"

            change to

            my_id = tablemax("tbl_fieldticket","left(Field_Ticket_Id,4) = 'JKFT'","alltrim(Field_Ticket_Id)")
            There can be only one.

            Comment


            • #7
              Re: Auto Increment Help

              Stan, using your suggestion I got it almost working as desired using the following code:

              current_id = alltrim(topparent.field_ticket_id.value)
              dup_id = current_id+".1"
              topparent.new_record()
              topparent:Field_Ticket_Id.value = dup_id

              Using the above code when user presses duplicate on field ticket (ie JKFT00200) a duplicate field ticket is created (ie JKFT00200.1). The problem I'm still having, is user trys to duplicate JKFT00200.1 the desired field ticket would JKFT00200.2 what is currently happening is, a duplicate field ticket is created with field ticket id of: JKFT00200.1.1

              Thanks again... JON

              Comment


              • #8
                Re: Auto Increment Help

                Hi Jon,
                See if this works:

                current_id = alltrim(topparent.field_ticket_id.value)
                if word(current_id,2,".",1) <> "" then
                dup_id = increment.value(current_id)
                else
                dup_id = current_id+".1"
                end if
                topparent.new_record()
                topparent:Field_Ticket_Id.value = dup_id
                Robin

                Discernment is not needed in things that differ, but in those things that appear to be the same. - Miles Sanford

                Comment


                • #9
                  Re: Auto Increment Help

                  You ignored the logic.

                  The logic would be

                  if there is a period in the id then it has been duplicated previously, just increment it
                  if not, add ".1" to the end as in
                  Originally posted by jbk View Post
                  Stan, using your suggestion I got it almost working as desired using the following code:

                  current_id = alltrim(topparent.field_ticket_id.value)
                  dup_id = current_id+".1"
                  topparent.new_record()
                  topparent:Field_Ticket_Id.value = dup_id

                  Using the above code when user presses duplicate on field ticket (ie JKFT00200) a duplicate field ticket is created (ie JKFT00200.1). The problem I'm still having, is user trys to duplicate JKFT00200.1 the desired field ticket would JKFT00200.2 what is currently happening is, a duplicate field ticket is created with field ticket id of: JKFT00200.1.1

                  Thanks again... JON
                  There can be only one.

                  Comment


                  • #10
                    Re: Auto Increment Help

                    Thanks Robin, that worked with minor change in the following line:

                    dup_id = increment.value(current_id) >>>> dup_id = increment_value(current_id) (just in case somebody else needed similiar code)

                    Thanks again... JON

                    Comment


                    • #11
                      Re: Auto Increment Help

                      Sorry Jon I didn't test it in the IW first ;)
                      Robin

                      Discernment is not needed in things that differ, but in those things that appear to be the same. - Miles Sanford

                      Comment


                      • #12
                        Re: Auto Increment Help

                        No problem Robin. Thank you for the help!!!

                        Comment


                        • #13
                          Re: Auto Increment Help

                          Robin, your solution for duplicating the field ticket works like a charm. Again Thank You... In my earlier post, I asked for help in finding a solution if a user presses duplicate button on form (ie JKFT00200) then a duplicate field ticket with (ie JKFT00200.1) would be created and it does thanks to Stan and Robin. If user tries to duplicate JKFT00200.1 a duplicate field ticket is created (JKFT00200.2). If user tries to duplicate JKFT00200 and JKFT00200.1 and JKFT00200.2 exist, a duplicate field ticket with id of JKFT00200.1 is created even though this ticket number exist. In this scenrio, I would've liked a duplicate ticket with id JKFT00200.3 to have been created due to the fact .1 and .2 already exist. Any and all help would be appreciated.... JON

                          Comment


                          • #14
                            Re: Auto Increment Help

                            Error checking is an art of its own! Since the user is selecting something other than the last duplicate record - which makes a lot of sense for the user who's only interest is copying a particular record - the logic to him is that it ought to make the next one in the series; regardless of which one of them he chooses. You are now going to have to do a query and then fetch the last record in that query and increment it. Which of course changes the whole ballgame...Your query needs to filter for just the basic field value so all three records will be in the result. Take a look at table.record_content_get() since you are using the open table. That will get you a list. Otherwise I suppose table.query_create() is needed. Once you have a table pointer you can fetch the last record.

                            No doubt there is a learning curve in Alpha...
                            Last edited by MoGrace; 05-02-2013, 12:37 AM.
                            Robin

                            Discernment is not needed in things that differ, but in those things that appear to be the same. - Miles Sanford

                            Comment


                            • #15
                              Re: Auto Increment Help

                              Jon,
                              Since you are trying to create a rule here then you need some test for when the user tries to break it. Perhaps you could add a logical flag to the record that your duplicate script changes to true. Then you can prompt the user for what he wants to do when he tries to duplicate a record again and give him a choice?

                              Illustration:

                              T 1001
                              T 1001.1
                              F 1001.2
                              F 1002
                              F 1003

                              If the user tries to duplicate 1001 again, your rule would now prompt him for the value, giving him the default perhaps of "1001." and of course the option to cancel so he can pick the right record - until he learns better that if he picks the right record in the first place then no prompt appears.

                              Oh, and you should also test that the number he enters is unique before allowing the record to be accepted.
                              Last edited by MoGrace; 05-02-2013, 12:02 PM.
                              Robin

                              Discernment is not needed in things that differ, but in those things that appear to be the same. - Miles Sanford

                              Comment

                              Working...
                              X