How to re-run prepopulation when login/password value is changed

0

My survey is using a login/password action to prepopulate hidden questions with uploaded data. In my case, the “passwords” are not unique to the respondent, and someone may want to change their password while editing their response or by clicking “Back” to a previous page.

My question is, how can I update the prepopulated fields to reflect a changed “password”? The prepopulation will re-run if I manually remove the prepopulated answer before returning to the password page, so I tried to replicate that action in custom scripting (i.e. before running the login/password action, set the value of the questions to be populated on the next page to be blank). That didn’t work as the questions that should have been prepopulated remain blank. 

Any ideas on how this could be accomplished?

Justin M. edited question
    0

    I actually just emailed support about this same issue, they said that the prepopulated fields will not pre-populate I there is already a value in the place they are trying to populate.

    I was able to get it to work using custom scripting.  When you said that you set them to be blank in your script, did you use blank text…or did you actually set them to be null?  Blank text would be a value, so that would stop the prefill.  Make sure you set to null. 

    Note (250 and 250 are the question IDs of the items I am clearing).

    Just make sure this script is run prior to the login action (place it on the same page as the login action, or on a prior page that anyone who edits their password will hit).

      sgapiSetValue(250, null);

      sgapiSetValue(251, null);

     

    If that doesn’t work, I actually use a script that checks to see if a question that feeds into the login action is answered (at page load), and if it is, then it sets the values pre-populated values to null.  I don’t think you need to get that complicated based on your description – but if you do, here is the script.  I place this on the page where the feeder questions are answered.

     

    If (sgapiIsAnswered (247))

    {

      sgapiSetValue(250, null);

      sgapiSetValue(251, null);

    }

     

    Steve commented
      • Thanks so much. I had tried variations of setting the questions to null, blank, and an empty array. I tried your suggestion again, placing the script above the login/password action, which is on the page directly before the questions to be prepopulated, but I get the same results — the script seems to override the prepopulation altogether, leaving the questions that should have been populated empty. Here’s the script I used (I wrapped it in a loop for efficiency):

        %%prepops = array(48,49,54,55,56,57);
        foreach (%%prepops as %%qId) {
        sgapiSetValue(%%qId,null);
        }

      • Odd. Three other things to look at
        1) Try it without the loop, maybe just clear one question the first time. When a script doesn’t work as expected, I try to break it down into small chunks to see where it breaks.
        2) I don’t know if this matters, but I always put a space before the word null. I’ve not tested it the other way, and I don’t know enough about the syntax of PHP to know if it matters.
        3) What type of question are you filling? I’m typically setting the value of a hidden value or text box. In that case, the syntax of the sgapiSetValue is correct. However, if you are using anything with an array, it needs be used a little differently: ‘10410’ is the option value of the item in the array that is being filled. %%mergeCode is a variable I set previously. In your case the value would be null
        sgapiSetValue(249, array(‘10410’ => %%mergeCode));

        I have not been able to set the value of a cascading drop down. For whatever reason it just won’t stick. I have been able to get it to set the value of a login action (that is actually what you see above).

        I can’t find any documentation that says what question types SetValue works with and what it doesn’t. If you still can’t get it to work, maybe try with a different question type. That will tell you if its your script that doesn’t work, or if it is something to do with the question type you are trying to set.

      ×

      Login

      Question stats

      • Active
      • Views125 times
      • Answers1 answer
      • Followers1 follower