使用setFieldValue在表单上的下拉菜单中设置字段值

时间:2018-12-05 18:31:07

标签: javascript netsuite suitescript suitescript2.0

我正在尝试在销售订单表单上将送货地址设置为new,如果在设置新地址字段值之前可以使用setFieldValue从下拉列表中进行选择,我会感到困惑

var salesOrder = nlapiCreateRecord('salesorder');
        salesOrder.setFieldValue('entity', customerInternalID);
        salesOrder.setFieldValue('location', LOCATION);
        salesOrder.setFieldValue('custbody_ebay_order_id', ebayOrderID);
        salesOrder.setFieldValue('currency', 1);
        salesOrder.setFieldValue('custbody_execute_script', 'T');

        var utc_trandate = nlapiSelectValue(xmlobj, '/GetOrdersResponse/OrderArray/Order['+(i+1)+']/CreatedTime');
        var trandate = dateToNetsuiteFormat(utc_trandate);
        salesOrder.setFieldValue('trandate', trandate);
        salesOrder.setFieldValue('shippingcost', nlapiSelectValue(xmlobj, '/GetOrdersResponse/OrderArray/Order['+(i+1)+']//ShippingServiceCost'));
        nlapiLogExecution('DEBUG', 'address', defaultAddress);
        salesOrder.setFieldValue('billaddresslist', defaultAddress);
        salesorder.setFieldValue('shipaddresslist', 'New');
        salesorder.setFieldValue('shipcountry', nlapiSelectValue(xmlobj, '/GetOrdersResponse/OrderArray/Order['+(i+1)+']//ShippingAddress/Country'));
        salesorder.setFieldValue('shipisresidential', 'T');
        salesorder.setFieldValue('shipattention', nlapiSelectValue(xmlobj, '/GetOrdersResponse/OrderArray/Order['+(i+1)+']//ShippingAddress/Name'));
        salesorder.setFieldValue('shipaddressee', nlapiSelectValue(xmlobj, '/GetOrdersResponse/OrderArray/Order['+(i+1)+']//ShippingAddress/Name'));
        salesorder.setFieldValue('shipaddrphone', nlapiSelectValue(xmlobj, '/GetOrdersResponse/OrderArray/Order['+(i+1)+']//ShippingAddress/Phone').substring(0, 12));
        salesorder.setFieldValue('shipaddr1', nlapiSelectValue(xmlobj, '/GetOrdersResponse/OrderArray/Order['+(i+1)+']//ShippingAddress/Street1'));
        salesorder.setFieldValue('shipaddr2', nlapiSelectValue(xmlobj, '/GetOrdersResponse/OrderArray/Order['+(i+1)+']//ShippingAddress/Street2'));
        salesorder.setFieldValue('shipcity', nlapiSelectValue(xmlobj, '/GetOrdersResponse/OrderArray/Order['+(i+1)+']//ShippingAddress/CityName'));
        salesorder.setFieldValue('shipstate', nlapiSelectValue(xmlobj, '/GetOrdersResponse/OrderArray/Order['+(i+1)+']//ShippingAddress/StateOrProvince'));
        salesorder.setFieldValue('shipzip', nlapiSelectValue(xmlobj, '/GetOrdersResponse/OrderArray/Order['+(i+1)+']//ShippingAddress/PostalCode'));

1 个答案:

答案 0 :(得分:0)

地址是销售订单上的子记录,要设置它们,您需要首先获取子记录,然后在其中设置值。另外,您无需显式保存子记录,该子记录将与父销售订单本身一起保存。 SuiteScript2.0中的示例

// first fetch address sub-record
addressRecord = salesOrderRecord.getSubrecord({ fieldId: 'shippingaddress' });
// then set data on sub-record
addressRecord.setValue({ fieldId: 'shipattention', value: 'ABC' });
// set other required fields