Knowledge Base
  • Introduction
  • Events and Actions
  • Action Panel
  • sending email
  • calling a SQL action from a client side js action
  • Accessing to translations form a server
  • Executing SQL statements from within an action
  • How to invoke a generic SQL statement defined through a SQL action
  • How to show a message dialog
  • checking for "undefined" values
  • How to add spaces to the right of a text
  • How to create a docx report and show it on the web browser Enterprise Edition only
  • How to get or set a value from the graphics control
  • How to invoke a generic SQL query defined through a business component
  • How to remove spaces to the left and right of a text
  • How to support multiple themes in a single application, accoding to a rule
  • How to set content to a Google Map linked to a grid or form
  • How to replace all occurences of a pattern from a text
  • Utility methods
  • Link auto login
  • Creation of a link for the first access of a new user without give the user a password and forcing
  • Forgot password
  • setting up default values from values coming from a filter panel
  • identifing the modified record after the alteration
  • enabling/disabling checkboxes in a grid
  • Filtering a Lookup
  • formatting a column
  • using checkboxes to select rows in grid
  • showing a summary row in grid
  • Disabling a toolbar button
  • Configuring grid exports
  • Adding filter conditions to a grid
  • Filtering the grid content from a tree
  • Filtering the tree content, starting from a filter panel linked to a grid
  • collapsing a panel
  • validating a lookup
  • accessing the authorizations set for a specific grid
  • How to design a web service
  • How to remotelly invoke an action or business component or perform a write operation through a Restf
  • how to feed a grid from a JS business component
  • converting a JS object to a JSON string
  • executing a query
  • passing parameters to a server side JS action
  • return value
  • scheduling and frequency
  • finding the right filter panel
  • checking out if a component has been defined
  • Deploying an application
  • Enquiring a table belonging to the Platform repository
  • Adding a where clause to a business component linked to grid
  • Integrating Mailchimp lists
  • Formatting a number as a currency value to use it inside an email template
  • sending email from a template
  • How to send an email
  • Error 'smtpHost' is empty
  • Linking two windows
  • How to open manually a window from another window
  • How to open manually a popup window
  • How to hide a panel in a window dinamically
  • How to manage folder panels
  • How to manage card panels
  • Predefined variables supported by Platform
  • Accessing the application parameters
  • Application Log
  • How to design a web service
  • How to import java classes in server
  • How to import java classes in server
  • How to dynamically set a value on a combo
  • 4WS.Platform
  • How to listen to events in a mobile HTML panel
  • Issues with HTTPS requests
  • How to manage row totals in grid
  • How to send to the UI a notification to execute code automatically
  • How to filter a chart by date interval
  • How to filter a grid by date interval
  • How to read a text or csv file and save data on the database
  • How to write text or csv files
  • Reading an xls file stored in the specified path
  • How to create a report with Jasper Report
  • How to customize the alert message content
  • Setting up a cluster
  • Uploading and downloading files
  • How to listen to user definition changes
  • How to auto-show a window from login
  • How to manage encrypted fields
  • How to change CSS settings for a grid row
  • Customizing a Tree Panel
  • How to execute complex queries on Google Datastore
  • Theme customization
  • Retrieve and send the log of a mobile app
  • Import Roles and Users
  • How to synchronize multiple Form panels in the same window
  • Anchor buttons
  • Properties of subpanels
  • Bulk import
  • How to display the data not found message in a grid
  • How to setup an LDAP based authentication
  • How to synchronize data from Datastore to BigQuery
  • How to synchronize data from Datastore to Google Spanner
  • How to synchronize data from Datastore to CloudSQL
  • Scrollable form list
  • How to setup SAML authentication
  • How to export data from BigQuery in streaming
  • Update Google Spreadsheet
  • How to setup OAuth2 authentication
Powered by GitBook
On this page
  • Filtering encrypted codes
  • Filtering encrypted data

Was this helpful?

How to manage encrypted fields

Platform can manage text type fields as encrypted fields. In order to set them, you have to change the default field type for a data model field, from its original value (text) to the new one: Encrypted Text.

When saving a record containing an encrypted field, these fields are encrypted along with the rest of the record, just before saving them.

Writing operations are automatically performed by Platform, when using the standard insert/update operations in a grid or form.

When the writing operation is carried out manually, without using the standard web services, i.e.within a server-side javascript action, it is up to the programmer to use the utils.encodePassword method.

Important note: when designing the database table hosting the encrypted value, bear in mind that the encryption algorithm can convert the original text in a new text having a longer length. Consequently, do not let the end user to fill in the whole field length, since it could be not possibile to save all of it, when encrypted (e.g. if a field is 255 chars length, it would be better to let the user to fill in up to 200 chars).

