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

Copy or Duplicate record with repeating section from Dialog2 ?

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

    Copy or Duplicate record with repeating section from Dialog2 ?

    Dear Experts,

    is there any sample or code to do "copy/duplicate" function on Dialog with repeating section ?

    I have search for few weeks from the forum but can't find a soluction

    TIA

    #2
    Re: Copy or Duplicate record with repeating section from Dialog2 ?

    Have you seen the video D33? That should get you what you need.

    Comment


      #3
      Re: Copy or Duplicate record with repeating section from Dialog2 ?

      thanks for the direction,

      but this only copy a row from the current repeating section only,

      what i need is to copy and existing master-details to a new master-details dialog to create a new record.

      thanks

      Comment


        #4
        Re: Copy or Duplicate record with repeating section from Dialog2 ?

        Hey Fred,

        The very best way to get exactly the help you need is to include details in your original request, as you did in your reply.

        So... you have 2 Dialogs? Essentially the same... and you want to copy Master/Detail records from one Dialog to a 2nd Dialog?

        Are the Dialogs Data Bound? Are both Dialogs open at the same time? Are they both displayed at the same time?

        There are so many variables and ways to accomplish this that more information is required.

        Comment


          #5
          Re: Copy or Duplicate record with repeating section from Dialog2 ?

          from a dialog, there is a "copy" button"
          when copy button is pressed
          will populate the exising data into a new record from the same dialog
          and a new records is save when press 'submit'

          Thanks

          Comment


            #6
            Re: Copy or Duplicate record with repeating section from Dialog2 ?

            Yes, you can do it. I do it in my dialogs, one of which has two repeating sections, but you're going to have to write the XBasic.
            What I do in my Xbasic is this:

            Query my database based on the current dialogs primary keys.
            Loop through that query and make an array out of it
            Put the array into the javascript dialog populate method
            output a command with the javascript to create a new record and populate it in one shot.

            If you need some help I'm sure others on the forum can give you a hand and I can too. In a couple of days I'll be headed to China though so I may not spend a lot of time on here.

            Comment


              #7
              Re: Copy or Duplicate record with repeating section from Dialog2 ?

              I have do it from ondialoginitialize with e.control.<field>_a5instant2 =
              but don't know how to use _d[1] ... etc and javascript populate.

              Thanks,

              p.s. If you go china through HK, may be we can meet from HK to share ... :)

              Comment


                #8
                Re: Copy or Duplicate record with repeating section from Dialog2 ?

                Hi Fred,
                Actually, I was in HK just after the spring festival. I was able to spend a day there on my way back from Taiwan. We stayed in Kowloon, rode the star ferry across to HK. Went up the mid-town escalators and up to Victoria Peak. I found some great Peking Duck at the Star House Peking Garden and even went to the Temple Street Night Market. Oh, and I got my photo Taken on the Star walk with Bruce Lee, Chow Yun Fat, Jet Li, and Jackie Chan's stars. Haha. I generally acted like a tourist.

                I'm flying direct to Shanghai this time.
                Last edited by -Jinx-; 04-08-2013, 11:55 AM.

                Comment


                  #9
                  Re: Copy or Duplicate record with repeating section from Dialog2 ?

                  I have a copy record button in my dialog. In it's onclick event it uses an ajax callback to call a function called copyRecordData.
                  That function is in my Xbasic Functions in the dialog and looks kind of like this and I stole the initial code from somewhere on this forum:
                  Code:
                  function copyRecordData as c (e as p)
                  dim oldid as c
                  'Get the unique id from the current record in your dialog
                  oldid = e.dataSubmitted.UNIQUE_ID
                  dim masterid as n
                  masterid = oldid
                  dim vjscmd as c
                  'Below is the pointer variable where you will store the array of data
                  dim j as p
                  dim cn as SQL::Connection
                  	if cn.open("::Name::MVWKS")	then
                  		dim sqlCommand as c = "SELECT * FROM machlayoutmaster WHERE unique_id = :masteruid"
                  		dim args as SQL::Arguments
                  		args.add("masteruid",masterid)
                  			if cn.Execute(sqlCommand,args) then
                  				dim rs as SQL::ResultSet
                  				rs = cn.ResultSet
                  					if rs.NextRow() then
                  						'These are the header controls
                  						j.MACHNO = rs.Data("machno")
                  						j.PARTNO = rs.Data("partno")
                  						j.DWGNO = rs.Data("dwgno")
                  						j.STATUS = rs.Data("status")
                  						j.MACHTYPE = rs.Data("machtype")
                  						j.NUMPARTS = rs.Data("numparts")
                  						j.OPNO = rs.Data("opno")
                  						j.LAYOUTREV = rs.Data("layoutrev")
                  						j.MAINPRGNO = rs.Data("mainprgno")
                  						j.HASSUBS = rs.Data("hassubs")
                  						j.NOTES = rs.Data("notes")
                  						j.PROGRAMCALL = rs.Data("prgcall")
                  							sqlCommand = "SELECT * FROM machlayoutdetail WHERE layoutmaster_id = :masteruid"
                  								delete rs
                  							dim cnt as n = 0
                  								if cn.Execute(sqlCommand,args) then
                  									dim rs as SQL::ResultSet
                  									rs = cn.ResultSet
                  									while rs.NextRow()
                  										cnt = cnt + 1
                  										'These are the repeating section controls for CONTAINER_1
                  										eval("j.LAYOUTORD_A5INSTANCE" + alltrim(str(cnt))) = rs.Data("layoutord")
                  										eval("j.POSITION_A5INSTANCE" + alltrim(str(cnt))) = rs.Data("position")
                  										eval("j.DETAILSEQUENCE_A5INSTANCE" + alltrim(str(cnt))) = rs.Data("sequence")
                  										eval("j.TOOL_A5INSTANCE" + alltrim(str(cnt))) = rs.Data("tool")
                  										eval("j.TOOLINFO_A5INSTANCE" + alltrim(str(cnt))) = rs.Data("toolinfo")
                  										eval("j.DETAILNOTES_A5INSTANCE" + alltrim(str(cnt))) = rs.Data("notes")
                  									end while
                  										delete rs
                  									'JavaScript returned to dialog
                  									vjscmd = "{dialog.object}._setRepeatingSectionRowCount('CONTAINER_1'," + cnt + ",true,true);"
                  									'Here we use the populate method and insert and convert our "j" pointer variable to javascript array
                  									vjscmd = vjscmd + "{dialog.object}.populate(" + varToJSON(j) + ",1,false,true);"
                  									'this is adding the code to the above to create a new record and then wait 1 second before populating it.
                  									vjscmd = "{Dialog.Object}.newRecord();setTimeout(function(){" + vjscmd + "},1000);"
                  								else
                  									vjscmd = "alert('No details found for this layout');"
                  								end if	
                  					else
                  						vjscmd = "alert('No header record found.');"
                  					end if
                  			else
                  				vjscmd = "alert('Execute Error: Error returned was: " + js_escape(cn.CallResult.text) + "');"
                  			end if
                  			cn.Close()
                  	else
                  		vjscmd = "alert('Connection Error: Error returned was: " + js_escape(cn.CallResult.text) + "');"
                  	end if
                  'debug(1)		
                  copyRecordData = vjscmd
                  end function
                  I chopped this up a bit because you only needed one repeating section. I may have made a mistake or two in the process, but this should get you where you're going.
                  Last edited by -Jinx-; 04-08-2013, 11:57 AM.

                  Comment


                    #10
                    Re: Copy or Duplicate record with repeating section from Dialog2 ?

                    Back from China. Yay!

                    Did you ever get this working Fred?

                    Comment


                      #11
                      Re: Copy or Duplicate record with repeating section from Dialog2 ?

                      Originally posted by -Jinx- View Post
                      Back from China. Yay!

                      Did you ever get this working Fred?

                      Yes, got working perfectly

                      Comment


                        #12
                        Re: Copy or Duplicate record with repeating section from Dialog2 ?

                        Thank you -Jinx-. Used this myself and it works great. I do have more than one repeating section and have not been able to figure out where to modify the code to include the other repeating sections.

                        -JR
                        J.R.
                        Epigate Software, LLC.

                        [email protected]
                        http://www.epigate.com
                        sigpic

                        Comment


                          #13
                          Re: Copy or Duplicate record with repeating section from Dialog2 ?

                          Jinx

                          I must also thank you for this code. After the code I opens a new ux Dialog and wants to paste the records into it. How do I do it?
                          Thanks

                          Comment


                            #14
                            Re: Copy or Duplicate record with repeating section from Dialog2 ?

                            Jinx

                            Let me rephrase my question. I have a quotation (dialog). On this dialog I have a button to copy all the data to another dialog (order). With your code a new dialog is opened from the quote. I want to open a new order dialog.

                            Can you help?

                            Comment


                              #15
                              Re: Copy or Duplicate record with repeating section from Dialog2 ?

                              Hi Norman,
                              Sorry it took me a while to reply. Been busy.

                              You're best off doing something like this I think:

                              Click a button in the parent dialog that opens the child dialog. Upon running the child dialog, have it check for a variable (which would be the primary key from the parent dialog) and if that variable exists, run the query and the code on in the child dialog. So, put the Xbasic code to copy a record into the Xbasic functions of the child dialog. Just transfer the primary key and only the primary key from the parent dialog.

                              Make sense?

                              As usual, there's probably an even better way to do it somewhere that I haven't thought of yet. My code is still working in my application so I haven't had any reason to research updating it lately.

                              Comment

                              Working...
                              X