首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何插入与ShippingAddress的合同?

如何插入与ShippingAddress的合同?
EN

Stack Overflow用户
提问于 2022-11-15 09:42:17
回答 1查看 23关注 0票数 0

我想注册一个新的合同对象。但是,当我尝试将它与ShippingAddress一起注册时,我会得到一个错误。

如何添加带有契约对象的ShippingAddress?

字段不可写: Contract.ShippingAddres

代码语言:javascript
复制
Contract cont = (Contract) parser.readValueAsStrict(Contract.class);

Address a = new Address();
a.country = 'Japan';
a.city = 'Tokyo';

cont.ShippingAddress = a;

insert cont;

我在GUI中运行了新契约,第二个数组已经注册了ShippingAddress。我也想用Apex来做这件事。

第二个记录的ShippingAddress被注册。

代码语言:javascript
复制
[
  {
    "attributes": {
      "type": "Contract",
      "url": "/services/data/v56.0/sobjects/Contract/8000T000000223IQAQ"
    },
    "Id": "8000T000000223IQAQ",
    "AccountId": "0010T00000Ox7sSQAR",
    "BillingAddress": null,
    "ShippingAddress": null,
    "OwnerId": "0055g00000GRB5vAAH",
    "Status": "Draft",
    "StatusCode": "Draft",
    "IsDeleted": false,
    "ContractNumber": "00000114",
    "CreatedDate": "2022-11-15T10:03:42.000+0000",
    "CreatedById": "0055g00000GRB5vAAH",
    "LastModifiedDate": "2022-11-15T10:03:42.000+0000",
    "LastModifiedById": "0055g00000GRB5vAAH",
    "SystemModstamp": "2022-11-15T10:03:42.000+0000",
    "LastViewedDate": "2022-11-15T10:03:42.000+0000",
    "LastReferencedDate": "2022-11-15T10:03:42.000+0000"
  },
  {

    "BillingStreet": "西新宿1丁目",
    "BillingCity": "新宿区",
    "BillingState": "東京都",
    "BillingPostalCode": "163-0590",
    "BillingCountry": "日本",
    "BillingAddress": {
      "city": "新宿区",
      "country": "日本",
      "geocodeAccuracy": null,
      "latitude": null,
      "longitude": null,
      "postalCode": "163-0590",
      "state": "東京都",
      "street": "西新宿1丁目"
    },
    "ShippingStreet": "西新宿1丁目",
    "ShippingCity": "新宿区",
    "ShippingState": "東京都",
    "ShippingPostalCode": "163-0590",
    "ShippingCountry": "日本",
    "ShippingAddress": {
      "city": "新宿区",
      "country": "日本",
      "geocodeAccuracy": null,
      "latitude": null,
      "longitude": null,
      "postalCode": "163-0590",
      "state": "東京都",
      "street": "西新宿1丁目"
    },
    .....
  }
]
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-11-15 10:06:36

https://developer.salesforce.com/docs/atlas.en-us.238.0.object_reference.meta/object_reference/compound_fields_address.htm

标准地址复合字段是只读的,并且只能使用SOAP和REST访问。有关此限制的其他详细信息,请参阅Compound Field Considerations and Limitations

相反,在地址内设置单个字段。

代码语言:javascript
复制
cont.ShippingCountry = 'Japan';
cont.ShippingCity = 'Tokyo';
insert cont;
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/74443461

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档