Anonymous surveys not anonymous until submitted

JohanH
Tera Contributor

Hi!

Ive noticed that if an anonymous survey is being saved and not submitted the selections/answers made by the user are not anonymous at that point in time. 

Only when the user submit its being anonymized e.g. the guest user is being assigned.

Question - could anything be done to avoid the exposure during first save until submit?

Regards

Johan

1 ACCEPTED SOLUTION

Shubham_Jain
Mega Sage

@JohanH 

 

Save Responses as Anonymous by Default: One approach is to modify how the survey responses are saved. You can configure the save operation (or create a custom business rule) to assign the guest user as soon as the survey starts, ensuring that any saved answers are anonymous from the beginning.

Here's what you can do:

  • Create a Business Rule on the table where survey responses are stored (e.g., asmt_assessment_instance for surveys).
  • Use the business rule to set the sys_created_by or any user-related fields to 'guest' when a response is saved, before it is actually submitted.

Example Business Rule (before insert/update):

 

 

(function executeRule(current, previous /*null when async*/) {
    // Check if the survey instance is saved but not yet submitted
    if (current.state == 'in_progress' && !current.submitted) {
        // Assign the guest user to anonymize the response
        current.sys_created_by = 'guest';
        current.sys_updated_by = 'guest';
    }
})(current, previous);

 

 

This way, even if the user saves the survey without submitting, the answers are immediately assigned to an anonymous user.

✔️ If this solves your issue, please mark it as Correct.


✔️ If you found it helpful, please mark it as Helpful.



Shubham Jain


View solution in original post

3 REPLIES 3

Shubham_Jain
Mega Sage

@JohanH 

 

Save Responses as Anonymous by Default: One approach is to modify how the survey responses are saved. You can configure the save operation (or create a custom business rule) to assign the guest user as soon as the survey starts, ensuring that any saved answers are anonymous from the beginning.

Here's what you can do:

  • Create a Business Rule on the table where survey responses are stored (e.g., asmt_assessment_instance for surveys).
  • Use the business rule to set the sys_created_by or any user-related fields to 'guest' when a response is saved, before it is actually submitted.

Example Business Rule (before insert/update):

 

 

(function executeRule(current, previous /*null when async*/) {
    // Check if the survey instance is saved but not yet submitted
    if (current.state == 'in_progress' && !current.submitted) {
        // Assign the guest user to anonymize the response
        current.sys_created_by = 'guest';
        current.sys_updated_by = 'guest';
    }
})(current, previous);

 

 

This way, even if the user saves the survey without submitting, the answers are immediately assigned to an anonymous user.

✔️ If this solves your issue, please mark it as Correct.


✔️ If you found it helpful, please mark it as Helpful.



Shubham Jain


Thanks!

That sounds like a good approach! I had one other idea as well and that is to remove the save-button from the survey-widget. Thanks for the input/help!

Johan 

@Shubham_Jain @JohanH 

How would you identify if it is your survey if you cover the assigned to field once it’s saved? It’ll all be guest user and won’t be able to recall the survey?