Getting variable from url to string field

perlemmingwittu
Kilo Expert

Hi

OK, I'm pretty new at this, and I am building a survey where I can write a value in a url variable with the survey link and have the survey form pick it up in a string field (preferable read-only).

For instance, a case number:

https://<link to survey>&casenumber=FF012345

I manage to view the field Default Answer in the form by removing the conditions regarding when to apply under "Show and hide default value field", but that just gives me an uneditable empty drop-down field, so I suspect I'm on the wrong track

So "all i need" is to be able to put some magic into that field and have it pick up the casenumber variable. Or another idea.

Best regards

Per

1 ACCEPTED SOLUTION

you can use the sysparm_query property to set the values



https://<instance name>.service-now.com/nav_to.do?uri=incident.do?sys_id=-1%26sysparm_query=priority=1^incident_state=3



you can set this values dynamically from email notification while sending survey like below.



https://<instance name>.service-now.com/nav_to.do?uri=incident.do?sys_id=-1%26sysparm_query=assigned_project_title=${short_description}


View solution in original post

9 REPLIES 9

I'm trying to populate a survey question with an answer however. Not sure how to pass in the data to the answer of the question. Survey's are really like accessing an incident record.


Use the g_form API to set the appropriate field on the form to set the value.




Regards



Hem


Gurpreet07
Mega Sage

Below link explains different ways to get value from url parameter. Further you may need an onLoad client script to set values in field.


3 Ways to Populate Values in ServiceNow via the URL


perlemmingwittu
Kilo Expert

Today I worked my way around this, but it was srnewbie who came up with that I needed first.



I went another way: record producer.



I don't feel that the survey is versatile enough to handle what I require in this particular case unless I wanted to edit the page assessment_take2.do (which I find to be a touch much to complete my mission). It suits many other needs, but apparently not my variable-pick-up stunt. I found a way to make Legacy Survey do what I want (almost), but seeing as how legacy survey will be deprecated in near future, I have skipped it.



So, record producer. With all the fields I need, and easy access to a isolated table and application.


Added to the url for the record producer entry form: %26sysparm_query=SD1236547


String field picking up the value by having a default value: javascript:RP.getParameterValue('sysparm_query');


And the string field is made read-only with a UI policy.



Thank you all for your time and suggestions


Hello,

I am trying to implement your solution.

Could you tell me how you added the URL for the record producer entry form? I am mentioning your line for reference.

"Added to the url for the record producer entry form: %26sysparm_query=SD1236547"