You need to sign in to do that
Don't have an account?
![DJP1S DJP1S](https://dfc-org-production.my.site.com/img/userprofile/default_profile_45_v2.png)
Method does not exist or incorrect signature on leftPad operation?
I've got this piece of code in my sandbox which is working just fine
Page1Project__c[] updates = new Page1Project__c[]{}; Project_Template__c[] templates = new Project_Template__c[]{}; for (Page1Project__c pu : projects){ updates.add(pu); } ; for (Project_Template__c pt : [SELECT Name, Id, Times_Used__c, Last_Used__c FROM Project_Template__c]){ for(Page1Project__c u : updates){ if(pt.Id == u.Project_Template__c){ decimal i = pt.Times_Used__c; pt.Times_Used__c = i + 1; integer m = u.CreatedDate.date().month(); string ms = string.valueOf(m); integer d = u.CreatedDate.date().day(); string ds = string.valueOf(d); pt.Last_Used__c = '' + u.CreatedDate.date().year() + '-' + ms.leftPad(2, '0') + '-' + ds.leftPad(2, '0') + ' - ' + UserInfo.getFirstName() + UserInfo.getLastName().SubString(0,1); //string d = u.createdDate.date().year();(); templates.add(pt); } } } if (templates.size() >0){ update templates; }
But whenever I try to deploy I get a save error that the "Method does not exist or incorrect signature: [String].leftPad(Integer, String)"
It's throwing it at this line:
pt.Last_Used__c = '' + u.CreatedDate.date().year() + '-' + ms.leftPad(2, '0') + '-' + ds.leftPad(2, '0') + ' - ' + UserInfo.getFirstName() + UserInfo.getLastName().SubString(0,1);
I'm trying to get the string writted like this: 2012-09-26 - FirstnameL
I ende up checking the length with an IF statement and changing the length accordingly.
All Answers
I guess it is not updated now.
Thanks! How can I achieve the same result in API 25.0?
I ende up checking the length with an IF statement and changing the length accordingly.