How To retrieve a single row from a subject store

Overview

This ‘How To’ will show you how to use the function ‘dblGetSubjectStoreRow’ that allows you to pull a row from a subject store. The example pulls a book name from a book subject store in your survey.

Note: the dblGetSubjectStoreRow function uses internally the "getTableFromStore" function.

 

Steps for using ‘dblGetSubjectStoreRow’ in your survey

Step 1: Adding the Excel file as a subject store and attach the subject store to the survey

Step 2: Use ‘dblGetSubjectStoreRow’ function to pull the book name from a book subject store

Step 3: Pipe the book name to a certain question

 

Step 1: Adding the Excel file as a subject store and attaching it to the survey

 

  1. Upload the Excel and add it as a subject store. Attach it to the survey (as described here): http://support.dooblo.net/entries/22793802-How-to-use-an-excel-file-as-a-data-list-in-a-survey).

 

Step 2: Use ‘dblGetSubjectStoreRow’ function to pull the book name from a book subject store

 

  1. After loading the Excel to the system and adding it to the survey subject stores, you can use the dblGetSubjectStoreRow function to retrieve a row from the excel using a master key.
  2. For example, if your store name is "Books" and you want to pull the book author of a certain book by the value in the BookID column, you can write the following script:

var row = dblGetSubjectStoreRow("Books","ID",Answer(QRef(1)));

if (row != null) {

SetTextFormat(CurrQues,row["author"]);

}

  1. This will try to pull a book by the ID of the book chosen in question 1. You’ll receive a "row" back that allows you to access the columns as shown in the “author” variable. 

 

Step 3: Pipe the book name to a certain question

  1. Here is a link to our How to pipe text in your survey: http://support.dooblo.net/entries/22810137-How-to-pipe-text-objects-in-you-survey.

  

How to use this example

  1. Import the attached Survey. This is how you import a survey: http://support.dooblo.net/entries/22388573-How-to-import-a-survey
  2. Define the attached Excel file as a subject store. Call it Books. See above how this is done.
  3. Once you added the new store navigate to Q1 and choose the store in the Answers tab
  4. Run it to experience the example

 

That’s it!

Was this article helpful?
3 out of 3 found this helpful
Have more questions? Submit a request

Comments

1 comment
  • I looked for an equivalent function in order to change a value in the Subject Store, based on an answer given in an active survey. Is this possible?

    Regards

Please sign in to leave a comment.