Alpha Video Training
Page 1 of 2 12 LastLast
Results 1 to 30 of 39

Thread: Web Dialog Database not talking

  1. #1
    Member
    Real Name
    Ondra Simons
    Join Date
    Jul 2007
    Posts
    22

    Default Web Dialog Database not talking

    Hi I am creating my first web Dialog. I linked it to a table
    using some x basic code. The connection works but when
    I put numbers in my form the rows in the table just show up
    with 0.00 the table look for numeric only and all the columns
    are being filled with 0.00 after I press the submit button, insted
    of the numbers I put in the form.

  2. #2
    Volunteer Moderator Steve Wood's Avatar
    Real Name
    Steve Wood
    Join Date
    Nov 2003
    Location
    Bay Area, California
    Posts
    8,842

    Default Re: Web Dialog Database not talking

    Welcome to Alpha web...

    You might have to post the xbasic here for it to make sense. Everything on a web dialog is Charactor, even if you select Numeric, etc. To save to your numeric table field, you would need to use something like this:

    tbl.mynumber = convert_type(mydialogfield,"N")

    But posting the xbasic will help, because maybe it isn't even posting results.
    Steve Wood
    Join the ALPHA DEVELOPERS NETWORK
    There is no Cloud. It's just someone else's computer.
    Web - Mobile - Hosting - Products - Frameworks - Developer Resources
    AlphaToGo | IADN (100% Alpha Anywhere Websites)

  3. #3
    Member
    Real Name
    Ondra Simons
    Join Date
    Jul 2007
    Posts
    22

    Default Re: Web Dialog Database not talking

    Thanks Steve. It worked.

  4. #4
    Member
    Real Name
    Travis Seymour
    Join Date
    Sep 2007
    Location
    Bay Area, California
    Posts
    44

    Default Re: Web Dialog Database not talking

    Hi Steve, I'm a newbie having trouble posting back to my table after pressing submit on a web dialog. I'm able to load the data into the dialog just fine using this code in INITIALIZE:

    dim t as P
    dim rec as N
    if eval_valid("PageVariables.Id") then
    t = table.open("[PathAlias.ADB_Path]\pekids_table")
    t.order("Id")
    rec = t.fetch_find(val(PageVariables.Id))
    if (rec > 0) then
    ParentLast = alltrim(t.PARENT_LASTNAME)
    ParentFirst = alltrim(t.PARENT_FIRSTNAME)
    HomeNum = alltrim(str(t.HOME_PHONE))
    WorkNum = alltrim(str(t.WORK_PHONE))
    CellNum = alltrim(str(t.CELL_PHONE))
    Street = alltrim(t.STREET_ADDRESS)
    City = alltrim(t.CITY)
    end if
    t.close()
    end if


    then in the AFTERVALIDATE event I have this:

    dim t as P
    dim rec as N
    if eval_valid("PageVariables.Id") then
    t = table.open("[PathAlias.ADB_Path]\pekids_table")
    t.order("Id")
    rec = t.fetch_find(val(PageVariables.Id))
    if (rec > 0) then
    t.PARENT_LASTNAME = alltrim(ParentLast)
    t.PARENT_FIRSTNAME = alltrim(ParentFirst)
    t.HOME_PHONE = convert_type(remspecial(HomeNum),"N")
    t.WORK_PHONE = convert_type(remspecial(WorkNum),"N")
    t.CELL_PHONE = convert_type(remspecial(CellNum),"N")
    t.STREET_ADDRESS = alltrim(Street)
    t.CITY = alltrim(City)
    end if
    t.close()
    end if


    It does the validation properly (I'm using the javascript boxes) and doesn't complain when I press submit, but the changes are not reflected in the database.

    What am I doing wrong here?

  5. #5
    Alpha Software Employee Lenny Forziati's Avatar
    Real Name
    Lenny Forziati
    Join Date
    Nov 2001
    Location
    Alpha Software
    Posts
    4,696

    Default Re: Web Dialog Database not talking

    You need to use t.change_begin() to put the table into change mode for your record, and then t.change_end() to commit the change.

    Lenny Forziati
    Vice President, Internet Products and Technical Services
    Alpha Software Corporation

  6. #6
    Member
    Real Name
    Travis Seymour
    Join Date
    Sep 2007
    Location
    Bay Area, California
    Posts
    44

    Default Re: Web Dialog Database not talking

    Thanks for the fast response!
    I assumed you meant like this:

    t = table.open("[PathAlias.ADB_Path]\pekids_table")
    t.order("Id")
    rec = t.fetch_find(val(PageVariables.Id))
    if (rec > 0) then
    t.change_begin()
    t.PARENT_LASTNAME = alltrim(ParentLast)
    t.PARENT_FIRSTNAME = alltrim(ParentFirst)
    t.HOME_PHONE = convert_type(remspecial(HomeNum),"N")
    t.WORK_PHONE = convert_type(remspecial(WorkNum),"N")
    t.CELL_PHONE = convert_type(remspecial(CellNum),"N")
    t.STREET_ADDRESS = alltrim(Street)
    t.CITY = alltrim(City)
    t.change_end()
    end if
    t.close()

    but the changes still didn't post.

  7. #7
    Alpha Software Employee Lenny Forziati's Avatar
    Real Name
    Lenny Forziati
    Join Date
    Nov 2001
    Location
    Alpha Software
    Posts
    4,696

    Default Re: Web Dialog Database not talking

    Have you verified that rec is not zero?

    Lenny Forziati
    Vice President, Internet Products and Technical Services
    Alpha Software Corporation

  8. #8
    Member
    Real Name
    Travis Seymour
    Join Date
    Sep 2007
    Location
    Bay Area, California
    Posts
    44

    Default Re: Web Dialog Database not talking

    Shoot, I feel a little silly about not checking that. Since the INITIALIZE event successfully used the same method to get the data already stored in the current record, I assumed it worked here. Maybe my pagevariable is no longer in scope or something. BTW, I did use (.T.) with the change_end function.

    In terms of debugging, what's the easiest way to throw up a value somewhere where I can see it? If I were programming some other language, I'd do something like

    if (rec > 0) then msg_box("rec retrieved ok").

    Is there something like ui_msg_box() for web apps?
    Last edited by drowelf; 09-21-2007 at 08:03 PM. Reason: clarification

  9. #9
    Member
    Real Name
    Travis Seymour
    Join Date
    Sep 2007
    Location
    Bay Area, California
    Posts
    44

    Default Re: Web Dialog Database not talking

    OK, I created some debugging code and just wrote the text to one of the textboxes on my dialog. Turns out that

    if eval_valid("PageVariables.Id") then

    is evaluating to False, even though it evaluated to True in the INITIALIZE event. I can get around this by actually storing the ID on the dialog and then using this info later instead of the pagevariable. However, an internal variable would be better. Is there a way for me to keep this PageVariable around, or to create my own variable that will stick around so that the AFTERVALIDATE even can use it?

  10. #10
    Volunteer Moderator Peter.Greulich's Avatar
    Real Name
    Peter Greulich
    Join Date
    Apr 2000
    Location
    Boston, MA
    Posts
    11,644

    Default Re: Web Dialog Database not talking

    Quote Originally Posted by drowelf View Post
    Is there a way for me to keep this PageVariable around, or to create my own variable that will stick around so that the AFTERVALIDATE even can use it?
    I think you want a session variable. Something like:

    session.id

  11. #11
    Volunteer Moderator Steve Wood's Avatar
    Real Name
    Steve Wood
    Join Date
    Nov 2003
    Location
    Bay Area, California
    Posts
    8,842

    Default Re: Web Dialog Database not talking

    I've never understood exactly why local variables don't stick between events. For instance, if you set name=steve in the Validate, its not available in the AfterValidate event. It must be due to the fact that this is all operating in a web environment and whenever you press Submit, you are refreshing the page. If I need a variable to exist between events, or after, I always use session.variable=myvalue, in whatever event the value myvalue exists.
    Steve Wood
    Join the ALPHA DEVELOPERS NETWORK
    There is no Cloud. It's just someone else's computer.
    Web - Mobile - Hosting - Products - Frameworks - Developer Resources
    AlphaToGo | IADN (100% Alpha Anywhere Websites)

  12. #12
    Member
    Real Name
    Travis Seymour
    Join Date
    Sep 2007
    Location
    Bay Area, California
    Posts
    44

    Default Re: Web Dialog Database not talking

    I took your advice and used a session variable to store my ID number. It sticks around from the Initialize Event to the AfterValidate Event as expected. However, here:

    http://msgboard.alphasoftware.com/al...ad.php?t=69352

    I describe trying to update anoter session variable inside a control's OnClick Event. For some reason, this update is never happening. Any idea why the OnClick Event wouldn't see a session variable?

  13. #13
    Volunteer Moderator Steve Wood's Avatar
    Real Name
    Steve Wood
    Join Date
    Nov 2003
    Location
    Bay Area, California
    Posts
    8,842

    Default Re: Web Dialog Database not talking

    I know from testing that code there does not do anything if the control is a text field of any type. You can test easily by putting rsponse.redirect("bogus") in the OnClick event, then view in browser and click the control.

    However, it you change the control to an Advanced Button, it fires that code when the button is clicked. So far as I can tell, that OnClick is reserved for the Advanced Button.

    Change your logic - in the Initailize save all values to temp variables. In the AfterValidate, test for any difference between temps and the new values, save recrod if so. Write your audit trail at the same time.

    note - I have an article on my website about audit trails in web apps.
    Steve Wood
    Join the ALPHA DEVELOPERS NETWORK
    There is no Cloud. It's just someone else's computer.
    Web - Mobile - Hosting - Products - Frameworks - Developer Resources
    AlphaToGo | IADN (100% Alpha Anywhere Websites)

  14. #14
    Member
    Real Name
    Travis Seymour
    Join Date
    Sep 2007
    Location
    Bay Area, California
    Posts
    44

    Default Re: Web Dialog Database not talking

    Aha. In most places, when you change the control type, the valid options appear/disappear as appropriate. Since the OnClick was still there, I assumed the obvious. I think I'll try your audit solution and also check your website.
    Thanks, for your quick reply!
    tls

  15. #15
    Member
    Real Name
    Travis Seymour
    Join Date
    Sep 2007
    Location
    Bay Area, California
    Posts
    44

    Default Re: Web Dialog Database not talking

    Whoa, that audit article is great! I'm writing this just in case later readers didn't notice that quick suggestion. If you're reading this thread because you have a similar goal as mine, you should definitely check out this article. I'm not sure if it's ok to link directly, so just go to Alphatogo.com --> ForDevelopers --> search for "Audit". It's a PDF file with an easy to understand guide.

  16. #16
    Volunteer Moderator Steve Wood's Avatar
    Real Name
    Steve Wood
    Join Date
    Nov 2003
    Location
    Bay Area, California
    Posts
    8,842

    Default Re: Web Dialog Database not talking

    May be an oversight, but Alpha does properly display/hide options elsewhere. BTW, as a self-described newbie, you are doing very well with the xbasic and components.
    Steve Wood
    Join the ALPHA DEVELOPERS NETWORK
    There is no Cloud. It's just someone else's computer.
    Web - Mobile - Hosting - Products - Frameworks - Developer Resources
    AlphaToGo | IADN (100% Alpha Anywhere Websites)

  17. #17
    Volunteer Moderator Steve Wood's Avatar
    Real Name
    Steve Wood
    Join Date
    Nov 2003
    Location
    Bay Area, California
    Posts
    8,842

    Default Re: Web Dialog Database not talking

    On the article, note that the section on Login Dialog (capturing login information) is outdated. It won't work if you are building an application that uses the new Security Framework. That's because the new Login component does not allow for custom events.

    S/F has a built in way to capture logins on the Security Config page, or you can put code similar to what's in the article, but directly on the Login.A5W page, in exactly the right spot! But I'd have to expirement to know how that code would look.
    Steve Wood
    Join the ALPHA DEVELOPERS NETWORK
    There is no Cloud. It's just someone else's computer.
    Web - Mobile - Hosting - Products - Frameworks - Developer Resources
    AlphaToGo | IADN (100% Alpha Anywhere Websites)

  18. #18
    Member
    Real Name
    Travis Seymour
    Join Date
    Sep 2007
    Location
    Bay Area, California
    Posts
    44

    Default Re: Web Dialog Database not talking

    Let me ask you....
    I have a big flat database of contacts that I actually borrow from an even larger set owned by someone else. The agreement is that I can contact these people for my studies (I'm a memory researcher) as long as I report particular types of changes (phone number, call restrictions, phone/address changes, and a couple others).

    What I need is not just some way to audit when users make changes, but to audit exactly which changes they make. That is, with my web grid, I'd like to save a change record to my changes_table.mdb table that contains username, recordID, name of field changed, and the actual change.

    So, my question is:
    1) Which Event (BeforeValidateExistingRecords, CanUpdateRecord, AFterUpdateRecords, etc.) is the best one to use and
    2) How do I get access to only the fields that changed?

    I'm trying to avoid having to save the value of each field in a session variable and then compare them. Even if I wanted to take this approach, grids (as opposed to dialogs) don't seem to have any sort of Initialize event where I'd setup the "before" values anyway.

    If I'm thinking about this incorrectly, perhaps I'd change my question to: Given my reporting needs (notify someone when certain fields change), how would you go about it with a grid component?

    Thanks in advance

  19. #19
    "Certified" Alphaholic peteconway's Avatar
    Real Name
    Peter Conway
    Join Date
    Oct 2005
    Location
    Melbourne, Australia
    Posts
    2,642

    Default Re: Web Dialog Database not talking

    If it was my call, id just start with two identical tables, both having the same unique key, do all the editing on one of them and at the end run a report that checks where the tables are different.

    Peter

  20. #20
    Member
    Real Name
    Travis Seymour
    Join Date
    Sep 2007
    Location
    Bay Area, California
    Posts
    44

    Default Re: Web Dialog Database not talking

    That's interesting. I guess I could run my weekly difference report, then copy all changes to the comparison table...then do it all again the next week. That would work. Did you suggest this because it's easy, or because there is no way to do it the way I was thinking?

  21. #21
    Member
    Real Name
    Travis Seymour
    Join Date
    Sep 2007
    Location
    Bay Area, California
    Posts
    44

    Default Re: Web Dialog Database not talking

    also, how should I approach the report? It's not obvious to me how to filter the report based on a comparison with another table.

  22. #22
    Volunteer Moderator Steve Wood's Avatar
    Real Name
    Steve Wood
    Join Date
    Nov 2003
    Location
    Bay Area, California
    Posts
    8,842

    Default Re: Web Dialog Database not talking

    Don't keep a record of any change as it happens. Periodically compare the original database to the current one, write any field value differences to an audit file.

    EDIT: Peter - I left this post on my screen, went out for the day, came back and posted my thoughts -- apparently I made the same suggestion as you!
    Steve Wood
    Join the ALPHA DEVELOPERS NETWORK
    There is no Cloud. It's just someone else's computer.
    Web - Mobile - Hosting - Products - Frameworks - Developer Resources
    AlphaToGo | IADN (100% Alpha Anywhere Websites)

  23. #23
    "Certified" Alphaholic peteconway's Avatar
    Real Name
    Peter Conway
    Join Date
    Oct 2005
    Location
    Melbourne, Australia
    Posts
    2,642

    Default Re: Web Dialog Database not talking

    Until you get the hang of things, try this.
    Start with your original table (to make this easy ensure all fields are Charcter based).
    Add a Character field called all_data , make if approx the same size as the total of all field widths (you may get away with half the size) but see how you go.
    Create a calculated rule for the "all_data" field.
    it would look something like this.
    alltrim(field1)+alltrim (field2)+alltrim(field3) or if you want it easy to read alltrim(field1) + " " + alltrim (field2) +" " + alltrim(field3) etc.
    save the rule
    right click the table and select to recalc field rules
    right click again
    duplicate
    name this table to indicate this if the file to be edited.
    use the table when making changes in your grid
    when you are done
    just click operations
    new -and create a post update on the files whe all_data <> all_data from both the tables.
    Good luck.

  24. #24
    "Certified" Alphaholic peteconway's Avatar
    Real Name
    Peter Conway
    Join Date
    Oct 2005
    Location
    Melbourne, Australia
    Posts
    2,642

    Default Re: Web Dialog Database not talking

    Cheers, Steve. - Peter

  25. #25
    Member
    Real Name
    Travis Seymour
    Join Date
    Sep 2007
    Location
    Bay Area, California
    Posts
    44

    Default Re: Web Dialog Database not talking

    Wow, I was just wrote a function that takes a record-number and a fieldname and returns .t. if the passed fieldname is different in the current vs. duplicate the database. I wrote another function that flags the fields in the current table with changed fields I care about. I was going to use this function to filter my report. You're solution is much more elegant, and I'm tempted to switch to it.

    However, since my functions would only get used when the report was run, doesn't it put less strain on the database than the bigfield approach which would involve recalculating the bigfield every time a change was made? Or does it really matter?

    I think I might use your approach anyway just for it's simplicity.

    In any case, I really appreciate the time your advice.

  26. #26
    Member
    Real Name
    Travis Seymour
    Join Date
    Sep 2007
    Location
    Bay Area, California
    Posts
    44

    Default Re: Web Dialog Database not talking

    In the end, I used the two functions I mentioned. I filtered the report using a function that checked to see if each record had changed (essentially using a version of Peter's aggregation method). Since the report prints the entire record, I used a more targeted function (did THIS field change) to highlight each field in each record that actually changed.

  27. #27
    Member
    Real Name
    Travis Seymour
    Join Date
    Sep 2007
    Location
    Bay Area, California
    Posts
    44

    Default Re: Web Dialog Database not talking

    ...well, it works fine from the designer, but when trying to runt the report from a web dialog, I get a "Function is not recognized" error. Does this mean that user defined functions can't be used in web components?
    Last edited by drowelf; 09-30-2007 at 06:29 PM. Reason: clarification

  28. #28
    Volunteer Moderator Steve Wood's Avatar
    Real Name
    Steve Wood
    Join Date
    Nov 2003
    Location
    Bay Area, California
    Posts
    8,842

    Default Re: Web Dialog Database not talking

    The web, by design, is not attached to your database other than momentarily when you press submit. The only things on the "Control Panel" that are applicable on the web are Tables, Reports and some (not all) of the Field Rules. Nothing from the Code tab is available from the browser. However, almost anything you write in Code can be lifted and placed in an A5W page as xbasic. It will run when the page is displayed in the browser. YOu can also put that same code in the afterValidate event of a dialog and it fires when you press Submit. All of this takes some practice. It sounds like you put a myfunction() statement in your dialog -- that won't work. But take the same code and copy-paste it directly to the AfterValidate and, after some tweaking, it should work. Note, you cannot use any UI type functions in the web environment, functions that would bring a message box dialog to the screen for instance.
    Steve Wood
    Join the ALPHA DEVELOPERS NETWORK
    There is no Cloud. It's just someone else's computer.
    Web - Mobile - Hosting - Products - Frameworks - Developer Resources
    AlphaToGo | IADN (100% Alpha Anywhere Websites)

  29. #29
    Member
    Real Name
    Travis Seymour
    Join Date
    Sep 2007
    Location
    Bay Area, California
    Posts
    44

    Default Re: Web Dialog Database not talking

    Thanks Steve, that makes sense...I'll give that a try.

  30. #30
    Member
    Real Name
    Travis Seymour
    Join Date
    Sep 2007
    Location
    Bay Area, California
    Posts
    44

    Default Re: Web Dialog Database not talking

    Hmmm...the Geni generated code to print a report is giving me this error:

    Internal Error: 3023
    Bad object handle


    when it gets to this line of code:

    filename = report.saveas("weekly_change@[PathAlias.ADB_Path]\pekids_table.ddd","html",filter,order,filename,.f.)


    I assume the object in question is the report object. Do I need to initialize this object somewhere before using the .saveas method?

Similar Threads

  1. Web Component - Dialog
    By jacklcs22 in forum Application Server Version 8
    Replies: 3
    Last Post: 11-05-2007, 02:57 PM
  2. Quickbooks and Alpha Talking To Each Other
    By John Keogh in forum Alpha Five Version 8
    Replies: 26
    Last Post: 10-18-2007, 12:23 PM
  3. Web Dialog
    By jacklcs22 in forum Application Server Version 8
    Replies: 0
    Last Post: 06-25-2007, 09:27 PM
  4. Talking to a modem?
    By seidel1 in forum Alpha Five Version 6
    Replies: 3
    Last Post: 05-27-2005, 12:23 PM
  5. talking to QuickBooks or Peachtree
    By Tom Inloes in forum Alpha Five Version 4
    Replies: 4
    Last Post: 05-28-2000, 01:48 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •