Alpha Video Training
Results 1 to 9 of 9

Thread: updating table field before new record is added through grid a component

  1. #1
    Member
    Real Name
    Aijaz Ahmed
    Join Date
    Mar 2006
    Posts
    31

    Default updating table field before new record is added through grid a component

    i am trying to update a field in my table with the a session variable.

    when the user enters a new record the userID is to be saved in the table (both variable and table feild types are character)

    i am using the following code in before validate existing record event which is not working.

    function BeforeValidateExistingRecords as v (DataSubmitted as P, Args as p, PageVariables as p)
    with PageVariables
    vt_clnt.value_put("session.userid")
    end with
    end function

    Where vt_clnt is the feild in table and session.userid is the session variable holding the userid

    Is this the correct syntax?

    What else i should be doing to acheive the required result?

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

    Default

    I think its a bit more simple. Here is what I have in my BeforeValidateNewRecords inside the WITH statement:

    DataSubmitted.job_id = session.job_id

    Also, place your userid in the grid as a text box, but as a hidden column.
    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
    Martin Horzempa
    Join Date
    Oct 2005
    Posts
    224

    Default

    hi aijaz

    i use
    DataSubmitted.PAYMENT_ID=session.userid
    but my userid is numeric

    checkout the insert button on the events tab of the component builder
    it will get you started

    try something like

    DataSubmitted.vt_clnt=session.userid

    regards
    martin

  4. #4
    Member
    Real Name
    Aijaz Ahmed
    Join Date
    Mar 2006
    Posts
    31

    Default

    Thank you All

    Itried the proposed Syntax but i started to get this error.

    Code:
    500 Internal Server Error
    Script Error
    Error:Script: /visa_client.A5w line:23
    x_Visaclient = a5w_run_Component(tmpl_Visaclient)
    Property not found 
    editProps.number_of_insert_rows subelement not found.
    What can be causing this error?

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

    Default

    You're going to have to open the A5W page and look at line 23, then see where "editProps.number_of_insert_rows" comes from, and figure it out. If you have altered the Xbasic in the grid, or elsewhere, try creating a virgin grid and A5W page without those alterations (other than the filter described earlier in this post). The filter is not causing this error. Make sure you periodically publish ALL files, don't rely on that checkmark to publish files that have changed, etc. Alpha Web Server cannot find some portion (element) of the grid.
    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)

  6. #6
    Member
    Real Name
    Aijaz Ahmed
    Join Date
    Mar 2006
    Posts
    31

    Default

    You are right the error is gone after i republish the files without the new or changed files checkmark.

    but the syntax i inserted in the validate record event does,nt seem to work record adds but the feild in table is not updated, below is what i inserted

    Code:
    function BeforeValidateNewRecords as v (DataSubmitted as P, Args as p, PageVariables as p)
    with PageVariables
    DataSubmitted.vt_clnt=session.userid
    end with
    end function
    Both my Feild and session variable are charactor type.

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

    Default

    Did you "Also, place your userid in the grid as a text box, but as a hidden column." as suggested below?
    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)

  8. #8
    Member
    Real Name
    Aijaz Ahmed
    Join Date
    Mar 2006
    Posts
    31

    Default

    Yes my table field vt_clnt is already present in the grid component as hidden row.

    Do i need to add my session variable also to the grid? if yes how will i achieve that?

  9. #9
    Member
    Real Name
    Aijaz Ahmed
    Join Date
    Mar 2006
    Posts
    31

    Default Help Please....

    I think i am loosing my session variable inside the grid component.It remains available outside grid component

    Below is the error i get inside the grid events ( Zoom interactive window)

    ?session.userid
    ERROR: Not found
    session not found.

Similar Threads

  1. Add a variable textbox field to grid component?
    By rjonas in forum Alpha Five Version 7
    Replies: 4
    Last Post: 02-13-2006, 11:05 AM
  2. Grid component field validation (date field)?
    By Hansolo in forum Web Application Server v7
    Replies: 4
    Last Post: 01-26-2006, 11:21 AM
  3. Updating record with a new field
    By Mark Williams in forum Alpha Five Version 7
    Replies: 3
    Last Post: 12-17-2005, 05:17 PM
  4. Calculated field in grid component: refresh ?
    By mronck in forum Web Application Server v7
    Replies: 0
    Last Post: 11-19-2005, 12:37 PM
  5. Updating parent grid after changing child grid
    By Howard G. Cornett in forum Web Application Server v6
    Replies: 3
    Last Post: 08-30-2005, 04:09 AM

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
  •