Return URL for taking Surveys

Justine Garcia1
Mega Expert

Hi

i have a requirement about creating a survey once an incident is resolved. 

the Survey is up and running however I am also asked to make it so that once the Survey is finished, the user will be redirected to the Incident that is associated with that Survey. 

I found that there is a Return URL field in the Survey record. 

it works just fine. However I cant seem to make it into a dynamic URL to the specific incident that is associated with that Survey. 

I have tried several scripts:
/incident.do?sysparm_query=javascript:'number'=current.trigger_id
/incident.do?sysparm_query=number=current.trigger_id
/incident.do?sysparm_query=javascript:'number+'=current.trigger_id

and it still redirects to a different specific record / it states that record is not found. 

If anyone has encountered and found a fix for this any help would be appreciated!

 

Thanks,

Justine

 find_real_file.png
1 ACCEPTED SOLUTION

Justine Garcia1
Mega Expert

So! I shared this issue with my team and one my teammates gave me a solution for it. 
Kudos to @Carl Miguel Bartolome my teammate. Thank you so much for the help! 

I will share it here for other people that might encounter this same issue in the future. 

the objective is that, whenever a survey is completed and closed, the user will be sent back to the incident that is associated with that survey. 

so for the Survey... we realized that the return url field is actually a string field. 
it could not execute javascript code or glide system functions. 

therefor in order to make the return URL dynamic to each record resolved, we created a Business Rule. 

This Business Rule will update the value in the return URL field every time a survey is completed and closed. 
Here is the conditions for the BR to run 
find_real_file.png




And here is the script

(function executeRule(current, previous /*null when async*/) {

// Add your code here
var incidentSysID = current.trigger_id;
var metricTypeSysId = current.metric_type;

var gr = new GlideRecord('asmt_metric_type');
if (gr.get(metricTypeSysId)) {
gr.url = '/incident.do?sys_id='+incidentSysID;
gr.update();
}

})(current, previous);


This way, each time a survey is completed, the BR will update the return url field of the survey and the user will be redirected to the incident that is associated with the survey. 

find_real_file.png


Again thank you very much to my teammate that helped me solve this issue. 

and if you have any other suggestions feel free to reply. Thank you.

View solution in original post

6 REPLIES 6

Allen Andreas
Administrator
Administrator

Hi,

If this field is anything like most other fields in the platform, your format would need to be:

javascript:"/incident.do?sysparm_query=sys_id="+current.trigger_id;

This of course is assuming you've done due diligence and saw that current.trigger_id results in a sys_id.

You can try that and see if it works?

Please mark reply as Helpful/Correct, if applicable. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

It doesnt seem to be like the other fields in the instance. 😕

It doesnt allow me to save it and it shows an error 
This URL must be in the same domain as the instance and must be preceded by a ./ or a /.
find_real_file.pngfind_real_file.png

Hi,

Hmm, you could set that return URL validation business rule to not execute on the specific assessment metric in question and see if it works as I mentioned without that?

Please mark reply as Helpful/Correct, if applicable. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

Yes I did. At one test I even tried deactivating the whole BR. 
while it DID let me save the survey like that.... once i finished taking the survey nothing happened. fortunately the response IS recorded , However once I click the submit  it just turns gray and nothing happens. 
the instance isnt loading or anything. Its broken. find_real_file.png