PreQuery, PostQuery & Server Side Validation

In this lesson, you will learn how to define PreQuery, PostQuery & Server Side Validation scripts for a Data Source. Please refer to the Pre QueryPost Query & Serverside Validation help articles to learn more about these.

  • Now to add an 'Active' column in the table( OE_ORDER_HEADERS_ALL).
  • For that you need to Execute this in the SQL Query Browser - ALTER TABLE OE_ORDER_HEADERS_ALL ADD ACTIVE VARCHAR2(1);


  • Now goto the data source that is associated to this table in the platform.( Navigation → Developer → Data source list)
  • Click on the data source.

  • Enable Sync and click on save button.
  • The Active field will be added as attribute to the data source.
  • Now specify the Default value, Primary Key field and enable the Auto Sequence property.
  • Since EmployeeDetails data source and EmployeeGeneratedScreen data source are pointing to the same Table, specify the same default value as of EmployeeDetails datasource.
  • Now create two fields 'Active Text' and 'Flag' as calculated columns in the data source by clicking on Add new attribute button.
  • Click on 'Active Text' field and uncheck the Select Allowed, Query Allowed, Export Allowed in the Attributes details panel which is at the bottom.
  • Similarly do it for 'Flag'.

  • Now go to page where this data source is specified.
  • Click on Grid and click on New button on Page Layout header.
  • A new child will be created and now select the item type as check box from the property pallet.
  • Specify the field label as Active.
  • Create one more child to the grid which is a button.
  • Name it as Pre Query.
  • Below the button create a button action as "Action Query" and specify the data source(OrderScreenAuto).
  • Create child to the "Action Query" and set the data as in image.


  • Click on save button.


  •  Now go to the OrderScreenAuto data source and click on PreQuery Script tab. 
  •  Write the prequery.

  • Click on save button.
  • Go to preview page and  go to the Employee Generated Screen page. 
  • Click on Search button.
  • By default all the rows are displayed.
  • Now Enable the Active field Check box for Christian and Jessy and click on save, in this case which means they are the active Purchase Orders.
  • Then Click on Prequery button.
  • This means that, the Active Purchase Orders alone are to be displayed. 
  • This is how the Query is appended in the Sql Query. To See the query goto File → Administration → Examine Recent SQLs.

  • First query is performed when Pre Query button is clicked.
  • Second query is by default performed, when you click on search button.
  • The output on the query  looks as below.

Post Query:

  • In the similar way, goto datasource and click on the Post Query Script.
  • Write the Post Query over here and save it.

  • Goto the Employee Generated Screen.
  • Then goto customize page.
  • Click on the Grid( Employee Details) and click on New button on the page layout.
  • A new child item will be populated and now select the item type as text field.
  • Specify the view attribute as "Active Text" and field label as Active Text.
  • In this case, it is to return text saying 'Active Users' if users are active user or else as non-active user.
  • As there is a "Active Text field", this is being used to set the post query returned value into it.
  • This is how the output looks like.

Serverside Validation:

  • Go to the data source page and enter the Serverside validation script.
  • Click on save. 
  • Here validation is written against the "After Insert" property.

    Note: You can fire the Servervalidation on either of these: 'Before Insert','Befor Update','After Insert','After Update'.

  • So it executes after a record gets inserted into that table.
  • Now goto the page 'EmployeeGenerateScreen'.

This is how the output looks like.


101 California Street, Suite 2710
San Francisco, CA 94111

440 N. Wolfe Rd.
Sunnyvale, CA 94085

Office 11, 5th Floor, Building 9,
Mindspace IT Park
Hyderabad 500081

p: +1 (844) AT CloudIO (844-282-5683)
f: +1 (650) 300-5247 | e:
© 2009, 2017 CloudIO Inc. | Terms of Use | Privacy Policy