- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-30-2018 08:23 PM
I've got a record producer that has a widget that opens up a popup that gathers information from the fields on the form. Then inside the popup is a button to "Print/Save". Pressing this button triggers the printer window on the users computer, and also needs to then submit the form to create the record on the destination table. I've got everything working except for the submit() part. Anyone see what I'm missing? Thanks!
Here's the client script in the widget.
function($uibModal, $scope) {
var c = this;
var g_form = $scope.page.g_form;
c.print = function() {
elem = "printMe";
var mywindow = window.open('', 'PRINT', 'height=400,width=600');
mywindow.document.write('<html><head><title>' + document.title + '</title>');
mywindow.document.write('</head><body >');
mywindow.document.write('<h1>' + document.title + '</h1>');
mywindow.document.write(document.getElementById(elem).innerHTML);
mywindow.document.write('</body></html>');
mywindow.document.close(); // necessary for IE >= 10
mywindow.focus(); // necessary for IE >= 10*/
mywindow.print();
mywindow.close();
console.log('hello, record should save');//this shows in the console, but the next line is not submitting the form
g_form.submit();//this should save the record, but it's not
return true;
}
c.openModal = function() {
//pass field values to the modal
$scope.data.reqName = g_form.getDisplayValue('u_requester_name');
$scope.data.dep = g_form.getDisplayValue('u_department');
$scope.data.phone = g_form.getDisplayValue('u_phone_number');
$scope.data.hpc = g_form.getDisplayValue('u_hpc');
$scope.data.date = g_form.getDisplayValue('u_date_of_notary');
$scope.data.delDoc = g_form.getDisplayValue('u_delivery_of_documents');
c.modalInstance = $uibModal.open({
templateUrl: 'notary-print.html',
scope: $scope
});
};
c.closeModal = function() {
c.modalInstance.close();
};
// hide submit button
$("[name='submit']").hide();
}
and here's the code in the HTML script that triggers the "c.print"
<div class="panel-footer text-right">
<button class="btn btn-primary" ng-click="c.print()">${Print & Save}</button>
</div>
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-12-2018 11:42 PM
Hi
This worked for Patrick perfectly.
$timeout(function() {
$("[name='submit']").trigger('click');
});
Thanks.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-30-2018 10:56 PM
Hi
Maybe you can make use of spUtil which contains utility methods to perform common functions in a Service Portal widget client script.
You need to send the values to server script in widget and then insert records from there.
Go through this :-
Mark correct if it helps.
Regards,
Omkar Mone
www.dxsherpa.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-02-2018 01:31 PM
Hi Omkar,
thanks for the response...I appreciate the link.
Ended up getting it to work with the following script in the client controller for the widget.
$timeout(function() {
$("[name='submit']").trigger('click');
});

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-11-2018 10:48 PM
Hi Patrick,
I hope my answer helped you solve the issue.
Please mark correct answer to close this thread.
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-12-2018 07:33 AM
Hi Omkar,
yes of course. If you'd like to reply one more time with the script I used that worked I'll mark your answer correct. Here again is the script that worked. Thanks again!
$timeout(function() {
$("[name='submit']").trigger('click');
});