Alpha Video Training
Results 1 to 9 of 9

Thread: AfterUpdateRecords vs AfterUpdateRecord - Need one that fires after everything is done

  1. #1
    "Certified" Alphaholic
    Real Name
    Scott
    Join Date
    Mar 2010
    Location
    Toronto,ON
    Posts
    1,031

    Default AfterUpdateRecords vs AfterUpdateRecord - Need one that fires after everything is done

    Hi everyone,
    I am looking to run some code after all the records in the grid have been updated.

    Some background:
    Users will use a Grid component to complete activities. When all activities are Completed I need to prompt the user if they would like to email out the report to their client.
    Multiple rows can be edited at once.


    The issue:
    AfterUpdateRecord will fire once for every row submitted - so they are prompted to send the report multiples times.

    AfterUpdateRecords only fires when the submit button is clicked - and not when an individual row is updated.

    Is there a grid event that fires only once after all work is done? The onAfterSQLCommandExecute also seems to fire multiple times.
    I think I may have to resort to one of the client side after events, however, I would prefer not to do this in order to try and save round trips to the server.

    Any help is appreciated.
    Scott Moniz - Computer Programmer/Analyst
    REA Inc.
    http://reainc.net
    (416)-533-3777
    scott@reainc.net

    REA INC offers consulting services, programming services, systems design, database design, third party payment gateway integration (CHASE, PAYPAL, AUTHORIZE.NET) and developer support.
    If you need custom code, or 1-to-1 mentoring in any facet of your database/web application design,
    contact us to discuss options.

  2. #2
    "Certified" Alphaholic
    Real Name
    Frank Bicknell
    Join Date
    Feb 2010
    Location
    39.1915° N, 84.4348° W
    Posts
    2,467

    Default Re: AfterUpdateRecords vs AfterUpdateRecord - Need one that fires after everything is done

    I have not used that event for a while but wonder if there is some information in the e parameters that indicates the number of rows that need updating. Then you might be able to count the loops or something. Just a thought.
    Win 10 64 Development, Win 7 64 WAS 11-1, 2, Win 10 64 AA-1,2, MySql, dbForge Studio The Best MySQL GUI Tool IMHO. http://www.devart.com/dbforge/mysql/studio/

  3. #3
    "Certified" Alphaholic
    Real Name
    Govindan Gandhi
    Join Date
    Aug 2008
    Location
    New York, NY
    Posts
    4,294

    Default Re: AfterUpdateRecords vs AfterUpdateRecord - Need one that fires after everything is done

    i do not know if there is a function that will trigger an event to do what you want to do, but you can bend your customers to press the submit button when all editing is done by
    "turning off individual records can be saved" option in the update properties.
    my feeling is when individual records are saved the singular afterUpdateRecord fires off and only submit button is designed to respond with the pleural afterUpdateRecords.
    by turning this off you are limiting the combinations, like the way you described.
    thanks for reading

    gandhi

    version 11 3381 - 4096
    mysql backend
    http://www.alphawebprogramming.blogspot.com
    ggandhi344@gmail.com
    Skype:ggandhi344@gmail.com
    1 914 924 5171

  4. #4
    Banned
    Real Name
    David Kates
    Join Date
    Apr 2008
    Location
    Unionville, ON
    Posts
    7,819

    Default Re: AfterUpdateRecords vs AfterUpdateRecord - Need one that fires after everything is done

    Your question may provide a clue to the answer...

    Is there a grid event that fires only once after all work is done?
    How you do know when all work is done?

  5. #5
    "Certified" Alphaholic
    Real Name
    Scott
    Join Date
    Mar 2010
    Location
    Toronto,ON
    Posts
    1,031

    Default Re: AfterUpdateRecords vs AfterUpdateRecord - Need one that fires after everything is done

    Hi GGandhi, unfortunately turning single row edits off is not an option.
    Scott Moniz - Computer Programmer/Analyst
    REA Inc.
    http://reainc.net
    (416)-533-3777
    scott@reainc.net

    REA INC offers consulting services, programming services, systems design, database design, third party payment gateway integration (CHASE, PAYPAL, AUTHORIZE.NET) and developer support.
    If you need custom code, or 1-to-1 mentoring in any facet of your database/web application design,
    contact us to discuss options.

  6. #6
    "Certified" Alphaholic
    Real Name
    Scott
    Join Date
    Mar 2010
    Location
    Toronto,ON
    Posts
    1,031

    Default Re: AfterUpdateRecords vs AfterUpdateRecord - Need one that fires after everything is done

    Hi David,
    All work would be done when all records to be processed are complete. However, I am not sure if there is an event that represents this.
    AfterUpdateRecords fires when submit button is pressed
    AfterUpdateRecord fires for each row so in the case where multiple are edited this fires multiple times
    onAfterSQLCommandExecute fires once per row being changed

    None of these seem ideal and I was looking for something like 'AfterRecordsProcessed' that would fire once only regardless of whether it was a submit button press or a single row save, but could not find one.


    I have completed my requirement by hooking into both the afterGridSubmit and afterRowSubmit client side events. I was trying to save another trip to the server by running the code in the server side events but I am not sure if this is possible.


    afterGridSubmit (fires on submit button), afterRowSubmit

    Code:
    if (!e.hasErrors){
       {grid.Object}.runAction('CheckSendVerificationReport'); 'this function calls an action that does an ajax callback to check conditions
    }
    Thank you all for your input!
    Scott Moniz - Computer Programmer/Analyst
    REA Inc.
    http://reainc.net
    (416)-533-3777
    scott@reainc.net

    REA INC offers consulting services, programming services, systems design, database design, third party payment gateway integration (CHASE, PAYPAL, AUTHORIZE.NET) and developer support.
    If you need custom code, or 1-to-1 mentoring in any facet of your database/web application design,
    contact us to discuss options.

  7. #7
    Banned
    Real Name
    David Kates
    Join Date
    Apr 2008
    Location
    Unionville, ON
    Posts
    7,819

    Default Re: AfterUpdateRecords vs AfterUpdateRecord - Need one that fires after everything is done

    All work would be done when all records to be processed are complete. However, I am not sure if there is an event that represents this.
    There can't be an event that "knows" when all records are complete, although that'd be a pretty sweet AI event. You're looking for something to tell you when everything is done, but you're not defining what "done" is.

    What is "done" for a record... for all records? All fields filled in? Something specific set in each record indicating the record is complete? And for how many rows?

    Do you know the count of rows needing to be completed? If so, as each record is updated (if that's what completed means) then add to a grid namespace variable.

    Create that namespace variable when the grid is rendered... on the client side.

    Code:
    {grid.Object}.__rowsCompleted = 0;
    As each row is "completed", maybe in AfterUpdateRecord, return a javacsript function that will increment this "row updated" counter...

    Code:
    dim aa as p
    aa = e.rtc.A_AjaxResponses
    aa[].text = "checkCompletedRows();"
    aa[..].id = 100
    The javascript function would be...

    Code:
    function checkCompletedRows(){
    
    	{grid.Object}.__rowsCompleted++;
    	alert({grid.Object}.__rowsCompleted);
    
    }
    Put your logic in here to detect all rows completed and fire off the email.

  8. #8
    "Certified" Alphaholic
    Real Name
    Scott
    Join Date
    Mar 2010
    Location
    Toronto,ON
    Posts
    1,031

    Default Re: AfterUpdateRecords vs AfterUpdateRecord - Need one that fires after everything is done

    Hi David, Thanks for your input. That event would be pretty nice to have and I think it could be accomplished by having the AfterUpdateRecord function fire the AfterUpdateRecords function.
    In this manner regardless of whether you use the Submit button or a single row edit the AfterUpdateRecords event would still fire. Do you know of a way to programatically fire an event event from AfterUpdateRecord? I swear I remember seeing this somewhere.

    With regards to rows completed I am unsure of whether this approach would work because I do not know the count of records to be updated (maybe there is a rowsDirty counter in the e.tmpl objects - not sure? Ill have to look into this).

    Anyways, although not ideal in my eyes, the current client side approach handling the afterGridSubmit and afterRowUpdate seems to work fairly well.

    I'd like to thank you for your time - and I highly appreciate your input.
    Scott Moniz - Computer Programmer/Analyst
    REA Inc.
    http://reainc.net
    (416)-533-3777
    scott@reainc.net

    REA INC offers consulting services, programming services, systems design, database design, third party payment gateway integration (CHASE, PAYPAL, AUTHORIZE.NET) and developer support.
    If you need custom code, or 1-to-1 mentoring in any facet of your database/web application design,
    contact us to discuss options.

  9. #9
    "Certified" Alphaholic
    Real Name
    Govindan Gandhi
    Join Date
    Aug 2008
    Location
    New York, NY
    Posts
    4,294

    Default Re: AfterUpdateRecords vs AfterUpdateRecord - Need one that fires after everything is done

    may be you can tell, what information is being emailed when all the work is done, just list of records or the information that is changed?
    thanks for reading

    gandhi

    version 11 3381 - 4096
    mysql backend
    http://www.alphawebprogramming.blogspot.com
    ggandhi344@gmail.com
    Skype:ggandhi344@gmail.com
    1 914 924 5171

Similar Threads

  1. Script fires regardless of conditional
    By Bill@TrackerSystems.com in forum Alpha Five Version 6
    Replies: 8
    Last Post: 02-19-2005, 07:46 AM
  2. Script fires twice
    By Bill@TrackerSystems.com in forum Alpha Five Version 6
    Replies: 5
    Last Post: 02-06-2005, 12:35 PM
  3. OnRowDblClick fires when?
    By russ Boehle in forum Alpha Five Version 5
    Replies: 6
    Last Post: 04-21-2003, 05:41 AM
  4. CanWriteField script fires three times
    By Daniel Weiss in forum Alpha Five Version 4
    Replies: 1
    Last Post: 03-04-2002, 03:42 AM
  5. CanWriteField script fires three times
    By Daniel Weiss in forum Alpha Five Version 4
    Replies: 0
    Last Post: 03-04-2002, 02:42 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
  •