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

How to split a string value in apex and check the checkbox automatically

Hi All,


            I am having a custom field "Demo" on my custom object. Below this custom object i am having 4 checkbox.

For Example: in the custom field has the value  "Demo= IREAGL" means. 

  IR is splited than the checkbox IRON must be checked.

   EA is splited than the checkbox EARTH must be checked.

   GL is splited than the checkbox GLASS must be checked.

    other check box  must be  left unchecked


One more thing this custom field value is upload using CSV file using apex code. I nedd split the split the test into 2 letter and corresponding value must be used to check the check box.


                           Kindly  any one tell how to do this.


Try splitting the String first by "IR". Get the remaining string split by "EA" again get the remaining split it by "GL".

I hope you will able to write the steps.

thanks for the reply. Kindly tell me how to this. Pls explain me more.

Bhawani SharmaBhawani Sharma
You can do something like:
if(customField.contains('IR')) {
//Mark IRON checkbox checked
if(customField.contains('EA')) {


if(customField.contains('GL')) {