Prefill form using URL?


I am looking to prefill the email address field on my customer portal using the URL.

The reason for this is that many users from our housekeeping department (not computer literate) use the helpdesk portal to submit tickets regarding maintenance in the rooms. They cannot type the email address correctly and sometimes I end up getting new customers created in the portal because they have typed the email address wrong. So I am looking to create a shortcut on the desktop of the shared computer that prefills the form with the email address. I cannot keep the user logged in because guests also use these laptops.



I tried something like this by using inspect element and trying to find the ID of the email field.

https://mycompany.freshdesk.com/support/tickets/new?helpdesk_ticket[email]=someone@company.com


or


https://mycompany.freshdesk.com/support/tickets/new#helpdesk_ticket[email]=someone@company.com


10 replies

Hi Ryan,


As per the current design, We do not allow pre filling the forms using the URL since we only support REST API.


You could achieve your requirement by using our Feedback widget in which you could pre populate field values. 


You could add the feedback widget code for your account available under Admin -> feedback widget to a local HTML file and update the code to pre populate the email address and save it in the local workstation. When the user access the file, It will load the feedback widget with the email address populated.


Similarly, You could add the code to a different HTML for the next workstation and update the email address for that workstation. 


Please refer to the solution articles for instructions on feedback widget and pre filling feedback widget.


https://support.freshdesk.com/support/solutions/articles/37690


https://support.freshdesk.com/solution/articles/154064-pre-populating-feedback-widget-form





Hi,




I also need to pre-populated my widget but my design can't use the popup feedback widget shown in :


https://support.freshdesk.com/solution/articles/154064-pre-populating-feedback-widget-form




Has the embedded widget been updated to support customization?








Hi Steve,



You can follow the same steps for the embedded widget as well !

















Best Regards,


Thriyam

















I'm looking for the possibility to preset contact info on a ticket form, is this still no possible?

Let me give little more background.

We have a network of stores that open ticket about some other system they use.

I'd like to avoid to ask them to have a new set of credentials for Freshdesk, so the idea would be to allow them to open ticket thru a (possibly) private form, maybe invoked by one of the systems, having contact and company fields preset but allowing them to choose category, subcategory, description, etc.

Any idea?

Thanks in advance.

Alfredo 


Hi, I also need to populate the ticket form via url query string parameters. Is this possible in 2023?

Thanks.

Alex. 

Userlevel 2
Badge +2

Hi @ryan.mcallister,

Welcome to Freshworks Community :)


We do support a prefill for ticket fields as a part of Widget API in the Feedback widget. Refer to the below API documentation for more reference.

1) Prefill Details about your customer: https://developers.freshdesk.com/widget-api/#identify

2) Prefill other Fields: https://developers.freshdesk.com/widget-api/#prefill-fields
 

However, if you are referring to the Ticket form, prefill it inside the portal. In that case, We would recommend you to get in touch with the help of your developers and make use of portal customization and alter the code to cater for your business needs. Kindly navigate to Admin->Portal->Customize Portal and modify the code line accordingly
 

Portal customization help article: https://support.freshdesk.com/en/support/solutions/articles/65026-complete-layout-customization

https://support.freshdesk.com/en/support/solutions/articles/50000003753-customizing-your-customer-portal

 

Here’s to you

Vidya D
 


Learn something new today, get recognized for your contributions, stay on top of product updates and build meaningful connections in our Freshdesk community. Fresh ideas, quality service :) 

Thanks @Vidya Deenadayalan for the details.

Are there any plans to make this happen? It’s nice that it’s possible on the Widget. However, it would be even more useful for us with the Form.

We really need the prefill using URL parameters or something to guarantee the best customer experience.

 

Thanks a lot!

Badge +1

💪

Badge +1

Vidya’s response was the first helpful one I’ve seen on this topic from Freshworks, but it’s only a vague answer. Here’s what we did to make this happen:

Note that you’ll need a web developer or someone familiar with HTML and javascript to modify this to your needs. I’m providing this with no assurance it’ll work for you and can’t support it. But hopefully it gets you started. It was a life-saver for us for the customer experience!

In the Portal customization, (Admin>Portals>Customize) go to the submit ticket page.

In that section (we added it just inside of the top one) add the following code snippet after modifying it with the values you want:

	<script>
// This script takes certain url params and inserts them into form fields.
// Wait till the page loads.
document.addEventListener('DOMContentLoaded', () => {
const queryString = window.location.search;
const urlParams = new URLSearchParams(queryString);
// Rename these variables and param names to describe your actual URL param names you want to be allowed.
const myFirstParam = urlParams.get('param1');
const mySecondParam = urlParams.get('param2');
//etc...

// Grab the relevant field by name. This will do a "starts with" match so you don't need the number at the end unless you want to get specific.
const FirstFieldName = document.querySelector('input[id^="helpdesk_ticket_custom_field_cf_customer_name"]');
const SecondFieldName = document.querySelector('input[id^="helpdesk_ticket_custom_field_cf_customer_id"]');

if (myFirstParam) {
if (FirstFieldName) { // We found a matching field.
FirstFieldName.value = myFirstParam;
FirstFieldName.readOnly = true; // This is optional.
FirstFieldName.style.display = 'none'; // Hide the field since we set it successfully. Also optional.
}
}
if (mySecondParam) {
if (SecondFieldName) { // We found a matching field.
SecondFieldName.value = mySecondParam;
SecondFieldName.readOnly = true; // This is optional.
}
}
});
</script>

 

Now when you link to your form and add &param1=yadayada&param2=12345 it should fill the relevant fields. Example: https://mydomain.freshdesk.com/support/tickets/new?ticket_form=my form name&param1=yadayada&param2=12345

Reply