Not able to call script inlcude
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2024 03:32 AM
I am trying to call script inlcude by onchange client script but i am not able to do so...but are in scoped application
script include:
var CheckForDuplicity = Class.create();
CheckForDuplicity.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {
checkForDuplication: function() {
gs.log('working','working12');
var invoiceNumber = this.getParameter('sysparm_invoiceNo');
var invoiceAmount = this.getParameter('sysparm_invoiceAmount'); // Updated parameter name
var invoiceDate = this.getParameter('sysparm_invoiceDate'); // Updated parameter name
var vendorCode = this.getParameter('sysparm_vendorCode'); // Updated parameter name
// Logging the values for debugging
gs.log('Invoice Number: ' + invoiceNumber, 'CheckForDuplicity');
gs.log('Invoice Amount: ' + invoiceAmount, 'CheckForDuplicity');
gs.log('Invoice Date: ' + invoiceDate, 'CheckForDuplicity');
gs.log('Vendor Code: ' + vendorCode, 'CheckForDuplicity');
var gr = new GlideRecord('x_perii_account_0_marketing_invoice');
gr.addQuery('invoice_no', invoiceNumber);
gr.addQuery('invoice_amount', invoiceAmount);
gr.addQuery('invoice_date', invoiceDate);
gr.addQuery('vendor_code', vendorCode);
gr.query();
if (gr.next()) {
gs.log('Duplicate record found.', 'CheckForDuplicity');
return 'true'; // Return as string for client-side
} else {
gs.log('No duplicate record found.', 'CheckForDuplicity');
return 'false'; // Return as string for client-side
}
},
type: 'CheckForDuplicity'
client script:
var invoiceNumber = g_form.getValue('invoice_no');
var invoiceDate = g_form.getValue('invoice_date');
var invoiceAmount = g_form.getValue('invoice_amount');
var vendorCode = g_form.getValue('vendor_code');
// Alert concatenated values
alert('Invoice Number: ' + invoiceNumber + ', Vendor Code: ' + vendorCode + ', Invoice Date: ' + invoiceDate);
// Create GlideAjax object
var ga = new GlideAjax('CheckForDuplicity');
ga.addParam('sysparm_name','checkForDuplication');
ga.addParam('sysparm_invoiceNo', invoiceNumber);
ga.addParam('sysparm_invoiceAmount', invoiceAmount); // Fixed parameter name
ga.addParam('sysparm_invoiceDate', invoiceDate); // Fixed parameter name
ga.addParam('sysparm_vendorCode', vendorCode); // Fixed parameter name
alert('test');
// Send request and handle response
ga.getXMLAnswer(duplicate);
function duplicate(response) {
response = response.trim(); // Trim whitespace
if (response === 'true') {
g_scratchpad.duplicateRecord = 'false';
} else {
g_scratchpad.duplicateRecord = 'true';
}
}
script include is not triggering
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2024 06:57 AM - edited 10-16-2024 06:58 AM
Hi @gautam_dhamija ,
If you're working on a scoped application, please make sure to provide the complete API name in the GlideAjax object. For example:
var ga = new GlideAjax('x_perii_account_0.CheckForDuplicity');
Replace x_perii_account_0 with your scoped application name or use the API name from the Script Include field.
Please also check which role can access this script include.
Also, please ensure that your Script Include is accessible across all scopes. If your Script Include is written within an application scope, avoid using gs.log inside it.
Hope this help you.
Regards
Moin