Solved

Pre-populated ticket fields

  • 24 November 2022
  • 2 replies
  • 45 views

Userlevel 6
Badge +10

Hello, 

I’m looking for a way to populate fields/drop down/check boxes using a URL 

So I can have card on the end user portal with like this url 

myitsm.freshservice.com/support/home?category=HR?employeetype=Consulting?active=True

“employeetyp” is a drop down field 
“active” is a checkbox 

 

Has anyone manage to get something to work ? 

 

TIA

Daniel

icon

Best answer by Rutger Bockholts 25 November 2022, 16:06

View original

2 replies

Userlevel 2
Badge

Hi Daniel,

 

The different parameters in the url have to be separated with the “&” character instead of the “?”. Format wise, below url should do the trick:

https://example.freshservice.com/support/tickets/new?category=HR&employeetype=Consulting&active=true

 

The script can be added via Helpdesk Rebranding - Customize Custom Portal - Layout & Pages - Portal Pages - New Ticket.

Field ID's (#****) in the script have to be adjusted to your own environment. For the Dropdown menus on the portal, you can find the field ID's in the <Select section of the page source. If you need help with this, I can provide some page source examples where to find them.

 

<script>
jQuery(document).on('PageUpdate', function() {

// (un)select checkbox
var active_input = getParameterByName('active');
console.log('active_input: ' + active_input);

if (active_input == 'True' || active_input == 'true') {
var checkBox = document.getElementById('27000156639');
checkBox.checked = false;
checkBox.onchange = function () {
document.getElementById("27000156639").checked = true;
};
checkBox.onchange();
} else {
var checkBox = document.getElementById('27000156639');
checkBox.checked = false;
checkBox.onchange = function () {
document.getElementById("27000156639").checked = false;
};
checkBox.onchange();
}

// Employeetype dropdown selection
var employeetype_input = getParameterByName('employeetype');
console.log('employeetype_input: ' + employeetype_input);
$("#27000156640").val(employeetype_input).show().trigger("change");

// Category dropdown selection
var category_input = getParameterByName('category');
console.log('category_input: ' + category_input);
$("#27000073325").val(category_input).show().trigger("change");

});
</script>

 

 

 

 

Hope this helps. I'm looking forward for your result.

 

Kind regards,

 

Rutger Bockholts

Freshworks

Userlevel 6
Badge +10

@Rutger Bockholts 

Thanks , you are right it should be &, something was wrong when I wrote the URL but couldn’t put my finger on what is was. 

 

Did some smal Tests and it worked great, going to post some more when I have a full setup. 

 

//Daniel 

Reply