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

UX Repeating Section Xbasic Loop Code

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

    UX Repeating Section Xbasic Loop Code

    Hi All,

    I have a repeating section that I need to loop through 1 row at a time, and then submit the data for each row.

    With the help of http://wiki.alphasoftware.com/Parent...+in+Version+11, I wrote the following code.

    I commented out the loop portions, to first get the sql insert to work. It does in fact submit the first row in the repeating section. As soon as I uncomment 'for i = 1 to ncount' and 'if len(e.dataSubmitted.WoChildId[i]) < 1 continue end if' data does not submit, and debug(1) does not fire.

    Can someone look through my code, and let me know what I am missing?


    Code:
    function afterDialogValidate as v (e as p)
    
    debug(1)
    	
    dim sql as c	
    DIM cn as SQL::Connection
    DIM args as sql::arguments
    DIM cr as sql::CallResult
    
     
    sql = "INSERT INTO WorkOrders (WoChildId, WoCustId, WoTechId, WoOpenDt, Approval, WoStatus, WoProjectId, WoDescription, WoSrtDtTm, WoEndDtTm, WoPropSrtDt, WoPropSrtTm, WoPropEndDt, WoPropEndTm, WoRespReq, WoTechPay, WoEmpId) VALUES (:WoChildId, :WoCustId, :WoTechId, :WoOpenDt1, :Approval1, :WoStatus1, :WoProject_Id1, :WoDescription1, :WoSrtDtTm1, :WoEndDtTm1, :WoPropSrtDt1, :WoPropSrtTm1, :WoPropEndDt1, :WoPropEndTm1, :WoRespReq1, :WoTechPay1, :WoEmpId1)"
    
    cn.PortableSQLEnabled = .t.
    cn.open("::Name::ProSQL")
    
    dim i as n
    dim ncount as n = e.dataSubmitted.WoChildId.size()
    
    for i = 1 to ncount
    	 
      'Test to see if the row in the repeating section has data. 
      '       If not, skip to the next row.
      if len(e.dataSubmitted.WoChildId[i]) < 1 
        continue
      end if
      
      args.Clear()
      args.set("WoTechId", e.dataSubmitted.WoTechId[i])
      args.set("WoChildId", e.dataSubmitted.WoChildId[i])
      args.set("WoCustId", e.dataSubmitted.WoCustId1[i])
      args.set("WoOpenDt1", convert_type(e.dataSubmitted.WoOpenDt1[i], "D"))
      args.set("Approval1", e.dataSubmitted.Approval1[i])
      args.set("WoStatus1", e.dataSubmitted.WoStatus1[i])
      args.set("WoProject_Id1", e.dataSubmitted.WoProject_Id1[i])
      args.set("WoDescription1",e.dataSubmitted.WoDescription1[i])
      args.set("WoSrtDtTm1",convert_type(e.dataSubmitted.WoSrtDtTm1[i], "T"))
      args.set("WoEndDtTm1",convert_type(e.dataSubmitted.WoEndDtTm1[i], "T"))
      args.set("WoPropSrtDt1",convert_type(e.dataSubmitted.WoPropSrtDt1[i], "D"))
      args.set("WoPropSrtTm1",CTOT(e.dataSubmitted.WoPropSrtTm1[i]))
      args.set("WoPropEndDt1",convert_type(e.dataSubmitted.WoPropEndDt1[i], "D"))
      args.set("WoPropEndTm1",CTOT(e.dataSubmitted.WoPropEndTm1[i]))
      args.set("WoRespReq1",convert_type(e.dataSubmitted.WoRespReq1[i], "T" ))
      args.set("WoTechPay1",e.dataSubmitted.WoTechPay1[i])
      args.set("WoEmpId1",e.dataSubmitted.WoEmpId1[i])
      
      cn.Execute(sql,args)
      cr = cn.CallResult
      e.javascript = cr.text;
      cn.Close()
    
    next i
    
    end function

    Thanks,
    James

    #2
    Re: UX Repeating Section Xbasic Loop Code

    Hi James,

    Gotta check this first... your code, as listed, reads...

    Code:
    len(e.dataSubmitted.WoChildId[i]) < 1
    Is this actually your code? And not...

    Code:
    len(e.dataSubmitted.WoChildId[i]) < 1
    I also prefer using the repeating section info for getting row counts... but... just a preference.

    Code:
    'In addition, the e object will contain information about the repeating sections
    'e.repeatingSectionNames - a comma delimited list of the name (container ID) or each repeating section
    'e.repeatingSectionInfo - a property array with one entry for each repeating section.
    'The e.repeatingSectionInfo[] array will have these properties for each entry:
    ' - .activeRow - the row in the repeating section that had focus when the Dialog was submitted
    ' - .deletedRows - a CRLF delimited list of rows that were deleted. e.g. 1 and 3
    ' - .rowCount - a count of the number of non-deleted rows
    ' - .totalRowCount - a count of all rows in the repeating section including rows that were deleted
    ' - .fieldsInRepeating section - a CRLF delimited list of fields in the repeating section
    ' - .dirtyRowsInSection - a CRLF delimited list of rows in the repeating section that were edited. (A row that was edited, then deleted will still appear in this list).
    ' - .dirtyFieldsInSection - a CRLF delimited list of fields in the repeating section that were edited. for example: PARTNO_A5INSTANCE3 is the 'PARTNO' field in row 3.
    '-------------------------------------------------------------------------------------------

    Comment


      #3
      Re: UX Repeating Section Xbasic Loop Code

      Thank you so much Dave!!!

      Iv'e been working on this for a couple of days now. I should have looked more closely and have been able to see the &lt; &gt; are HTML <>. The page that helped me with the code must have reformatted the < and > in the code.

      My understanding behind the use of e.dataSubmitted.WoChildId.size(), is to grab how many rows have data in the repeating section. My UX onInitialize prompts the user on how many repeating rows. User enters a number, and the form continues to load. If the user fills in a row in the repeating section and then needs to remove it, Alpha does not delete the row, but instead hides the row. I have added code to the repeating section delete button to clear the data in that row. This way only data entered by the user is actually inserted into SQL.

      Thanks again Dave.

      James

      Comment


        #4
        Re: UX Repeating Section Xbasic Loop Code

        I know... I've been bitten by that before... but only on the desktop and only when creating a mailing. All your HTML goes bonkers and turns into &lt &gt if you edit the email message.

        Your repeating section stuff is all great... I just wanted to confirm something. Would .rowCount give you what you needed? Not that you don't want to check for data anyway. I was just wondering if .rowCount would give you the same count as you need for looping.

        Comment


          #5
          Re: UX Repeating Section Xbasic Loop Code

          Hi Dave,

          I looked into .rowCount and I would think it would work just as well, the explanation is short, but I assume it does not count delete(hidden) rows?

          I stumbled on to the wiki page looking for a way to use a UX with repeating section without binding to any tables and submit the rows manually. So i based the code off that page.

          The UX is used to create multiple records in a flat table setup.

          I now need to go back and put some error checking in place, and also perform a sql lookup of all Child Ids that were entered. (lookup the id in another table and export the address info to excel and email)

          So still have a ways to go.
          Last edited by jacktheripper; 10-10-2013, 09:28 PM.

          Comment

          Working...
          X