13
Points
Questions
0
Answers
6
-
The exportPDFInvoices() function defines a search to find all Customer and Vendor PDF invoices in NetSuite. It then loops through the search results and saves down each PDF file internally. You can schedule this script to run automatically on a recurring basis using the NetSuite Scheduled Script feature.
Note that you will need to replace the 123 placeholder in the script with the internal ID of the folder where you want to save the files.
/**
* The main function that exports and saves down PDF invoices.
*/
function exportPDFInvoices() {
// Define the search filters to find invoices
var filters = [
search.createFilter({
name: ‘mainline’,
operator: search.Operator.IS,
values: [‘T’]
}),
search.createFilter({
name: ‘type’,
operator: search.Operator.ANYOF,
values: [‘CustInvc’, ‘VendBill’]
})
];// Define the search columns to retrieve
var columns = [
search.createColumn({
name: ‘tranid’
}),
search.createColumn({
name: ‘tranid’,
join: ‘customer’
}),
search.createColumn({
name: ‘tranid’,
join: ‘vendor’
}),
search.createColumn({
name: ‘transactionnumber’
}),
search.createColumn({
name: ‘pdftransaction’,
join: ‘file’
})
];// Create the search object and run the search
var searchObj = search.create({
type: search.Type.TRANSACTION,
filters: filters,
columns: columns
});
var searchResult = searchObj.run().getRange({
start: 0,
end: 1000
});// Loop through the search results and save each PDF file
for (var i = 0; i < searchResult.length; i++) {
var result = searchResult[i];// Get the transaction ID, customer name, vendor name, and PDF file object
var transactionId = result.getValue(‘tranid’);
var customerName = result.getText(‘customer’);
var vendorName = result.getText(‘vendor’);
var pdfFile = result.getValue({
name: ‘pdftransaction’,
join: ‘file’
});// Save down the PDF file internally
if (pdfFile) {
var fileObj = file.load({
id: pdfFile
});
fileObj.name = transactionId + ‘.pdf’;
fileObj.folder = 123; // Replace with the internal ID of the folder where you want to save the files
fileObj.save();
}
}
}- 674 views
- 4 answers
- 0 votes
-
The createSublist() function creates a new sublist on the Suitelet form and adds columns for the employee name, net pay, and tax deduction. It then loops through the search results and adds each result to the sublist. The getSearchResults() function loads the saved search and retrieves the search results.
Note that you will need to replace the your_saved_search_id_here placeholder with the ID of your saved search. Also, the field IDs used in the code (custpage_employee, custpage_netpay, and custpage_taxdeduction) are custom field IDs that you can set when creating the sublist fields.
function createSublist(form) {
// Get the search results
var searchResults = getSearchResults();// Create the sublist
var sublist = form.addSubList({
id: ‘custpage_employees’,
type: serverWidget.SublistType.LIST,
label: ‘Employee Payroll Information’
});// Add columns to the sublist
sublist.addField({
id: ‘custpage_employee’,
type: serverWidget.FieldType.TEXT,
label: ‘Employee’
});
sublist.addField({
id: ‘custpage_netpay’,
type: serverWidget.FieldType.CURRENCY,
label: ‘Net Pay’
});
sublist.addField({
id: ‘custpage_taxdeduction’,
type: serverWidget.FieldType.CURRENCY,
label: ‘Tax Deduction’
});// Loop through the search results and add them to the sublist
for (var i = 0; i < searchResults.length; i++) {
var searchResult = searchResults[i];// Get the employee name and sublist values from the search result
var employeeName = searchResult.getValue(‘sublistEmployee’);
var sublistPay = searchResult.getValue(‘sublistpay’);
var sublistAmount = searchResult.getValue(‘subListAmount’);// Add the values to the sublist
sublist.setSublistValue({
id: ‘custpage_employee’,
line: i,
value: employeeName
});
if (sublistPay == ‘netpay’) {
sublist.setSublistValue({
id: ‘custpage_netpay’,
line: i,
value: sublistAmount
});
} else if (sublistPay == ‘tax deduction’) {
sublist.setSublistValue({
id: ‘custpage_taxdeduction’,
line: i,
value: sublistAmount
});
}
}
}function getSearchResults() {
// Define the saved search filters and columns
var filters = [];
var columns = [
search.createColumn({
name: ‘sublistEmployee’
}),
search.createColumn({
name: ‘sublistpay’
}),
search.createColumn({
name: ‘subListAmount’,
summary: search.Summary.SUM
})
];// Load the saved search and run it
var savedSearch = search.load({
id: ‘your_saved_search_id_here’
});
var searchResults = savedSearch.run().getRange({
start: 0,
end: 1000
});// Return the search results
return searchResults;
}Good luck π
- 788 views
- 2 answers
- 0 votes
-
Sounds like some of the invoices are associated with a locked accounting period.Β Test on open periods before unlocking older periods.Β Be careful changes in locked periods will affect reporting.
- 163 views
- 3 answers
- 0 votes
-
try this
var myListField = β<!DOCTYPE html>β;
myListField += β<html>β
myListField += β<head>β
myListField += β</head>β
myListField += β<body>β
myListField += β<table align=βleftβ bgcolor=β#e0e6efβ style=βwidth:20%;β>β
myListField += β<tr>β
myListField += β<td>β
myListField += β<p style=βtext-align: left; margin-left:5px; font-family: Open Sans; font-size:12px;β><b>Summary</b></p>β
myListField += β</td>β
myListField += β<td>β
myListField += β<p style=βtext-align: right; margin-right:5px; font-family: Open Sans; font-size:12px;β><b>Value</b></p>β
myListField += β</td>β
myListField += β</tr>β
myListField += β<tr>β
myListField += β<td>β
myListField += β<p style=βtext-align: left; margin-left:5px; font-family: Open Sans; font-size:12px;β>β+βfield1β+'</p>β
myListField += β</td>β
myListField += β<td>β
myListField += β<p style=βtext-align: right; margin-right:5px; font-family: Open Sans; font-size:12px;β>β+value1+'</p>β
myListField += β</td>β
myListField += β</tr>β
myListField += β<tr>β
myListField += β<td>β
myListField += β<p style=βtext-align: left; margin-left:5px; font-family: Open Sans; font-size:12px;β>β+βfiled2β+'</p>β
myListField += β</td>β
myListField += β<td>β
myListField += β<p style=βtext-align: right; margin-right:5px; font-family: Open Sans; font-size:12px;β>β+value2+'</p>β
myListField += β</td>β
myListField += β</tr>β
myListField += β<tr>β
myListField += β<td>β
myListField += β<p style=βtext-align: left; margin-left:5px; font-family: Open Sans; font-size:12px;β>β+βfield3β+'</p>β
myListField += β</td>β
myListField += β<td>β
myListField += β<p style=βtext-align: right; margin-right:5px; font-family: Open Sans; font-size:12px;β>β+value3+'</p>β
myListField += β</td>β
myListField += β</tr>β
myListField += β</table>β
myListField += β</body- 187 views
- 1 answers
- 0 votes
-
Try suitetalk web services.
This code demonstrates how to update data in the customer, vendor, item, and sales order objects.Β Note that you will need to replace the placeholders for the credentials and data with your own values, and ensure that your SuiteTalk web services integration is properly set up and authorized to access NetSuite. Additionally, you will need to handle any errors that may occur during the update process.
// Load the SuiteTalk Web Services module
var stWS = require(‘N/suiteTalk’);// Define the credentials for accessing NetSuite
var credentials = {
email: ‘your_email@example.com’,
password: ‘your_password’,
account: ‘1234567’,
role: ‘3’
};// Create a new NetSuite client using the credentials
var client = new stWS.createClient({
account: credentials.account,
consumerKey: credentials.consumerKey,
consumerSecret: credentials.consumerSecret,
token: credentials.token,
tokenSecret: credentials.tokenSecret
});// Define the data to update in the customer object
var customerData = {
internalid: 1234,
companyname: ‘Acme Inc.’,
firstname: ‘John’,
lastname: ‘Doe’
};// Update the customer record using the customer data
var updateCustomerResult = client.update({
record: {
recordType: ‘customer’,
fields: customerData
}
});// Define the data to update in the vendor object
var vendorData = {
internalid: 5678,
companyname: ‘Acme Supplies’,
firstname: ‘Jane’,
lastname: ‘Smith’
};// Update the vendor record using the vendor data
var updateVendorResult = client.update({
record: {
recordType: ‘vendor’,
fields: vendorData
}
});// Define the data to update in the item object
var itemData = {
internalid: 9012,
itemid: ‘ABC123’,
displayname: ‘ABC Widget’
};// Update the item record using the item data
var updateItemResult = client.update({
record: {
recordType: ‘inventoryItem’,
fields: itemData
}
});// Define the data to update in the sales order object
var salesOrderData = {
internalid: 3456,
memo: ‘Updated memo’
};// Update the sales order record using the sales order data
var updateSalesOrderResult = client.update({
record: {
recordType: ‘salesOrder’,
fields: salesOrderData
}
});// Log the results of the updates
log.debug(‘Update Customer Result’, updateCustomerResult);
log.debug(‘Update Vendor Result’, updateVendorResult);
log.debug(‘Update Item Result’, updateItemResult);
log.debug(‘Update Sales Order Result’, updateSalesOrderResult);- 174 views
- 2 answers
- 0 votes
-
Export the historical supplier invoices that need to be updated. Go to Transactions > Purchases > Enter Bills and filter the list to include only the invoices that you want to update. Then, click the Export button to export the invoices to a CSV file.
Open the CSV file in excel.
Add a new column to the spreadsheet and label it “Approval Status”.
In the “Approval Status” column, enter “Pending Approval” for each invoice that needs to be updated.
Save the CSV file.
Go to Transactions > Purchases > Enter Bills and click the Import CSV button.
Select the CSV file that you saved in step 5.
On the Import Options page, map the “Approval Status” column in the CSV file to the “Approval Status” field in NetSuite.
Click the Import button to import the CSV file.
Good luck π
- 163 views
- 3 answers
- 0 votes