Bhasker
Bhasker

Reputation: 11

NetSuite - Get Transaction Type using suite script API

How to get Transaction Type using suite script API? Based on the fetched value want to perform logic. Is it possible to fetch transaction type?

   function afterSubmit(type) {
            if (type == 'create' || type == 'edit') {
                //how to get transaction type(transType) so that I can use in the condition???
                if (transType == 'SalesOrd') {

                    var toemail = nlapiLookupField('customer',
                            nlapiGetFieldValue('customer'), 'email');
                    nlapiLogExecution('DEBUG', 'ToEmail', toemail);
                    var emailSubject = 'Hello World';
                    var emailBody = 'Hello World Message';
                    var fromId = -5;
                    nlapiSendEmail(fromId, toemail,
                            emailSubject, emailBody, null, null, null, null);

                }// if
                else

                if (transType == PurchOrd) {
                    var toemail = nlapiLookupField('customer',
                            nlapiGetFieldValue('customer'), 'email');
                    nlapiLogExecution('DEBUG', 'ToEmail', toemail);
                    var emailSubject = 'Hello World';
                    var emailBody = 'Hello World Message';
                    var fromId = -5;
                    nlapiSendEmail(fromId, toemail,
                            emailSubject, emailBody, null, null, null, null);

                }
            }// end

    }

-Thanks

Upvotes: 1

Views: 1729

Answers (1)

Shea Brennan
Shea Brennan

Reputation: 1132

There are dozens of ways probably. Here are a few:

In SS1:

var myRecordType = nlapiGetRecordType(); //gives you the internal id ie: 'salesorder' etc

or

var myRecord = nlapiGetNewRecord();
var myRecordType = myRecord.getFieldValue('type') //as above

In SS2:

var myRecord = context.newRecord;
var myRecordType = myRecord.type; //value from the record.Type "enum" ie: SALES_ORDER

Upvotes: 4

Related Questions