Announcement

Collapse
No announcement yet.

Call a form for a specific entry.

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

  • Call a form for a specific entry.

    Hello folks,

    Can we call a form for a specific entry in the database by providing the where condition to the sql request? It seems to be possible for the grids with the sc_select_where macro (even if it's still not clear how to do it for me), but can we do the same with forms?

    Here are some details about what I'd like to do (but I've also others places where I'd like to do things like this):

    I have a form called "people" wich refer to a mysql database containing a table for peoples and a sub-table with some details with a master/details relationship.

    When I create a new people, I need to perform some specific task like creating new entries in the details table. To do this, I removed the standard "New" button and replace it with one of mine with some dedicated php code that I can summary like this :

    $mydate=('Y-m-d');
    sc_begin_trans();
    $sql="INSERT INTO people ('Name') VALUES ('???')";
    sc_exec_sql($sql);
    $People_ID=mysql_insert_id();
    sc_commit_trans();
    sc_begin_trans();
    $sql="INSERT INTO peoples_details ('People_ID', 'Date') VALUES ('" . $People_ID . "', ' . $mydate . ')";
    sc_exec_sql($sql);
    sc_commit_trans();
    [global_peopleid] = $People_ID;
    sc_redir(new_people);


    Currently the solution that I use is that I made a copy of "people" form into a "new_people" form and I've added in the WHERE condition : "People_ID = [global_peopleid]". Then I have a "onValidate" event on the new_people form wich do a sc_redir(people).

    I'd like to use only one form, replacing the 2 last lines of my script by something like :
    sc_redir(people, "where_contion");

    Tanks for your help.

  • #2
    Originally posted by pompon2 View Post
    Hello folks,

    I'd like to use only one form, replacing the 2 last lines of my script by something like :
    sc_redir(people, "where_contion");

    Tanks for your help.
    This is possible. Because the variables you put after the redir will become available as global variables in the called application.

    So it would be something like:

    sc_redir(people.php, glob_where='where myconditioin');

    in your people.php you can refer to [glob_where].
    Albert Drent
    aducom software netherlands
    scriptcase partner, reseller, support and (turn-key) development
    www.scriptcase.eu / www.scriptcase.nl

    Comment


    • #3
      Thanks aducom,

      But what I'm missing is exactly how can I refer to [glob_where] in people.php to show (select) only the people refered by the ID in [glob_where] ? Is there a macro to specify the where clause and reload the page? I've only found things like sc_where_filter, sc_where_current, sc_where_orig and sc_select_where wich Macro scope seems to be defined only for "Grid" applications.

      I've also tried things like : sc_redir(people.php, glob-where='People_ID = ' . $People_ID . ');
      and set the Where condition of my people.php to : [global_where] but can't reach to make it work correctly because I don't know when to empty the [global_where] variable for the form to becalled with all data the next time.

      Any idea?
      Thanks.

      Comment


      • #4
        In general you can apply the global variable in your sql statement in the sql section. For a grid you can use where [glob_where] For a form you can use the same paradigma in the where input field.

        Sometimes it's tricky where to (re)set your data. You can add a custom button to reset the filter.
        Albert Drent
        aducom software netherlands
        scriptcase partner, reseller, support and (turn-key) development
        www.scriptcase.eu / www.scriptcase.nl

        Comment

        Working...
        X