我正在使用 jsforce find-api 来按 DOB 搜索帐户,这是一个 type 字段Date
。
对 API 的调用如下所示:
const conn = await connection();
result = await conn.sobject(this.schema.Name).find(rawSObject, Object.keys(this.schema.Fields));
rawSObject
如下所示:
试试 1
const rawSObject = { [AccountFields.PersonBirthdate]: moment(birthDate, 'MM/DD/YYYY').format('YYYY-MM-DD') };
但它失败了:
INVALID_FIELD:
PersonBirthdate = '1985-12-12'
^
ERROR at Row:1:Column:985
value of filter criterion for field 'PersonBirthdate' must be of type date and should not be enclosed in quotes
试试 2
const rawSObject = { [AccountFields.PersonBirthdate]: moment(birthDate, 'MM/DD/YYYY').toISOString();
但仍然得到同样的错误。
尝试 3
我还尝试传递一个日期对象:
const rawSObject = { [AccountFields.PersonBirthdate]: moment(birthDate, 'MM/DD/YYYY').toDate()
这一次我得到了一个不同的错误:
MALFORMED_QUERY:
PersonBirthdate = Thu Dec 12 1985 00:00:00 GMT+0200
^
ERROR at Row:1:Column:1002
Bind variables only allowed in Apex code
at HttpApi.getError (/Users/nalfasi/dev/salesforce-gateway/node_modules/jsforce/lib/http-api.js:250:13)...
尝试 4
在搜索网络时,我还遇到了以下线程:https ://github.com/jsforce/jsforce/issues/851并尝试了那里的建议,特别是这里评论中的建议:https ://github.com/ jsforce/jsforce/issues/851#issuecomment-594233217
rawSObject = { [AccountFields.PersonBirthdate]: { $eq: SfDate.toDateTimeLiteral(birthDateObj) };
现在我遇到了一个新错误:
INVALID_FIELD:
PersonBirthdate = 1985-12-11T22:00:00Z
^
ERROR at Row:1:Column:985
value of filter criterion for field 'PersonBirthdate' must be of type date and should not be enclosed in quotes
at HttpApi.getError (/Users/nalfasi/dev/salesforce-gateway/node_modules/jsforce/lib/http-api.js:250:13)
更远
我还搜索了网络并发现了以下问题: Cannot Update Custom Date field via SalesForce API (JSforce)
但他们也没有帮助