【问题标题】:How to set time in Netsuite using suitescript 2.0?如何使用 suitescript 2.0 在 Netsuite 中设置时间?
【发布时间】:2020-10-16 17:32:34
【问题描述】:

我可以为 UI/API 的 timeofday 类型字段设置时间。

我可以在 Task 的 UI 中使用冒号 (:) 分隔符将 time 类型字段 INITIAL TIME BUDGET 的时间设置为 16:55 .

我无法使用套件脚本为该字段设置时间,如下所示,

function load(recordType, id) {
   return record.load({
    type: recordType,
    id: id
    });
}

var recordType = "task"
var id = "123"

var objectRecord = load(recordType, id);
objectRecord.setValue("estimatedtime", "16:55");

var updatedId = objectRecord.save({});

我收到此错误

You have entered an Invalid Field Value 16:55 for the following field: estimatedtime

我尝试了以下案例,

"16:55" - Invalid Field Value
16:55   - UNEXPECTED_ERROR
16.55   - No error, but set as "estimatedtime":"16:33"

时间类型字段如何设置时间?

【问题讨论】:

  • 这是一个数字。 0.55 是一小时的 55/100,也是一小时的 33/60。或 0:33。

标签: netsuite suitescript2.0


【解决方案1】:

您需要创建一个 Date 对象。例如,假设您经过“13:00”,您需要执行以下操作:

dateStr = "13:00";

d = new Date();
dateParts = dateStr.split(":");
d.setHours(+dateParts[0]);
d.setMinutes(+dateParts[1]);

然后:

objectRecord.setValue("estimatedtime", d);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-09-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多