11
Points
Questions
1
Answers
4
-
I have a question: how can i Access Customer Fields from Sales Order Suitelet. I need to get a value from customer record and update it after sales order is successful.
- 7210 views
- 12 answers
- 0 votes
-
I can create sales order now. I need to make a comparison of quantity user has put with quantity available in inventory and if the user input quantity is more than in stock, I have to send notification in html page to lower the quantity or remove it. Please help me on this.
- 7210 views
- 12 answers
- 0 votes
-
Thank u so much. I will try and let u know.
- 7210 views
- 12 answers
- 0 votes
-
Thank u for reply. I have tried this code, can u please help me where to put your code, this is my very first time writing suitelet
/**
*@NApiVersion 2.x
*@NScriptType Suitelet
*/
define([‘N/search’, ‘N/record’],
function (search, record) {
function onRequest(context) {
if (context.request.method === ‘GET’) {// Get parameters
var customer_id = context.request.parameters.customer_id;
var total_amount = context.request.parameters.total_amount;
var id = context.request.parameters.id;
var quantity = context.request.parameters.quantity;
var price = context.request.parameters.price;
var amount = context.request.parameters.amount;var salesOrder = record.create({
type: record.Type.SALES_ORDER,
isDynamic: true,
});// memo
salesOrder.setValue({
fieldId: ‘memo’,
value: Testing
});// Set customform
salesOrder.setValue({
fieldId: ‘customform’,
value: ‘123’ //internal id
});// Set shipmethod
salesOrder.setValue({
fieldId: ‘shipmethod’,
value: ‘123’ //internal id
});// Shipping Carrier
salesOrder.setValue({
fieldId: ‘shipcarrier’,
value: FedEx
});//Sales representative
salesOrder.setValue({
fieldId: ‘salesrep’,
value: ‘123’ //internal id
});salesOrder.selectNewLine({
sublistId: ‘item’
});salesOrder.setCurrentSublistValue({
sublistId: ‘item’,
fieldId: ‘item’,
value: item.id
});salesOrder.setCurrentSublistValue({
sublistId: ‘item’,
fieldId: ‘tax’,
value: 0
});salesOrder.setCurrentSublistValue({
sublistId: ‘item’,
fieldId: ‘quantity’,
value: item.quantity
});salesOrder.setCurrentSublistValue({
sublistId: ‘item’,
fieldId: ‘rate’,
value: item.price
});salesOrder.setCurrentSublistValue({
sublistId: ‘item’,
fieldId: ‘amount’,
value: item.amount
});salesOrder.commitLine({
sublistId: ‘item’
});try {
var sales_order_id = salesOrder.save({
ignoreMandatoryFields: true
});log.debug(‘record save with id’, sales_order_id);//sales order internal id
return id;} catch (e) {
return 0;}
return {
onRequest: onRequest
};
});- 7210 views
- 12 answers
- 0 votes