• Resolved mart08812

    (@mart08812)


    Hi, I am wanting to use the DS fields to pull field data from other forms into a single form. For the most part I need data entered into the other forms from the same user who is working on the currently active form.

    I believe this can be done through the query fields in a DS field however not knowing much about query structure I am not familiar with the parameters or format for the queries.

    Does anyone know if a detailed list of parameters that can be used? For example I need to retrieve the first second or third value a specific user entered into another form. The first form captures the current user id.

    Many thanks!

Viewing 4 replies - 1 through 4 (of 4 total)
  • I don’t really know. But you could try to make a bigger database with all values.

    Plugin Author codepeople

    (@codepeople)

    Hello,

    The option is not as simple. By default the plugin does not store the id of the user that has submitted the form. If you have installed the Developer version of the plugin and activated the “Users Permissions” add-on the plugin will create a new database table with the correspondence between users and submissions, but it is not the only one issue. The plugin stores the collected data in the database as a serialized object, so, you should unserialize the object in the public form after receive it.

    There are multiple libraries in the Internet that you can use to unserialize the PHP objects received, for example:

    https://locutus.io/php/var/unserialize/
    https://github.com/naholyr/js-php-unserialize/blob/master/php-unserialize.js

    Furthermore, there is another alternative, in the forms’ submissions, you can store the data in your own database (more information in the following link: https://cff.dwbooster.com/documentation#third-party-database), and then from the second form, read the data from your database’s table.

    Best regards.

    Thread Starter mart08812

    (@mart08812)

    Sorry I did not mention that I am writing the information from the first field to a separate table. The field includes UID timedate and user values.

    As we cannot access one form information from another easily I am wanting to see if I can use the DS data fields as a way to filter what gets pulled from this table.

    eg sum of userid 1 values in a points column. average value across all users for a certain column. Amazing these kind of things are not accessible natively however I am not a programmer so need to know if there is something that shows me all of variables available and the syntax to use them.

    thanks again

    Plugin Author codepeople

    (@codepeople)

    Hello,

    If you don’t have some knowledges of SQL, will be more difficult to take all the advantage of the “DS” fields.

    Ok, assuming you have a table in the database called “my_table”, with the columns: UID, and result, where the UID is the user’s id, and the result is a number, and you want set a field in the form with the sum of all previous results entered by the logged user. The solution is really simple.

    – Insert a “Hidden DS” field, I will call it: fieldname1
    – The datasource of the fieldname1 will be “User Data”, select the “ID” option for the attribute: “Attribute for Values”, and tick the checkbox: “Display data of logged user”

    The fieldname1 field will contain the ID of the logged user.

    – Insert a “Number DS” field, I will call it: fieldname2
    – Select “database” as datasource, and tick the radio button: “Custom Query”
    – Finally, enter as the database query:

    SELECT SUM(resul) as value FROM my_table WHERE UID=<%fieldname1%>

    and that’s all, the fieldname2 will contain the sum of previous results corresponding to the logged user.

    Best regards.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘DS Query Structure Detailed Parameters’ is closed to new replies.