1

I have linkId = ApexPages.currentPage().getParameters().get('Id');. I want to determine wether what object this ID belongs. Is it Sample1_Object__c ID or Sample2_Object__c ID..

This is a sample debug of an ID:

USER_DEBUG|[11]|DEBUG|a0T9000000KxMLAEA3
7

You could use the getsObjectType() method:

Id i = 'a0T9000000KxMLAEA3';
system.debug(i.getsObjectType());

or

SObjectType type = ApexPages.currentPage().getParameters().get('Id').getsObjectType();
7
  • sir just another question.. How can I determine its Object using visualforce page?.. – Lennon Leopoldo Sep 1 '15 at 8:18
  • @LennonLeopoldo do you have a custom controller or controller extension on the page? – martin Sep 1 '15 at 8:20
  • yes I have. But I'm using this code in vf page. list1Items out is string only. <apex:repeat value="{!list1Items}" var="item"> <li id="{!item}"><div class="item1">{!item}<!-- apex:outputLabel value="{!$ObjectType.Event_Booking__c.fields[item].Label}" /--></div></li> </apex:repeat> – Lennon Leopoldo Sep 1 '15 at 8:22
  • @LennonLeopoldo and are those strings sobject id values? – martin Sep 1 '15 at 8:25
  • yes they are. returned like code like this.. return list2 != null ? list2.split(';') : null; – Lennon Leopoldo Sep 1 '15 at 8:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.