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
Lisa SeilerLisa Seiler 

StringException: Invalid id: 0013E00000iMZjNQAW

Hi @all,
I hope someone can help me. I want to create a case ans assign a Id to a relationship.
In error I get -> StringException: Invalid id: 0013E00000iMZjNQAW
I convert a String to a Id with this code:
c.AccountId = Id.valueOf(newCatererId);
At this point I got the error.
newCatererId is a String with the Id.
I havre tried to convert it before I assign it to AccountId. It does not working too.

I hope someone can help me
Arunkumar RArunkumar R
Hi Lisa,

I have tried the below example. But it's working for me. 
String st = '0013E00000iMZjNQAW';

Contact cnt = new Contact();
cnt.AccountId = Id.valueOf(st);


Can you post part of the code to verify?
David @ ConfigeroDavid @ Configero
You actually do not need to explicitly convert a string to an Id for assignment.

You can simply do this
c.AccountId = newCatererId;

Please mark this as the correct answer if it helped you.