Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

I want to populate RITM and REQUEST number to Survey questions when somebody took the survey by Survey Link in email. I have created a Survey Wizard and it is public.

Chandresh
Tera Guru

I have created a Survey Wizard and in that I have created two fields Request Number and RITM Number. I want that when somebody takes the survey bu clicking on survey link present in survey mail. Request Number and RITM should auto populate with corresponding data.

1 ACCEPTED SOLUTION

geoffcox
Giga Guru

Your survey email notification can include various parameters which can be used to populate fields on the survey form. In my example below, we are prepopulating the change request field on a survey form.



<a href="https://<mail_script>template.print(gs.getProperty('instance_name'));</mail_script>.service-now.com/survey_take.do?sysparm_survey=Environment%20Build%20Customer%20Satisfaction%20Survey&sysparm_survey_update=false&change_request=${number}">Take Survey</a></p>



Now I just have to remember where I processed that parameter...


View solution in original post

7 REPLIES 7

geoffcox
Giga Guru

Your survey email notification can include various parameters which can be used to populate fields on the survey form. In my example below, we are prepopulating the change request field on a survey form.



<a href="https://<mail_script>template.print(gs.getProperty('instance_name'));</mail_script>.service-now.com/survey_take.do?sysparm_survey=Environment%20Build%20Customer%20Satisfaction%20Survey&sysparm_survey_update=false&change_request=${number}">Take Survey</a></p>



Now I just have to remember where I processed that parameter...


Hi Geoff,



I guess, Parameter 2 contains the sysid of the task. Can you advice me how to fetch the data in RITM number in number field in Survey question.



Mark Stanger   Hello Mark, Can you advice on this?


Know Your Expert | Pradeep Sharma Can you share your inputs on above requirements?


Subhajit Das Hi Subhajit, Could you help me out in above requirement?


mguy Hi Marc, Could you help me in above requirement?


Put the values in the URL as I have shown above. Then your wizard client script can retrieve them from the url:



var change_request = url_param('change_request');



function url_param(name) {


      name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");


      var regexS = "[\\?&]" + name + "=([^&#]*)";


      var regex = new RegExp( regexS );


      var results = regex.exec( window.location.href );


      if ( results == null ) {


              return "";


      } else {


              return results[1];


      }


}