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
AdamSBealAdamSBeal 

Invalid Id Error

I am passing some selected account Ids to my page in the querystring. I wish to add these to a list in my page but I am getting an Invalid Id Error.  I am wondering if it is because my id is type string. This is the error (The id is a valid account id): 

Error:The following error occurred attempting to save:Invalid id: (001V000000606czIAA)

 

Here is the code:

 

String queryParamAccts = System.currentPagereference().getParameters().get('sAccts');

queryParamAccts = EncodingUtil.urlDecode(queryParamAccts, 'UTF-8');

 List<String> orderAccounts = queryParamAccts.split(',');
                 Set<Id> setAccountIds = new Set<Id>();
                 for(String s : orderAccounts)
                 {
                     setAccountIds.add(s); //error happens here
                 }

 Here is the debug log:

 

14:47:51.391 (391025000)|SYSTEM_METHOD_EXIT|[106]|System.debug(ANY)
14:47:51.391 (391095000)|SYSTEM_CONSTRUCTOR_ENTRY|[108]|<init>(Integer)
14:47:51.391 (391125000)|SYSTEM_CONSTRUCTOR_EXIT|[108]|<init>(Integer)
14:47:51.391 (391144000)|SYSTEM_METHOD_ENTRY|[109]|LIST<String>.iterator()
14:47:51.391 (391171000)|SYSTEM_METHOD_EXIT|[109]|LIST<String>.iterator()
14:47:51.391 (391184000)|SYSTEM_METHOD_ENTRY|[109]|system.ListIterator.hasNext()
14:47:51.391 (391199000)|SYSTEM_METHOD_EXIT|[109]|system.ListIterator.hasNext()
14:47:51.391 (391225000)|SYSTEM_METHOD_ENTRY|[111]|SET<Id>.add(Object)
14:47:51.391 (391287000)|EXCEPTION_THROWN|[EXTERNAL]|System.StringException: Invalid id: (001V000000606czIAA)
14:47:51.391 (391338000)|SYSTEM_METHOD_EXIT|[111]|SET<Id>.add(Object)
14:47:51.391 (391392000)|SYSTEM_METHOD_ENTRY|[132]|System.StringException.getMessage()
14:47:51.391 (391418000)|SYSTEM_METHOD_EXIT|[132]|System.StringException.getMessage()
14:47:51.391 (391487000)|SYSTEM_METHOD_ENTRY|[132]|ApexPages.addMessage(ApexPages.Message)
14:47:51.391 (391509000)|VF_PAGE_MESSAGE|The following error occurred attempting to save this order:Invalid id: (001V000000606czIAA)

yvk431yvk431

while adding the ids to the set, try placing a condition that the value is not null and '' (blank)

 

If the problem still persists try to paste the query string value and check.

 

--yvk

AdamSBealAdamSBeal

But the id is not null or blank check the debug log:

14:47:51.391 (391287000)|EXCEPTION_THROWN|[EXTERNAL]|System.StringException: Invalid id: (001V000000606czIAA)