function readOnly(count){ }
Don't have an account?
Search for an answer or ask a question of the zone or Customer Support.
You need to sign in to do that
Sign in to start searching questions
Signup for a Developer Edition
Sign in to start a discussion
IF(ISNUMBER(Text__c), VALUE(Text__c)+1,Text__c)
Integer textToNumber= Integer.ValueOf(textfield__c.trim()); textToNumber++; textfield__c= '' + textToNumber;
Example : String str = '100'; if(str.isNumeric()) { Integer numbervalue = Integer.valueof(str); numbervalue = numbervalue +1; System.debug('@@ Result '+numbervalue); }
Hi Foram,
there is field which is text type and value is combination of alphabet and numeric and i want to increase numeric value for next entered record.
String id= 'KC-012345'; System.debug('===raw=='+id); Integer index = id.lastIndexOf('-'); String text = id.substring(index+1); System.debug('===text=='+ text); Integer textToNumber= Integer.valueOf(text); System.debug('===text to number==='+ textToNumber); textToNumber++; System.debug('===new text to number==='+ textToNumber); String numberToText = String.ValueOf(textToNumber); System.debug('---padded number ---' + numberToText.leftPad(6,'0')); String newEmp = 'KC-'+ numberToText.leftPad(6,'0'); System.debug('new ID '+ newEmp);
but if playing in formula, use of ISNUMBER() and VALUE() could resolve the issue
If playing in apex, something like:
hth
Andrew
Thanks,
Foram rana
Hi Foram,
there is field which is text type and value is combination of alphabet and numeric and i want to increase numeric value for next entered record.
Can you provide example of this alphanumeric string?
Employee__c e =[select Employee_Id__c from Employee__c ORDER BY createdDate desc limit 1 ][0];
system.debug('====old idd'+e.Employee_Id__c);
for(Employee__c emp : trigger.new){
string id=e.Employee_Id__c;
system.debug('===ggh=='+id);
integer index = id.lastIndexOf('-');
string text = id.substring(index);
system.debug('===text=='+ text);
Integer textToNumber= Integer.ValueOf(text);
system.debug('===text to number===='+ textToNumber);
textToNumber++;
emp.Employee_Id__c= 'KC-' + textToNumber;
system.debug('=======================================id===='+emp.Employee_Id__c);
}
}
my number is not incremented properly it only revolve around 0 and 1
Pardon all the debugs , but if you post it to an Execute Anonymous window you will see exactly what is happening.
Regards
Andrew