NetSuite-使用套件脚本API获取事务类型

NetSuite-使用套件脚本API获取事务类型,netsuite,Netsuite,如何使用套件脚本API获取事务类型?基于提取的值,您需要执行逻辑。是否可以获取事务类型 function afterSubmit(type) { if (type == 'create' || type == 'edit') { //how to get transaction type(transType) so that I can use in the condition??? if (trans

如何使用套件脚本API获取事务类型?基于提取的值,您需要执行逻辑。是否可以获取事务类型

   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

    }

-谢谢

可能有几十种方法。以下是一些:

   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

    }
在SS1中:

   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

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

   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

    }
在SS2中:

   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

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

可能有几十种方法。以下是一些:

   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

    }
在SS1中:

   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

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

   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

    }
在SS2中:

   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

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