tag:blogger.com,1999:blog-5277328648605741474.post6782478403187816451..comments2024-03-19T08:13:51.196-04:00Comments on Salesforce <Source>: A Utility Apex Class to Convert All Types Into StringSam Arjmandihttp://www.blogger.com/profile/03304120460251140274noreply@blogger.comBlogger18125tag:blogger.com,1999:blog-5277328648605741474.post-68238315200647806702014-05-30T05:46:41.435-04:002014-05-30T05:46:41.435-04:00Hi Sam Arjmandi,
Nice p...Hi Sam Arjmandi,<br /> Nice post.In my requirement Object like below form<br />string strtemp = 'Mahesh__'+strFieldName + '__c'; <br /><br />How to use this String as like object ?(after only i will give these related fields edit and del functionalities)<br /><br />please help me...............<br /> Anonymoushttps://www.blogger.com/profile/00405486638654942736noreply@blogger.comtag:blogger.com,1999:blog-5277328648605741474.post-31215175906399580722012-01-09T01:58:13.279-05:002012-01-09T01:58:13.279-05:00Hi Sam,
Is there any way we can convert a sObject...Hi Sam,<br /><br />Is there any way we can convert a sObject to String type. <br /><br />ThanksAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-5277328648605741474.post-71304295426587688422012-01-04T09:33:10.613-05:002012-01-04T09:33:10.613-05:00Email, Phone, etc are logical types and have nothi...Email, Phone, etc are logical types and have nothing to do with Apex.<br /><br />In Apex, Email, Phone, etc all of them are string.Sam Arjmandihttps://www.blogger.com/profile/03304120460251140274noreply@blogger.comtag:blogger.com,1999:blog-5277328648605741474.post-61562736226883949322012-01-03T22:28:51.594-05:002012-01-03T22:28:51.594-05:00Hi Sam,
How do you convert Email Type to string? ...Hi Sam,<br /><br />How do you convert Email Type to string? I am tring to send an email to the current user. I can use User.Email; however, it is of type Email and I cannot get the string value from it.<br /><br />Thanks in advanceAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-5277328648605741474.post-2252085507929829592011-11-10T08:52:24.323-05:002011-11-10T08:52:24.323-05:00Hi Sam
I need to convert Blob to String.Blob is t...Hi Sam<br /><br />I need to convert Blob to String.Blob is the attachment Body and I need to convert it to String to display it on the VF Page.Can you please suggest any solution for this.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-5277328648605741474.post-47645110453192321462011-07-27T03:43:04.915-04:002011-07-27T03:43:04.915-04:00Hi Sam Arjmandi this is suman your code is good . ...Hi Sam Arjmandi this is suman your code is good . i faced one problem using apex class and page inserted records from csv file into custom object in salesforce. i take 3 fields in object. one field data type is currency. but uploading time showing error i.e. "llegal assignment from String to Decimal" . i use your code converting string to decimal but that time also showing error what is the solution please let me knowAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-5277328648605741474.post-21316832085719228822011-05-20T13:44:15.789-04:002011-05-20T13:44:15.789-04:00definitely useful, Sam. Thank you for sharing!
He...definitely useful, Sam. Thank you for sharing!<br /><br />Here's 100% test coverage:<br /><br /> /* test string utils */<br /> system.assertEquals('true',zConvert.ToString(true));<br /> system.assertEquals('false',zConvert.ToString(false));<br /> system.assertEquals('4/17/1960',zConvert.ToString(date.newInstance(1960, 4, 17)));<br /> system.assertEquals('Apr, 26 04 11:24:40',zConvert.ToString(datetime.newInstance(2004, 4, 26, 23, 24, 40), 'MMM, dd yy hh:mm:ss'));<br /> system.assertEquals('Apr, 17 1960',zConvert.ToString(date.newInstance(1960, 4, 17), 'MMM, dd yyyy'));<br /> system.assertEquals('4/26/2004 11:24 PM',zConvert.ToString(datetime.newInstance(2004, 4, 26, 23, 24, 40)));<br /> system.assertEquals('12.457',zConvert.ToString(decimal.valueOf('12.4567')));<br /> system.assertEquals('0',zConvert.ToString(decimal.valueOf('.000000000000000000000012'), true));<br /> system.assertEquals('12.4567',zConvert.ToString(decimal.valueOf('12.4567'), false));<br /> system.assertEquals('3.142',zConvert.ToString(double.valueOf('3.14159')));<br /> system.assertEquals('123,456',zConvert.ToString(123456));<br /> system.assertEquals('1,234,567,890',zConvert.ToString(long.valueOf('1234567890')));<br /> system.assertEquals('18:30:02.020Z',zConvert.ToString(time.newInstance(18, 30, 2, 20)));<br /> system.assertEquals('06-30-02-302',zConvert.ToString(time.newInstance(18, 30, 2, 20), 'hh-mm-ss-ms'));<br /> system.assertEquals('$123,456.17',zConvert.CurrencyToString(decimal.valueOf('123456.17'), '$'));<br /> system.assertEquals('1,023 Bytes',zConvert.FileSizeToString(long.valueOf('1023')));<br /> system.assertEquals('1,015.62 KB',zConvert.FileSizeToString(long.valueOf('1040000')));<br /> system.assertEquals('1,020.43 MB',zConvert.FileSizeToString(long.valueOf('1070000000')));<br /> system.assertEquals('1,015.14 GB',zConvert.FileSizeToString(long.valueOf('1090000000000')));Shawn Butterfieldhttp://www.salesforce.comnoreply@blogger.comtag:blogger.com,1999:blog-5277328648605741474.post-81117119192284818312011-01-26T12:07:44.167-05:002011-01-26T12:07:44.167-05:00Cheers, thanks for the class. Any chance there...Cheers, thanks for the class. Any chance there's a test class for this? Deadlines loom and creating a test is a chore. Either way this is a great help.Bryan and Christinahttps://www.blogger.com/profile/05951142112101822424noreply@blogger.comtag:blogger.com,1999:blog-5277328648605741474.post-91039399260034868652010-03-03T21:22:55.318-05:002010-03-03T21:22:55.318-05:00Hey,
You must have created an instance of the zCon...Hey,<br />You must have created an instance of the zConvert class. You do not need to get an instance. All methods are static and therefore you can use them directly using the class name.Sam Arjmandihttps://www.blogger.com/profile/03304120460251140274noreply@blogger.comtag:blogger.com,1999:blog-5277328648605741474.post-14122307867682892492010-03-03T12:14:07.989-05:002010-03-03T12:14:07.989-05:00First of all, very nice work. I am going to be nee...First of all, very nice work. I am going to be needing to use this very soon (like... today). Thank you very much for posting your work. With that said, when attempting to use this I get the error <br /><br />Save error: Static methods cannot be invoked through an object instance: ToString(Integer)<br /><br />I'm not exactly sure what that means. In an apex class, I just put the line<br /><br />String testVal = zConvert.ToString(13434);<br /><br />and it threw that. Any ideas?Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-5277328648605741474.post-32367754533319163152009-07-16T10:41:40.061-04:002009-07-16T10:41:40.061-04:00Hi Hart,
May you need to cast that value into num...Hi Hart, <br />May you need to cast that value into number data type before using it in the formula you posted above.Sam Arjmandihttps://www.blogger.com/profile/03304120460251140274noreply@blogger.comtag:blogger.com,1999:blog-5277328648605741474.post-58592189955516496792009-07-16T10:39:17.993-04:002009-07-16T10:39:17.993-04:00I am trying to create a formula that is calucating...I am trying to create a formula that is calucating a % from a roll-up summary field and a text field that has a currency value. I can not change the text field to a Number field because it is from a appexchange package. How can I convert my formula so it will accept the text field? Text field is SalesVision_c__Total_Asset_Millions__c<br /><br />IF(SalesVision_c__Total_Assets_Millions__c> 0, SalesVision_AUM__c / (SalesVision_c__Total_Assets_Millions__c * 1000000), 0)Harthttp://www.google.comnoreply@blogger.comtag:blogger.com,1999:blog-5277328648605741474.post-57408794209903259032009-06-29T12:27:42.740-04:002009-06-29T12:27:42.740-04:00Mark, You can cast ID type to string implicitly.
E...Mark, You can cast ID type to string implicitly.<br />Ex: string id = Account.Id;Sam Arjmandihttps://www.blogger.com/profile/03304120460251140274noreply@blogger.comtag:blogger.com,1999:blog-5277328648605741474.post-78123906128735235792009-06-25T12:22:36.866-04:002009-06-25T12:22:36.866-04:00Any idea on how to convert the SalesForce type of ...Any idea on how to convert the SalesForce type of ID to string?Unknownhttps://www.blogger.com/profile/09129641796812730112noreply@blogger.comtag:blogger.com,1999:blog-5277328648605741474.post-48501768725291434162009-02-04T02:01:00.000-05:002009-02-04T02:01:00.000-05:00This comment has been removed by a blog administrator.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-5277328648605741474.post-9054154241196264942008-11-26T02:00:00.000-05:002008-11-26T02:00:00.000-05:00use .format() method.....Alonsouse .format() method<BR/>.....AlonsoAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-5277328648605741474.post-47598428514092195822008-11-20T15:16:00.000-05:002008-11-20T15:16:00.000-05:00Good work. How do you consistently return 2 decima...Good work. How do you consistently return 2 decimal places for a formatted decimal? For example you have a list of decimal values and you want to render<BR/><BR/>123,456.78<BR/>234,567.80<BR/>345,678.00<BR/><BR/>instead of (what this class does, I believe):<BR/><BR/>123,456.78<BR/>234,567.8<BR/>345,678Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-5277328648605741474.post-77004649622459236522008-11-16T16:30:00.000-05:002008-11-16T16:30:00.000-05:00Thanks Sam!One sort of unrelated question: I still...Thanks Sam!<BR/><BR/>One sort of unrelated question: I still haven't figured out how to make use of the ApexPages.severity enums to display them nicely.<BR/>How does your VF code look that displays the nice yellow box and the 7 ToString'ed values in the first part of the post? The documentation, unfortunately, haven't been able to help me (or maybe I've not managed to understand it...).<BR/><BR/>If you have any input on this subject, I'd appreciate it.<BR/><BR/>Thanks<BR/>//Johan LiljegrenJohan Liljegrenhttps://www.blogger.com/profile/16822726513881675605noreply@blogger.com