Use SOAP API to create, update, or delete a record with Custom Address Fields data.
note: Before you create a custom address field, review the Custom Address Fields Requirements and Limitations. To discuss the feature and ask questions, join the Custom Address Fields Discussion group on the Trailblazer Community.
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.
<?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:urn="urn:enterprise.soap.sforce.com"
xmlns:urn1="urn:sobject.enterprise.soap.sforce.com"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Header>
<urn:SessionHeader>
<urn:sessionId>$0XXXXXXXXXXXXXXX</urn:sessionId>
</urn:SessionHeader>
</soapenv:Header>
<soapenv:Body>
<urn:create>
<urn:sObjects xsi:type="urn1:Account"> <!--Zero or more repetitions:-->
<Name>Puneet Ahmedabad Account</Name>
<Mailing_Address__City__s>Ahmedabad</Mailing_Address__City__s>
<Mailing_Address__Street__s>102 Suryakoti</Mailing_Address__Street__s>
<Mailing_Address__PostalCode__s>380022</Mailing_Address__PostalCode__s>
<Mailing_Address__StateCode__s>GJ</Mailing_Address__StateCode__s>
<Mailing_Address__CountryCode__s>IN</Mailing_Address__CountryCode__s>
<Mailing_Address__Latitude__s>37.775</Mailing_Address__Latitude__s>
<Mailing_Address__Longitude__s>-122.418</Mailing_Address__Longitude__s>
</urn:sObjects>
</urn:create>
</soapenv:Body>
</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.
<?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:urn="urn:enterprise.soap.sforce.com"
xmlns:urn1="urn:sobject.enterprise.soap.sforce.com"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Header>
<urn:SessionHeader>
<urn:sessionId>$0XXXXXXXXXXXXXXX</urn:sessionId>
</urn:SessionHeader>
</soapenv:Header>
<soapenv:Body>
<urn:update>
<urn:sObjects xsi:type="urn1:Account">
<Id>$001XXXXXXXXXXXXXXX</Id>
<Mailing_Address__Street__s>20 Udhyog Nagar</Mailing_Address__Street__s>
<Mailing_Address__City__s>Surendranagar</Mailing_Address__City__s>
<Mailing_Address__PostalCode__s>363001</Mailing_Address__PostalCode__s>
<Mailing_Address__StateCode__s>GJ</Mailing_Address__StateCode__s>
<Mailing_Address__CountryCode__s>IN</Mailing_Address__CountryCode__s>
<Mailing_Address__Latitude__s>22.757580</Mailing_Address__Latitude__s>
<Mailing_Address__Longitude__s>71.619350</Mailing_Address__Longitude__s>
</urn:sObjects>
</urn:update>
</soapenv:Body>
</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.
<?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:urn="urn:enterprise.soap.sforce.com"
xmlns:urn1="urn:sobject.enterprise.soap.sforce.com"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Header>
<urn:SessionHeader>
<urn:sessionId>$0XXXXXXXXXXXXXXX</urn:sessionId>
</urn:SessionHeader>
</soapenv:Header>
<soapenv:Body>
<urn:update>
<urn:sObjects xsi:type="urn1:Account">
<Id>$001XXXXXXXXXXXXXXX</Id>
<Name>Acc updated</Name>
<urn:fieldsToNull>Mailing_Address__Street__s</urn:fieldsToNull>
<urn:fieldsToNull>Mailing_Address__City__s</urn:fieldsToNull>
<urn:fieldsToNull>Mailing_Address__PostalCode__s</urn:fieldsToNull>
<urn:fieldsToNull>Mailing_Address__StateCode__s</urn:fieldsToNull>
<urn:fieldsToNull>Mailing_Address__CountryCode__s</urn:fieldsToNull>
<urn:fieldsToNull>Mailing_Address__Latitude__s</urn:fieldsToNull>
<urn:fieldsToNull>Mailing_Address__Longitude__s</urn:fieldsToNull>
</urn:sObjects>
</urn:update>
</soapenv:Body>
</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.
<?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:urn="urn:enterprise.soap.sforce.com"
xmlns:urn1="urn:sobject.enterprise.soap.sforce.com"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Header>
<urn:SessionHeader>
<urn:sessionId>$0XXXXXXXXXXXXXXX</urn:sessionId>
</urn:SessionHeader>
</soapenv:Header>
<soapenv:Body>
<urn:delete>
<Id>$001XXXXXXXXXXXXXXX</Id>
</urn:delete>
</soapenv:Body>
</soapenv:Envelope>