Skip to main content
Question

Custom Widget problem

  • Dec 5, 2025 8:15 AM UTC
  • 1 reply
  • 53 views

Tommas
Apprentice

Hi,

I’ve created a feedback widget.
I’ve added the related code to the footer connecting a button with a JS listener and it’s correctly opening a ticket.
I’ve tried to pre-fill the most of the filed ( native and custom ) following the documentation:
https://developers.freshdesk.com/widget-api/
But the filed are not auto filled.

I’m sharing the code, could you please confirm that the structure in correct ( we can asume that the maping is correct ) : 

<script>
  window.fwSettings = {
    'widget_id': 103000008811
  };
  !function(){if("function"!=typeof window.FreshworksWidget){var n=function(){n.q.push(arguments)};n.q=[],window.FreshworksWidget=n}}();
</script>
<script type='text/javascript' src='https://euc-widget.freshworks.com/widgets/103000008811.js' async defer></script>

<script>
  document.getElementById('feedback-btn').addEventListener('click', function() {
    FreshworksWidget('on', 'widget:loaded', function() {
      FreshworksWidget('prefill', 'ticketForm', {
        source: 9,
        priority: 1,
        status: 2,
        type: 'Question',
        group_id: 103000018370,
        custom_fields: {
          cf_option653248: 'OTHER',
          cf_seller: '1MONDE9 (984)',
          cf_sourcing_country: 'France',
          cf_shop: 'Andre (VP_FR - 38491)',
          cf_platform: 'Other',
          cf_topic: 'Process',
          cf_web: 'Severals',
          cf_resolution_by_department: 'Other',
          cf_requesting_team: 'Other',
        }
      });

      FreshworksWidget('hide', 'ticketForm', [
        'source',
        'custom_fields.cf_web',
        'custom_fields.cf_requesting_team',
      ]);

      FreshworksWidget('open', 'ticketForm');
    });
  });
</script>

1 reply

debojyotidev
Community Debut
  • Community Debut
  • May 17, 2026 9:20 PM UTC

 

Hi,

I faced the same issue recently and got it working. The main problem is with the event listener you're using.

Issue:
`FreshworksWidget('on', 'widget:loaded', function() { ... })` only runs once when the widget initially loads. Since you're triggering it from a button click (which happens later), the callback never executes.

Solution:

You don’t need the `widget:loaded` event here. Try this cleaned-up version:


<script>
  window.fwSettings = {
    'widget_id': 103000008811
  };
  !function(){if("function"!=typeof window.FreshworksWidget){var n=function(){n.q.push(arguments)};n.q=[],window.FreshworksWidget=n}}();
</script>
<script type='text/javascript' src='https://euc-widget.freshworks.com/widgets/103000008811.js' async defer></script>

<script>
  document.getElementById('feedback-btn').addEventListener('click', function() {
    
    FreshworksWidget('prefill', 'ticketForm', {
      source: 9,
      priority: 1,
      status: 2,
      type: 'Question',
      group_id: 103000018370,
      custom_fields: {
        cf_option653248: 'OTHER',
        cf_seller: '1MONDE9 (984)',
        cf_sourcing_country: 'France',
        cf_shop: 'Andre (VP_FR - 38491)',
        cf_platform: 'Other',
        cf_topic: 'Process',
        cf_web: 'Severals',
        cf_resolution_by_department: 'Other',
        cf_requesting_team: 'Other',
      }
    });

    FreshworksWidget('hide', 'ticketForm', [
      'source',
      'custom_fields.cf_web',
      'custom_fields.cf_requesting_team'
    ]);

    FreshworksWidget('open', 'ticketForm');
  });
</script>
 

Additional Tips:
- If you are using **Ticket Forms** (multiple forms), add `formId` in the prefill and hide calls.
- Double-check that the values you're passing in `custom_fields` exactly match the options configured in Freshdesk.
- You can also prefill `subject` and `description` — very useful for feedback widgets.


subject: "Feedback from Website",
description: "Please describe your feedback here..."
 

Let me know if this works or if you share the form ID / screenshot of your ticket form, I can help refine it further.


Debojyoti (https://www.linkedin.com/in/debojyoti-dev/)