You need to sign in to do that
Don't have an account?
akschamp
get object data by using only id of that object
Hi.....
I have the list of ID's only of standard/custom objects......
I want to get comman data for field 'lastactivitydate' for each object present in that list using id's of the same....how can i get...
for Ex i have record id '0013000000ZEghO' for , then how should i get 'Last activitydate' for this?
any suggestions or solutions....please let me know...
Many thanks,
Akshay
Yes there is.
This code will associate the Id prefix of every object to its name.
All Answers
Hi,
You mean "Last Modified Date"? If so, you can try like the below:
Account a = [select LastModifiedDate from Account where Id=: '0013000000ZEghO'];
To get the Last Modified Date, you can use, a.LastModifiedDate.
Thanks
Hey,
Thanks a lot for your reply!!!!!
I don't know which id's are in that list it could be id of any object.
means - 01q300000009RKJ, a0630000006FN4r, 0013000000ZEghO, a0Q30000004GAMV....etc like this.
so if i pick any one id, then for that i need 'last Activity date'
please let me know......
Thanks,
Akshay
Hi,
In that case you can make use of Dynamic SOQL.
Store the Id in a string.Check for the first three characters of the Id.
For eg. If the first three characters are '001', then dynamically pass the object name to your dynamic query.
String s='0018000000iDBJW';
String id ='id';
String objectName;
if(s.substring(0,3) == '001')
{
objectName ='Account';
}
String query = 'SELECT Name FROM ' + objectName + ' WHERE ' + objectName + '.' +
id+ '=' + '\'' + s+ '\'' ;
Account a = Database.query(query);
This will give you the corresponding record.
Thanks
Hi..
Thanks again for your reply......
But th case is that hav only id, dont know the object name like 'Account','Contact',........
I only know id, is here any way to get data?
thanks
Hi,
First three letters of the Id, specifies the Object. For eg. If the id is'001.........' , 001 specifies the Account.
I have given this extraction step in my above code.
Thanks
Hi.....
yeah....that s correct!!!!
But in my case object id's [standard+custom] are coming dynamically.
So using above code i can iplment for standard objects. but in my list also having custom objects to. and that id list is dynamic.
So please suggest for that case. Thank you ver much for you time.
Please let me know if there is any way?
Thanks
Hi.....
yeah....that s correct!!!!
But in my case object id's [standard+custom] are coming dynamically.
So using above code i can iplment for standard objects. but in my list also having custom objects to. and that id list is dynamic.
So please suggest for that case. Thank you ver much for you time.
Please let me know if there is any way?
Thanks
please help me out on above probem..........
Thanks
Hi,
I am not sure whether this will help you out or not.
For the custom objects, On click of the custom object tab, you will get a id. For eg. https://na6.salesforce.com/a0E/o
When you click on a record in that tab, the Id will be like "https://na6.salesforce.com/a0E80000003BUW2".
So the first three letters of the tab and the corresponding records are same. In your code, you can hard code like, if the first three letters are "a0E" then it belongs to the corresponding custom object and pass in the dynamic query..
Hope this helps.
Thanks
ok.......This is true....but in case of custom objetcs initials(first three letters) of id changes per organization.....so not possible to hard code as we'll not be able to work for dfferent organization.......
Please let me knw if have any other solution!!!!!!
Yes there is.
This code will associate the Id prefix of every object to its name.