1

I have a field called Co-ownere in "Account" Object where I need to query from the field.

In the field I have 2 owner value seperated with ';'. So I want to know What I need to do So that I can divide the values into 2 values.

How I can do it.

Is the approach that I am doing is right or any other way that is there to have 2 other owner in account object

1 Answer 1

1

I would be tempted to create new fields, that way you can use the field(s) more successfully as part of the WHERE clause in your SOQL.

HowveverIf you want to go with your existing approach, you can also use the String split method, for example:

List<Account> accounts = [ Select Co_Owner__c From Account ];
for( Account acc : accounts )
{
    List<String> coowners = acc.Co_Owner__c.split(';');
    for( String coowner : coowners )
    {
        System.debug( 'Co owner ' + coowner );
    }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.