tag:blogger.com,1999:blog-5277328648605741474.post6414906322642604112..comments2024-03-19T08:13:51.196-04:00Comments on Salesforce <Source>: Get the Best Out of Apex Describe MethodsSam Arjmandihttp://www.blogger.com/profile/03304120460251140274noreply@blogger.comBlogger12125tag:blogger.com,1999:blog-5277328648605741474.post-15778338312442008912014-07-03T10:07:13.480-04:002014-07-03T10:07:13.480-04:00How to retrieve created date of object in a pagebl...How to retrieve created date of object in a pageblocktable using schema methods in visualforce page?<br /><br />help me......Anonymoushttps://www.blogger.com/profile/04484960355070172958noreply@blogger.comtag:blogger.com,1999:blog-5277328648605741474.post-69779332754370938982013-04-24T17:57:05.993-04:002013-04-24T17:57:05.993-04:00omgosh...so nice!omgosh...so nice!TheWesternShorehttps://www.blogger.com/profile/08773924124925011649noreply@blogger.comtag:blogger.com,1999:blog-5277328648605741474.post-47338193439244450642013-04-03T14:16:42.246-04:002013-04-03T14:16:42.246-04:00Code had errors.. updated working code if anyone w...Code had errors.. updated working code if anyone wants it. (Not wrapped in class... obviously just add the Util. back and wrap the FormatFieldsForQuery in the Util class!)<br /><br /><br />// Put this method in same class/controller/extension<br /> public static string FormatFieldsForQuery(Map M, string prefix){<br /> Set fieldSet = M.keySet(); <br /> string fields = '';<br /> for(string f : fieldSet) fields += prefix + f +',';<br /> if(fields.endsWith(',')) fields= fields.substring(0,fields.length()-1);<br /> return fields;<br /> }<br /><br />// And your code to run query - Acc.Id is an account id you have from somewhere<br /><br /> MAP mapA;<br /> mapA= Schema.SObjectType.Account.fields.getMap();<br /> string fields = FormatFieldsForQuery(mapA,'');<br /> string q = 'SELECT '+ fields +' FROM Account WHERE Id= \''+Acc.Id+'\'';<br /> List MyAccount = Database.Query(q);<br />Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-5277328648605741474.post-23317727759262588032013-01-18T06:22:25.246-05:002013-01-18T06:22:25.246-05:00I noticed this blog entry and I am so thrilled by ...I noticed this blog entry and I am so thrilled by the style you create your posts! Which methods do you prefer spread the knowledge that you shared a brand new blog entry to your blog?Martha the writers Bloghttp://letgothepast.wordpress.com/noreply@blogger.comtag:blogger.com,1999:blog-5277328648605741474.post-20692966877172370012012-12-17T04:18:33.602-05:002012-12-17T04:18:33.602-05:00Hi sam,
Here we can get Field label,name e.t.c. Bu...Hi sam,<br />Here we can get Field label,name e.t.c. But How can I get created/modified date and created/modified by for individual field.Sukhdeephttps://www.blogger.com/profile/08376615780470552304noreply@blogger.comtag:blogger.com,1999:blog-5277328648605741474.post-48911399597191372802012-10-10T02:41:40.337-04:002012-10-10T02:41:40.337-04:00Hi sam,
I am new to salesforce getting the ...Hi sam,<br /> I am new to salesforce getting the job in sfdc is difficult for me can u send any real-time scenarios in apex&VF.<br /><br />Thanks&Regrds<br />Balaji<br />nagabaloo@gmail.comAnonymoushttps://www.blogger.com/profile/11414155091164754811noreply@blogger.comtag:blogger.com,1999:blog-5277328648605741474.post-44415430753687266002012-05-29T07:58:40.492-04:002012-05-29T07:58:40.492-04:00please provide the error messages you are encounte...please provide the error messages you are encountering.Sam Arjmandihttps://www.blogger.com/profile/03304120460251140274noreply@blogger.comtag:blogger.com,1999:blog-5277328648605741474.post-29659157261845499802012-05-29T03:13:33.552-04:002012-05-29T03:13:33.552-04:00public class Util
{
public static string Forma...public class Util<br />{<br /> public static string FormatFieldsForQuery(Map M )<br /> {<br /> Set fieldSet = M.keySet(); <br /> string fields = '';<br /> for(string f : fieldSet) fields += f +',';<br /> if(fields.endsWith(',')) fields= fields.substring(0,fields.length()-1);<br /> return fields;<br /> }<br /><br />//to access type of an object:<br />Account acc = new Account();<br /><br /><br />//to get the describe result for an object:<br />Schema.DescribeSObjectResult r = Account.sObjectType.getDescribe();<br /><br />//To describe a field of an object:<br />Schema.DescribeFieldResult f = Schema.sObjectType.Account.fields.Name;<br /><br />//To get a map of all fields an object:<br />Map map;<br />map = Schema.SObjectType.Account.fields.getMap();<br /><br />//get the field list:<br />string fields = Util.FormatFieldsForQuery(map);<br /><br />//perform the query:<br />string q = 'SELECT '+ fields +' FROM Account WHERE Name LIKE \'Test%\''<br />List accounts = Database.Query(q);<br />public List getAccountRecords()<br />{<br /> return accounts;<br />}<br />}<br />i have place ur code in controller. but it showing errors in it. <br /><br />and one more since ur not creating instance of class how it should work in fields variable . i thought i should apply static to FormatFieldsForQuery method. <br />can u clear my confusion plz..Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-5277328648605741474.post-64843626517376104462012-05-17T07:52:54.924-04:002012-05-17T07:52:54.924-04:00hi sam
i have to created Joined format re...hi sam<br /> i have to created Joined format report?there is no option for export to excel?then how to export the data to excel?please help to meAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-5277328648605741474.post-68628333804331846612012-05-14T15:40:11.144-04:002012-05-14T15:40:11.144-04:00Good question, You can use the prefix to query rel...Good question, You can use the prefix to query related objects.<br /><br />Let's say of you are querying "Contact" and want to bring over some of "Account" fields too, then you can to pass a map of Account fields plus the prefix: "Account."<br /><br />output will be:<br />SELECT id, name, Account.Id, Account.Name ... FROM ContactSam Arjmandihttps://www.blogger.com/profile/03304120460251140274noreply@blogger.comtag:blogger.com,1999:blog-5277328648605741474.post-38722338154874105092012-05-14T15:36:26.438-04:002012-05-14T15:36:26.438-04:00Thanks
One question: what is the prefix for?Thanks<br /><br />One question: what is the prefix for?Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-5277328648605741474.post-49358182194573019712012-05-11T18:20:50.237-04:002012-05-11T18:20:50.237-04:00Welcome back! I missed your posts. In your method,...Welcome back! I missed your posts. In your method, you really should do a check on isAccessible() since the describe will bring back all fields even if a user cannot see them. The API does not do this, but in Apex it does and you need to use isAccessible to double check access.Scotthttps://www.blogger.com/profile/06800083396431563282noreply@blogger.com