Important note: if you need to encrypted non text values, like dates or numbers, please note that they are always converted to a text, since the encryption algorithm always save data as a text. Consequently, you have to design your database with text type fields for dates/numbers, if you want to save them as encrypted data.

Reading operations of encrypted data is automatically managed by Platform, when using the standard business components for grid or form with SQL. It means that Platform would read encrypted data form the table, decrypt it and pass plain text to the UI.

If you do not use the standard Platform components, it is up to you to decrypt data, in a javascript business component of server-side javascript action, using the utils.decodePassword method.

Filtering encrypted codes

Once data has been encrypted, you cannot filter part of it, since the whole text has been converted in something completely different.

Consequently, the only filtering operator you can still apply is the equal, since you can only search for exact (case-sensitive) matching between the search pattern you wrote and te whole value saved encrypted in the database table.

For example, if you have a CLIENTS table containing a CLIENT_CODE encrypted field, you have to:

  • change the operator from "Like" to "Equals" for the encrypted CLIENT_CODE field in the filter panel

  • activate the "Uppercase" flag for the encrypted CLIENT_CODE field in the filter panel

  • save CLIENT_CODE in grid/form always in upper case (i.e. activate the "Uppercase" flag for the encrypted CLIENT_CODE field in the gird/form panel where it is allowed to save data)

In this way, the filter field would allow to specify the whole code, always expressed in upper case and Platform behind the scenes would encrypt that value when searching data and can successfully compare the value with the ones saved in the table.

A wrong setting would be to apply a "like" operator or case-insensitive settings: it would not work, since it is impossible to search for part of a text, if it has been encrypted.

Filtering encrypted data

Once data has been encrypted, you cannot filter part of it, since the whole text has been converted in something completely different.

Consequently, the only filtering operator you can still apply is the equal, since you can only search for exact (case-sensitive) matching between the search pattern you wrote and te whole value saved encrypted in the database table.

A more complex scenario is when the encrypted text to search for is not a code, but something more complex like a corporate name, when not all text is specified (no exact matching) and the search condition is case-insensitive.

Such a scenario, as reported above, is not possible, since the original text has been replaced by an encrypted one which cannot be compared only in part, but only as it is: the whole case-sensitive text.

A workaround which can be applied in such a scenario is adding a second text plain field, which contains the first part of the encrypted text in uppercase. For example, if you have a CLIENTS table containing a CORPORATE_NAME encrypted field, you have to:

  • add another text field PLAIN_CORPORATE_NAME in the database table, hosting for example the first two letters (in uppercase) of the original corporate name, saved in plain text (no encrypted)

  • use "before saving on insert/update" event in the grid/form used to save data and link a client-side javascript action, whose purpose is to automatically fill in the PLAIN_CORPORATE_NAME hidden field, starting from the CORPORATE_NAME value: only the first two letters are saved and in uppercase; in this way, PLAIN_CORPORATE_NAME and CORPORATE_NAME are always aligned with each other

  • show a filter field for PLAIN_CORPORATE_NAME and let the "Like" operator for it

  • activate the "Uppercase" flag for the PLAIN_CORPORATE_NAME field in the filter panel

  • add a "before search" event where replacing the value provided by the end user and cut it to up to two characters.

In this way, the filter field would allow to specify the whole text, part of it, two characters only or less than that: the "before search action" always cut that pattern to up to 2 characters expressed in upper case and Platform behind the scenes would search data in the plain text field instead of the original one.

Example of "before saving on insert/update" action content for a grid:

var sels = grid9.getSelectionModel().getSelections(); // get all changed rows
if (sels!=null) {
    for(var i=0;i<sels.length;i++) { 
        // for each row, fill in the "plainCorporateName" field
        // starting from the "corporateName" value provided by the end user
        var sel = sels[i];
        var descr = sel.get('plainCorporate');
        var len = descr.length;
        if (len>2)
          len = 2;
        sel.set("plainCorporateName",descr.substring(0,len).toUpperCase());        
    }
}

Example of "before saving on insert/update" action content:

var value = getFilterValue("plainCorporateName");
if (value!=null) {
  if (value.length>2)
    value = value.substring(0,2);
  changeFilter("plainCorporateName","like",true,value);
}

Here two utility methods are used:

  • getFilterValue(filterName) - it returns the value of the filter field identified by "filterName"; it returns null if not found/not filled

  • changeFilter(filterName, filterOp, filterCaseSensitive, filterValue) - it replaces the filtering conditions for "filterName" (if found and not empty), by replacing them with the new values provided as argument: filterOp, filterCaseSensitive, filterValue

PreviousHow to auto-show a window from loginNextHow to change CSS settings for a grid row

Last updated 4 years ago

Was this helpful?