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
Arvind010Arvind010 

How to clear the multi select picklist field?

I have created a multiselect picklist field in the Accounts object.I am displaying that as checkboxes in the visualforce page.I am able to update the selected values in the object.But it is not clearing the data in the multi select picklist field.

Code:
Account acct = new Account();
        acct = [Select Seagate_Product_Ranges__c from account where id=:id5];
        String b='';        
        acct.Seagate_Product_Ranges__c = b;
        system.debug('111111111111111111111:' + acct.Seagate_Product_Ranges__c);
        upsert acct;
        acct = [Select Seagate_Product_Ranges__c from account where id=:id5];
        system.debug('2222222222222222222:' + acct.Seagate_Product_Ranges__c);
        String a='';
        for(Integer i=0;i<Fields.size();i++)
        {                                                                      
            system.debug('Product ranges:'+ Fields[i]);
            a = a + Fields[i] + ';';
            system.debug('######################'+a);            
            acct.Seagate_Product_Ranges__c = a;//Fields[0]+ Fields[i]; 
            system.debug('@@@@@@@@@@@@@@@@@@@@@'+ acct.Seagate_Product_Ranges__c);                       
        }
            update acct;   

In the debug log,it is printing null and newly selected values.I thought, it will update only when the field is empty.So i assigned a null value.The problem is, it is not updating the null value to the object.Please help on this.