Survey URL is redirecting to csm_login page instead of survey portal page


Description

User tried to reach user survey URL by clicking the link from the received email and it is getting redirected to csm_login page instead of survey page.

Cause

  1. 1.Validate the survey URL received over the email, check if it is going via public page which is public_survey or not.
    • Non-problematic survey URL: /portal_est?id=public_survey&instance_id=b6f744dc1bcf1418f3944226cc4bcb46
    • Problematic survey URL: /nav_to.do?uri=assessment_take2.do%3Fsysparm_assessable_type=a33924dddb296f088d2e9e04db96190d%26sysparm_assessable_sysid=ac0de0e41b4fdc18f3944226cc4bcb13
  2. Validate does the public_survey is set to public or not.
  3. Validate the  status of system property "sn_portal_surveys.sp_survey.email_redirection".
    • When Yes is selected, a survey accessed from a link in an email opens in the Service Portal.

Resolution

Script include which is responsible to return the survey URL is returned incorrect survey URL based on the script conditions.

Script include - AssessmentUtils has a function - getAssessmentInstanceURL is responsible to populate the URL.

// Survey Instance Table URL
getAssessmentInstanceURL: function( /* String */ instance) {
  var gr = new GlideRecord("asmt_assessment_instance");
  var type = '';
  if (gr.get(instance)) {
    var asmtRec = new GlideRecord("asmt_metric_type");
    asmtRec.addQuery("sys_id", gr.getValue("metric_type"));
    asmtRec.query();
    if (asmtRec.next())
      type = asmtRec.getValue("sys_id");
  }
  var instanceURL = gs.getProperty("glide.servlet.uri");
  var overrideURL = gs.getProperty("glide.email.override.url");
  var url = "";
  if (this.redirectToPortal() == 'true') {
    if (asmtRec.allow_public)
      url = instanceURL + this.defaultServicePortal + '?id=public_survey&instance_id=' + instance;
    else
      url = instanceURL + this.defaultServicePortal + '?id=take_survey&instance_id=' + instance;
  } else {
    if (overrideURL)
      instanceURL = overrideURL;
    else
      instanceURL = instanceURL + "nav_to.do";
    url = instanceURL + '?uri=assessment_take2.do%3Fsysparm_assessable_type=' + type + '%26sysparm_assessable_sysid=' + instance;
  }

  return url;
},

The AssessmentUtils script include has two if conditions, if none of the portal is set to default true then it will go to else statement and return the URL which always requires login.

url = instanceURL + '?uri=assessment_take2.do%3Fsysparm_assessable_type=' + type + '%26sysparm_assessable_sysid=' + instance;

In order to overcome this issue validate the system property "sn_portal_surveys.sp_survey.email_redirection" it should be set to true and validate the "sp_portal", one of the portals should be set to default under the sp_portal.list.