How to use g_form.submit() in a widget for Service Portal

patricklatella
Mega Sage

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 &amp; Save}</button>
</div>

1 ACCEPTED SOLUTION

Hi 

 

This worked for Patrick perfectly.

 

$timeout(function() {
$("[name='submit']").trigger('click');
});

 

Thanks.

View solution in original post

5 REPLIES 5

Hi 

 

This worked for Patrick perfectly.

 

$timeout(function() {
$("[name='submit']").trigger('click');
});

 

Thanks.