Using two search applications to access a form

Using two search applications to access a form

In this example we are going to create 2 applications of the "Search" type, and 1 application of the "Form" type.


In the Search type applications, we will use the "customers" and "orders" tables, however, we will select only a few fields from each table and make adjustments to some of them.
To use the tables mentioned above, just create a new project and use the ready project "Samples" in the ScriptCase.

1. We created the first application of the type Search using the table "customers", and we will select only the field "customerid" to be used in the application.



2. Next, we will go to the option "Fields", because we will change the type of the field "customerid" to 'Select' and activate the option "Use Select2".




3. Still on the field's configuration page, let's scroll down a little further to "Lookup Method" to write an SQL code, where we select the 'customerid' and 'companyname' fields from the 'customers' table and sort the records in the 'companyname' field.




4. As the idea is to access the Form by going through 2 applications of the type "Search" beforehand, we will need to redirect the application "search_customers" to "search_orders", through the onValidate event, passing the following parameters below in the sc_redir() macro



5. That done, we will create the second application of the type "Search", where we will use the 'orders' table and make the necessary adjustments. In this case, two fields were selected: 'orderid' and 'employeeid'.



6. With the second application of the type "Search" created, we will adjust the fields to be of the type 'Select', however, different from the previous application, we will not activate the option "Use Select2".



7. In the onScriptInit event, we will define the field 'customerid' as being read-only, using the macro sc_field_readonly (), and then immediately assign the variable $customer, the global variable [customer_id] and then assign it to the field {customerid} the $customer variable.



8. Still in the configuration of the fields, we will write an SQL code where we will pass as a parameter inside the field 'customerid' which is also present in the table 'orders', the variable' customer_id, which was created in the onScriptInit event in the previous step. Below, we can see the code in the Lookup Method of each field:

 

9. That done, we will now create the Form using the 'orders' table. The detail for creating this Form is that we will configure the fields {customerid} and {employeeid} to be of type 'Select', in addition to also enabling the option "Use Select2".





10. After all these adjustments have been made, we will go to the "search_orders" application, and in the "Application Links" option, we will link the application with the "form_orders" that we have just created.
 
- In the side menu of the application, we select the option "Application Links":


- As no link was created, we click on "Click Here" to create a new one:

- We leave the option "Application Link" checked


- We selected the application "form_orders":


- According to the settings we defined earlier, everything will already be set up correctly, just confirm to complete the connection:


- We click on Save, and the link will be created:


11. We run the "search_customers" application for it will be redirected to "search_orders", which will later be redirected to "form_orders", as we defined in the previous step.

- We define the search parameter, and then "Customerid":



- We define the filter for the fields {orderid} and {employeeid}:



- Soon the Form will be executed with the records according to the filters previously defined:



    • Related Articles

    • Using tags in the grid search

      When we are using the search in the Grid applications, we can enable the display of the tags for the searched values. This option can be adjusted in the Advanced Search settings. Enable the option Display tags. Then run the application and access the ...
    • Using tags in the Chart search

      When we are using the search in the Chart applications, we can enable the display of the tags for the searched values. This option can be adjusted in the Advanced Search settings. Enable the option Display tags. Next, run the application and access ...
    • Filter on Form Aplication

      This application filters data that will be displayed on editing forms. This type of application necessarily works linked to a form.  The table used to create this application must be the same as the one used to create the form. In this article we ...
    • Project Search

      The Application Search option is ideal for large projects, which contain many applications. With this search tool it is possible to search among the applications created in Scriptcase from a word. 1. To access the application search, go to the menu ...
    • Using inline buttons in the Advanced Grid Search

      When you are using the advanced filter in Grids you can configure the button display mode. In order to do this, you must access the Advanced Search toolbar, as shown below. On the toolbar configuration screen, enable the Use buttons inline option. ...