Using Page Composer one can enable a custom Button and execute the SOAP/REST API dynamically by passing the parameters using the Bind parameters available in Oracle Fusion page.
Follow the steps mentioned below.
Enable the Page Composer using Sandbox. (Configuration > Sandboxes > Create Sandbox)
Name : customButtonPublishable: YesSelect Checkbox for Page Composer
Navigate to the Page where the button needed. For the blog I'm creating the button On "Transactions" Page where user can click the button and submit an ESS job "Print Receivables Transactions" to print the invoice and attach the pdf to the invoice also send an copy of invoice to the customer.
Navigate to Receivables > Billing > Manage Transaction
After opening the transaction window Click on Tools > Page Composer
Click the Add "+" button on the Dock. Make sure the Frame element "panelFromLayout" is selected.
Click on "+ Add" next to the HTML Markup in the available components and click on "Close" button.
In the "Component Properties" window click the Down arrow next to the "Value" and select the "Expression Builder".
In the "Expression Builder Copy paste the below code (Kindly modify the code as per your requirement" and test the code before deploying it in the Production or any of your environment.
<html>
<body>
<button id="custCompleteAndReview" class="button" onclick="(function(p_org_id, p_trx_number){
//console.log('Parameters received are : '+p_org_id+'-'+p_trx_number);
var xmlhttp = new XMLHttpRequest();
var finalurl = 'https://' + window.location.host + '/fscmService/ErpIntegrationService';
xmlhttp.open('POST', finalurl, true);
credentials = 'Basic ' + 'c3ZjLnBOkludGVncmF0aW9zZXJAMTIzNA==';
xmlhttp.setRequestHeader('Authorization', credentials);
var sr = '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:typ="http://xmlns.oracle.com/apps/financials/commonModules/shared/model/erpIntegrationService/types/"> ' +
'<soapenv:Header/> ' +
'<soapenv:Body> ' +
'<typ:submitESSJobRequest> ' +
'<typ:jobPackageName>/oracle/apps/ess/financials/receivables/transactions/shared/</typ:jobPackageName> ' +
'<typ:jobDefinitionName>TransactionPrintProgramEss</typ:jobDefinitionName> ' +
'<typ:paramList>'+ p_org_id + '</typ:paramList> ' +
'<typ:paramList>#NULL</typ:paramList> ' +
'<typ:paramList>ANY</typ:paramList> ' +
'<typ:paramList>TRX_NUMBER</typ:paramList> ' +
'<typ:paramList>#NULL</typ:paramList> ' +
'<typ:paramList>#NULL</typ:paramList> ' +
'<typ:paramList>#NULL</typ:paramList> ' +
'<typ:paramList>#NULL</typ:paramList> ' +
'<typ:paramList>#NULL</typ:paramList> ' +
'<typ:paramList>#NULL</typ:paramList> ' +
'<typ:paramList>#NULL</typ:paramList> ' +
'<typ:paramList>#NULL</typ:paramList> ' +
'<typ:paramList>'+ p_trx_number + '</typ:paramList> ' +
'<typ:paramList>'+ p_trx_number + '</typ:paramList> ' +
'<typ:paramList>#NULL</typ:paramList> ' +
'<typ:paramList>#NULL</typ:paramList> ' +
'<typ:paramList>#NULL</typ:paramList> ' +
'<typ:paramList>N</typ:paramList> ' +
'<typ:paramList>#NULL</typ:paramList> ' +
'<typ:paramList>#NULL</typ:paramList> ' +
'<typ:paramList>#NULL</typ:paramList> ' +
'<typ:paramList>#NULL</typ:paramList> ' +
'<typ:paramList>PDF</typ:paramList> ' +
'<typ:paramList>Default Invoice Template</typ:paramList> ' +
'<typ:paramList>Default Credit Memo Template</typ:paramList> ' +
'<typ:paramList>Default Debit Memo Template</typ:paramList> ' +
'<typ:paramList>Default Chargeback Template</typ:paramList> ' +
'<typ:paramList>N</typ:paramList> ' +
'<typ:paramList>#NULL</typ:paramList> ' +
'<typ:paramList>-1</typ:paramList> ' +
'</typ:submitESSJobRequest> ' +
'</soapenv:Body> ' +
'</soapenv:Envelope> ' ;
xmlhttp.onreadystatechange = function () {
if (xmlhttp.readyState == 4) {
if (xmlhttp.status == 200) {
let result = extractResultValue(xmlhttp.responseText);
alert ('Print Receivables Transactions ESS job Submitted successfully. Process ID : ' + result );
}
}
}
xmlhttp.setRequestHeader('Content-Type', 'text/xml');
xmlhttp.send(sr);
function extractResultValue(text) {
var xmlStartIndex = text.indexOf('<env:Envelope');
var xmlEndIndex = text.lastIndexOf('</env:Envelope>') + '</env:Envelope>'.length;
var xmlContent = text.substring(xmlStartIndex, xmlEndIndex);
var parser = new DOMParser();
var xmlDoc = parser.parseFromString(xmlContent, 'text/xml');
var resultTag = xmlDoc.querySelector('result');
if (resultTag) {
return resultTag.textContent;
} else {
return null;
}
}
String.prototype.obfs = function(key, n = 126) {
if (!(typeof(key) === 'number' && key % 1 === 0)
|| !(typeof(key) === 'number' && key % 1 === 0)) {
return this.toString();
}
var chars = this.toString().split('');
for (var i = 0; i < chars.length; i++) {
var c = chars[i].charCodeAt(0);
if (c <= n) {
chars[i] = String.fromCharCode((chars[i].charCodeAt(0) + key) % n);
}
}
return chars.join('');
};
})('', '');return false" > Reprint</button>
</body>
</html> <!-- typo -->
Click on Apply and OK button in the Component Properties window to close the Properties window.
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.