function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
MMA_FORCEMMA_FORCE 

Split a name?

I have an Object which the Name field starts with "AO-" Now within that is an autonumber. So the field would say for a record after created is AO-01856. How in an Apex Class just get the number from here and not the AO.

I am trying to create a new record for the child object which relates to the parent object.

Thanks

ThomasTTThomasTT

String has split() function, so name.split('-')[1] should be fine (but you should add more check just in case).

 

ThomasTT

jpwagnerjpwagner

string numstring = name.substring(3);

 

integer numvalue = integer.valueOf(numstring);

Message Edited by jpwagner on 09-22-2009 04:34 PM