You need to sign in to do that
Don't have an account?

Truncating 18-character Account ID in Query
Hello,
i'm currently building a search form where the user can enter search criteria for various fields.
One of those fields is a related Account field.
I am writing the values the user entered into a class variable to use them in a query.
After some troubleshooting I finally read that there are two types of IDs.
Now I am a little bit stuck with truncating the ID i get in a query to compare it with the 15-character ID i get in the lookup field.
//the custom object from which i get the fields public PT_System__c ptsystem; //the variable where the Account ID from the user field is stored public String searchAccount; //this is the query method public List<PT_System__c> getFilteredAnlagen(){ if(ptsystem.name !='' || ptsystem.name != null){ searchSystem = '%'+ptsystem.name+'%'; }else{searchSystem = '%';} if(ptsystem.account__c != null){ searchAccount = ptsystem.account__c+'___'; }else{searchAccount = '%';} return [select Id, Name FROM PT_System__c p WHERE p.RecordType.Name='Rental System' AND Name like :searchSystem AND Account__c like :searchAccount order by Name]; }
Currently I am getting an 'invalid operator on field id' error with the query.
Is there any possibility to work my way around this?
The easiest way I think would be to just cut the last 3 characters of the ID field from the query but I have no idea how to accomplish that.
Or is there some other possibility to compare the different IDs?
I would appreciate any help, because that would be one big step to completing my search form.
Easiest way would be converting the 15 char ID to 18 character.
if you are getting ID in the String typecast it to Id type and it will get converted to 18 character ID.
you can try out something above.
All Answers
Easiest way would be converting the 15 char ID to 18 character.
if you are getting ID in the String typecast it to Id type and it will get converted to 18 character ID.
you can try out something above.
Thank you very much, typecasting perfectly did the trick!