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-02-2025 10:46 PM
In HTML gave below code
<!-- Caller -->
<div class="form-group">
<label ng-if="data.company">Caller</label>
<input type="text" class="form-control" ng-if="data.company" ng-model="data.caller" ng-change="toggleCaller()">
</div>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-02-2025 10:54 PM
if user is entering full name then query sys_user, get the sysId and then include in URL
Something like this and enhance the query
$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
};
var callerSysId = '';
var gr = new GlideRecord("sys_user");
gr.addQuery("name", callData.caller_id);
gr.query();
if (gr.next()) {
callerSysId = gr.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 11:42 PM
I Have added below code as well but still caller is not populating
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-02-2025 11:55 PM
I informed to enhance the query based on what user enters
what is user entering? if it's full name then use that query
check what came in this
alert(callData.caller_id);
var callerSysId = '';
var gr = new GlideRecord("sys_user");
gr.addQuery("name", callData.caller_id);
gr.query();
if (gr.next()) {
callerSysId = gr.getUniqueValue();
}
I believe I have provided enough guidance on this and you can 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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-03-2025 12:03 AM
user is entering full name only, in alert as well full name is coming