Newer Version Available

This content describes an older version of this product. View Latest

SOAP API Examples (Beta)

Use SOAP API to create, update, or delete a record with Address as a Custom Field (Beta) data.

This feature is a Beta Service. Customer may opt to try such Beta Service in its sole discretion. Any use of the Beta Service is subject to the applicable Beta Services Terms provided at Agreements and Terms.

Address as a Custom Field (Beta) has been enabled for a limited number of customers in Spring '22. Before creating a custom field of type Address, review the limitations.

Note

Create a New Account with Data in a Custom Address Field

This example creates an Account record which includes address data stored in the Mailing Address custom address field.
1<?xml version="1.0" encoding="utf-8"?> 
2<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
3    xmlns:urn="urn:enterprise.soap.sforce.com"
4    xmlns:urn1="urn:sobject.enterprise.soap.sforce.com"
5    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
6    <soapenv:Header>
7        <urn:SessionHeader>
8            <urn:sessionId>$0XXXXXXXXXXXXXXX</urn:sessionId>
9        </urn:SessionHeader>
10    </soapenv:Header>
11    <soapenv:Body> 
12        <urn:create>
13            <urn:sObjects xsi:type="urn1:Account"> <!--Zero or more repetitions:-->
14                <Name>Puneet Ahmedabad Account</Name>
15                <Mailing_Address__c__City__s>Ahmedabad</Mailing_Address__c__City__s>
16                <Mailing_Address__c__Street__s>102 Suryakoti</Mailing_Address__c__Street__s>
17                <Mailing_Address__c__PostalCode__s>380022</Mailing_Address__c__PostalCode__s>
18                <Mailing_Address__c__StateCode__s>GJ</Mailing_Address__c__StateCode__s>
19                <Mailing_Address__c__CountryCode__s>IN</Mailing_Address__c__CountryCode__s>
20                <Mailing_Address__c__Latitude__s>37.775</Mailing_Address__c__Latitude__s>
21                <Mailing_Address__c__Longitude__s>-122.418</Mailing_Address__c__Longitude__s>
22            </urn:sObjects>
23        </urn:create> 
24    </soapenv:Body> 
25</soapenv:Envelope>

Update Data Within a Custom Address Field on a Record

This example updates the data stored in the Mailing Address custom address field for record ID 001XXXXXXXXXXXXXXX.
1<?xml version="1.0" encoding="utf-8"?>   
2<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
3    xmlns:urn="urn:enterprise.soap.sforce.com"
4    xmlns:urn1="urn:sobject.enterprise.soap.sforce.com"
5    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
6    <soapenv:Header>
7        <urn:SessionHeader>
8            <urn:sessionId>$0XXXXXXXXXXXXXXX</urn:sessionId>
9        </urn:SessionHeader>
10    </soapenv:Header>
11    <soapenv:Body> 
12        <urn:update>
13            <urn:sObjects xsi:type="urn1:Account">
14                <Id>$001XXXXXXXXXXXXXXX</Id>
15                <Mailing_Address__c__Street__s>20 Udhyog Nagar</Mailing_Address__c__Street__s>
16                <Mailing_Address__c__City__s>Surendranagar</Mailing_Address__c__City__s>
17                <Mailing_Address__c__PostalCode__s>363001</Mailing_Address__c__PostalCode__s>
18                <Mailing_Address__c__StateCode__s>GJ</Mailing_Address__c__StateCode__s>
19                <Mailing_Address__c__CountryCode__s>IN</Mailing_Address__c__CountryCode__s>
20                <Mailing_Address__c__Latitude__s>22.757580</Mailing_Address__c__Latitude__s>
21                <Mailing_Address__c__Longitude__s>71.619350</Mailing_Address__c__Longitude__s>
22            </urn:sObjects>
23        </urn:update>
24    </soapenv:Body>
25</soapenv:Envelope>

Delete Data Within a Custom Address Field from a Record

To delete address data stored within a custom address field on a record, update the record. This example deletes the address stored in the Mailing Address custom address field on the Account with record with ID 001XXXXXXXXXXXXXXX.
1<?xml version="1.0" encoding="utf-8"?>   
2<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
3    xmlns:urn="urn:enterprise.soap.sforce.com"
4    xmlns:urn1="urn:sobject.enterprise.soap.sforce.com"
5    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
6    <soapenv:Header>
7        <urn:SessionHeader>
8            <urn:sessionId>$0XXXXXXXXXXXXXXX</urn:sessionId>
9        </urn:SessionHeader>
10    </soapenv:Header>
11    <soapenv:Body> 
12        <urn:update>
13            <urn:sObjects xsi:type="urn1:Account">
14                <Id>$001XXXXXXXXXXXXXXX</Id>
15                <Name>Acc updated</Name>
16                <urn:fieldsToNull>Mailing_Address__c__Street__s</urn:fieldsToNull>
17                <urn:fieldsToNull>Mailing_Address__c__City__s</urn:fieldsToNull>
18                <urn:fieldsToNull>Mailing_Address__c__PostalCode__s</urn:fieldsToNull>
19                <urn:fieldsToNull>Mailing_Address__c__StateCode__s</urn:fieldsToNull>
20                <urn:fieldsToNull>Mailing_Address__c__CountryCode__s</urn:fieldsToNull>
21                <urn:fieldsToNull>Mailing_Address__c__Latitude__s</urn:fieldsToNull>
22                <urn:fieldsToNull>Mailing_Address__c__Longitude__s</urn:fieldsToNull>
23            </urn:sObjects>
24        </urn:update>
25    </soapenv:Body>
26</soapenv:Envelope>

Delete a Record That Contains Data in a Custom Address Field

This example deletes the Account record with ID 001XXXXXXXXXXXXXXX. When a record is deleted, all data for that record is deleted, including the custom address field information.
1<?xml version="1.0" encoding="utf-8"?>   
2<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
3    xmlns:urn="urn:enterprise.soap.sforce.com"
4    xmlns:urn1="urn:sobject.enterprise.soap.sforce.com"
5    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
6    <soapenv:Header>
7        <urn:SessionHeader>
8           <urn:sessionId>$0XXXXXXXXXXXXXXX</urn:sessionId>
9        </urn:SessionHeader>
10  </soapenv:Header>
11  <soapenv:Body> 
12      <urn:delete>
13          <Id>$001XXXXXXXXXXXXXXX</Id>
14      </urn:delete> 
15   </soapenv:Body>
16</soapenv:Envelope>