SuiteScript 在到期日向客户保存信用卡失败

SuiteScript Saving Creditcard to Customer Fails On Expire Date

我正在尝试将一些客户详细信息保存到客户记录中。我已经创建了这个方法,但是当我输入到期日期时它失败了。

function addCreditCard(rec, data){
    rec.selectNewLine({
        sublistId: 'creditcards',
    });
    rec.setCurrentSublistValue({
        sublistId   : 'creditcards',
        fieldId     : 'paymentmethod',
        value       : data.paymentmethod
    });
    rec.setCurrentSublistValue({
        sublistId   : 'creditcards',
        fieldId     : 'ccnumber',
        value       : data.ccnumber
    });
    rec.setCurrentSublistValue({
        sublistId   : 'creditcards',
        fieldId     : 'ccname',
        value       : data.ccname
    });
    log.debug("CC Expire Date", "'" + data.ccexpiredate + "'")
    rec.setCurrentSublistValue({
        sublistId   : 'creditcards',
        fieldId     : 'ccexpiredate',
        value       : data.ccexpiredate
    });
    rec.commitLine({
        sublistId: 'creditcards'
    });
}

我收到的错误是

{
    "type": "error.SuiteScriptError",
    "name": "INVALID_FLD_VALUE",
    "message": "You have entered an Invalid Field Value 08/2023 for the following field: ccexpiredate",
    "stack": [
        REDACTED
    ],
    "cause": {
        "type": "intenal error",
        "code": "INVALID_FLD_VALUE",
        "details": "You have entered an Invalid Field Value 08/2023 for the following field: ccexpiredate",
        "userEvent": null,
        "stackTrace": [
            REDACTED
        ],
        "notifyOff": false
    },
    "id": "",
    "notifyOff": false,
    "userFacing": true
}

我可以看到保存到 NetSuite 中的信用卡采用 MM/YYYY 格式,在 NetSuite 帮助文件中我可以看到它是一个字符串字段。我错过了什么?为什么我的到期日期不保存?

要使其正常工作,您需要将日期格式化为 Netsuite 接受的格式。 'N/format' 模块对此有帮助。

format.parse(expirationDate, format.Type.MMYYDATE)

上面的 returns 日期对象请注意 SuiteScript 记录浏览器概述 ccexpiredate 字段是 mmyydate类型和(不清楚它是否接受 String 或 Date 对象)但上面的代码适用于它。前段时间我遇到了类似的问题,该代码帮助我解决了这个问题。如果它适合你,请告诉我。