No announcement yet.

[SOLVED] Return to current record after insert

  • Filter
  • Time
  • Show
Clear All
new posts

  • [SOLVED] Return to current record after insert

    Hi All,
    I have created a Master/Detail application. When loading the application, I have set SQL sort order to 'inserted date - desc' so it always shows the most recent record.

    Problem I am facing now is, after insert of a record it goes to the beginning of the records rather than returning to the last record inserted. So then I have to click on 'First' (<<) button to go to the last record to enter remaining data in detail form. Is there anyway to return to the last record after insert?

    If I change the sql sort order to 'inserted date - asc' then there is no issues after insert as when it return to the beginning it will be the last record. Then every time I load the form I have to click on 'Last' (>>) button to view the most recent record.

    Anyone has any idea for this?
    Thank you.

  • #2
    Perhaps the following work-around will work. Create an even onafterinsert and do a sc_redir to the same application. It might be necessary to do a sc_committrans before to save the current data into your database.
    Albert Drent
    aducom software netherlands
    scriptcase partner, reseller, support and (turn-key) development /


    • #3
      Great, worked well. Thanks Albert.


      • #4
        Just in case anyone needs it ...
        We have found that some end users need to return to a list view straight after inserting or deleting a form record
        Default behavior is something like this
        • Grid view
        • Insert record
        • Save record
        • New blank record created
        Sometimes this new blank record confuses -- although power users like it
        By changing a setting in the form => Application=>Navigation pane you can get it to go like this
        • Grid view
        • Insert record
        • Save record
        • View saved record
        In our current project what we needed was
        • Grid view
        • Insert record
        • Save record
        • Back to grid
        and similar for delete

        Here's what worked for us. Haven't tested it extensively
        * Sometimes end users don't like SC offering a new blank session after an insert 
        * or a another record to delete following a delete.
        * This workaround returns the user to a list view immediately after a new insert or delete 
        // OnApplicationInit
        // Mark the record if this is a new load
        [session_inserted] = False;
        [session_deleted] = False;
        // onLoad
        // Has an insert or a delete just happened?
        if ([session_inserted] ==True || [session_deleted] == True){    
            // Reset flags 
            [session_inserted] = False;
            [session_deleted] = False;
        // Flag if a successful insert
        [session_inserted] = True;
        // onAfterDelete
        // Flag if record has been successfully deleted
        [session_deleted] = True;
        Two new variables are used
        Make sure that both are set in the Global variable space to
        • Input
        • Session