【问题标题】:How to get and set shipphone for transaction shipping address in SuiteScript?如何在 SuiteScript 中获取和设置交易送货地址的送货电话?
【发布时间】:2019-02-28 00:12:24
【问题描述】:

我正在尝试在保存项目履行时检索和修改送货地址shipphone 值,但更改没有保存(而且我还没有弄清楚如何检索shipphone,所以我正在使用电话值进行初始测试)。我应该这样做,以便我可以实际更新事务级地址详细信息吗?我假设我需要加载客户记录来获取地址,因为我无法直接获取交易记录上的电话,但这仍然不能解释如何在交易中为送货地址设置发货电话。

function beforeSubmit(context) {
    var ifNum = 'N/A';
    if (context.newRecord.id) ifNum = context.newRecord.id;

    var recordPhone = context.newRecord.getValue('phone');
    var phoneValid = checkPhone(recordPhone);

    if (!phoneValid) {
        try {
            var correctedPhone = correctPhone(recordPhone);
            var shipaddress = context.newRecord.getSubrecord('shippingaddress')
            shipaddress.setValue({fieldId: 'shipphone', value: correctedPhone});

            log.debug('Set phone to: ' + correctedPhone + ' from ' + recordPhone);
        }
        catch(e) {
            var errorStr = 'Error setting IF #' + ifNum + ' phone value';
            log.error(errorStr, e.message);
            throw error.create({
                name: errorStr,
                message: e.message,
                notifyOff: true
            });
        }
    }
}

【问题讨论】:

    标签: netsuite suitescript2.0


    【解决方案1】:

    shipphone 是具有它的交易(销售订单、项目履行等)的交易主体级别字段

    它来自的地址子记录字段是addrphone,因此您的代码应该更像:

    var recordPhone = context.newRecord.getValue({fieldId:'shipphone'});
    ...
      context.newRecord.setValue({fieldId:'shipphone', value:correctedPhone}); // for this transaction
      shipaddress.setValue({fieldId: 'addrphone', value: correctedPhone}); // corrected for future uses of this address.
    

    【讨论】:

      猜你喜欢
      • 2019-07-11
      • 2019-09-13
      • 2013-01-07
      • 2016-01-27
      • 1970-01-01
      • 2013-07-09
      • 1970-01-01
      • 2018-07-09
      • 2012-06-22
      相关资源
      最近更新 更多