widget on service portal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-02-2025 09:35 PM
I have created widget on service portal
in the body html template I have added few fields like caller, category, contact type, description and short description along with submit button
if i click the submit button new tab should be open incident form with pre filled above details, need to save incident form manually
in the client controller I have added beow script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-03-2025 01:25 AM
I wrote this in client script , due to that it is not working, how to call this script from server to client
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-03-2025 02:25 AM
why not make that input as reference type and then no need of GlideRecord?
How to pass the reference value from the HTML to the client controller in the widget
OR
try to use GlideRecord with callback
Sharing script for 2nd approach
$scope.submitForm = function() {
var callData = {
caller_id: $scope.data.caller,
category: $scope.data.category,
contact_type: $scope.data.contact_type,
short_description: $scope.data.short_description,
description: $scope.data.description
};
// Use GlideRecord with a callback
var gr = new GlideRecord('sys_user');
gr.addQuery('name', callData.caller_id);
gr.query(function(response) {
var callerSysId = '';
if (response.next()) {
callerSysId = response.getUniqueValue();
}
// Construct the URL with query parameters
var url = '/incident.do?sys_id=-1' +
'&sysparm_query=caller_id=' + encodeURIComponent(callerSysId) +
'^category=' + encodeURIComponent(callData.category) +
'^contact_type=' + encodeURIComponent(callData.contact_type) +
'^short_description=' + encodeURIComponent(callData.short_description) +
'^description=' + encodeURIComponent(callData.description);
// Open the URL in a new tab
window.open(url, '_blank');
});
};
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-02-2025 10:45 PM
Glad to know that my script worked.
Please enhance it further.
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
