function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
SF ADMINISTRATORSF ADMINISTRATOR 

Update Custom Object - Error on Salesforce ID

Greetings

I am trying to update a Custom Object with te SalesForce API but I keep getting an error that the ID I am sending to the custom object is not a valid SalesForce ID.

This is happening on a custom object for our Contacts.

I don't really know the best way to explain it but here it goes.

We have a custom object on our Accounts named "Account Refernece".  The Account Refernece Object is created (by default) once we add an account.  But then I need to update the Account Refernece with more information.  Thus:

Step 1: Create Account and return the salesforce account id
Step 2: Update the account reference object with the salesforce account id in step 1

When trying to do step 2 I am presented with this error:

 '001i000000wxerh' is not a valid Salesforce ID for the type Account Reference

And for some reason "001i000000wxerh" is actually truncated to 15 characters.  The actual id retuned in step 1 is 18 characters "001i000000wxerhAAA".  But from what I have read that does not matter.  It is the first 15 characters that count.

Here is a snippet of the fields where myFields(0) is the account id returned in step 1.  Does anyone know what I am doing wrong?

        Dim AccountObject As sObject = New JacoApex.sObject()
        Dim myFields As System.Xml.XmlElement() = New System.Xml.XmlElement(5) {}

        Dim doc As New System.Xml.XmlDocument()

        myFields(0) = doc.CreateElement("id")
        myFields(0).InnerText = account.ToString

        myFields(1) = doc.CreateElement("Credit_Card_No__c")
        myFields(1).InnerText = cardnumber

        myFields(2) = doc.CreateElement("Credit_Card_Exp_Date__c")
        myFields(2).InnerText = cardexpires

        myFields(3) = doc.CreateElement("CVV2_Code__c")
        myFields(3).InnerText = cvvcode

        myFields(4) = doc.CreateElement("Name_On_Card__c")
        myFields(4).InnerText = nameoncard

        myAccountRef.type = "gii__AccountAdd__c"
        myAccountRef.Any = myFields

        Dim myAccountRefList As sObject() = New sObject(0) {}
        myAccountRefList(0) = AccountObject

        Dim results As SaveResult() = bindingService.update(myAccountRefList)

Andy BoettcherAndy Boettcher

The "001" prefix is an Account - you are grabbing the Id for the actual Account and sticking that in the "Id" field of your custom child object.  If you are creating a record (not updating) you will never populate the "Id" field - Salesforce will assign that when the record is inserted.

If you are trying to use the AccountId to relate the custom object to your standard Account object record, there will be another field you will have created as a Lookup or Master/Detail relationship that you will stick the AccountId in.

Giuseppe CodazziGiuseppe Codazzi
Hi ! I am really new to the SalesForce world and I have a very similar problem . 

I am populating Salesforce using EasyMorph which has a connection already preset . 

I need to add a new Contact , linked to Account via Account Name field (Master/Detail relationship). 

The problem is that it does not allow me to update the Account Name field when I create a new contact , giving me the following error : 

INVALID_FIELD_FOR_INSERT_UPDATE:Unable to create/update fields: Name. Please check the security settings of this field and verify that it is read/write for your profile or permission set.

So I tried to update the Id field , but I got the same truncation problem, so it tells me that the data type is incorrect . 

Would you know how to help me ?