无法使用 jsforce 将项目添加到 Salesforce 中的自定义选择列表

Can't add item to custom Picklist in Salesforce with jsforce

每当我们发布新版本的软件时,我都需要在 Opportunity 对象中向自定义 Picklist 添加一个选项。

let metadta = [{
      "fullName": "Opportunity.Custom_Picklist__c",
      "label": "Custom Opportunity Picklist",
      "valueSet": {
            "restricted": "true",
            "valueSetDefinition": {
            "sorted": "false",
            "value": [
                        {
                              "fullName": "Option1",
                              "default": "false",
                              "Label": "Option 1"
                        },
                        {
                              "fullName": "Option2",
                              "default": "false",
                              "label": "Option 2"
                        }
                  ]
            }
      }
}];
conn.metadata.update('CustomField', metadata, function(err, results) {
      if(err) console.log(error);
      if(results) console.log(results);      
});

我已经尝试了所有我能想到的变体来更新它,但无论我做什么我都会收到这个错误:

{
  "name": "soapenv:Client",
  "errorCode": "soapenv:Client"
}

我正在使用来自 https://jsforce.github.io/document/#metadata-api

的文档

要将字段添加到您的选择列表,您需要 create metadata. Specifically, the field you wish to add. Have a look at the CustomValue 文档以准确查看 CustomValue 的形状。您还可以以类似的方式使用 jsforce 的 update 将字段更新为非活动状态。

这是一个简短的示例:

const metadata = [{
  fullName: "Opportunity.Custom_Picklist__c.SomeOption",
  default: "false",
  label: "Some New Option"
}];
conn.metadata.create('CustomValue', metadata, function(err, results) {
      if(err) console.log(err);
      if(results) console.log(results);      
});