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
Alexander GoodmanAlexander Goodman 

Apex setting a mutiselect picklist value from blank

Hi, 
I am trying to figure out how to set a value in a Muti-select Picklist if its blank. How would I first find if it is Blank then set it to a value to Other, Note: I am trying to learn Apex so a bit of guild for the future would be greatly appreciated.

Thanks in advance. 
Best Answer chosen by Alexander Goodman
ManojjenaManojjena
HI Alexander ,

Then you can check with instance of the object.industry__c == null ,then do your stuff .
 

All Answers

ManojjenaManojjena
Hi Alexander,

Is it possible to post your sample code ,I will try to modify your code .
else add  <apex:selectOption itemLabel="--Select Object--" itemValue="blank" />  in your page .

Thanks 
Manoj


 
Alexander GoodmanAlexander Goodman
 Hi Manoj
 
this is what I have so far
public class OpportunityPicklistFix {
    public OpportunityPicklistFix() {
        Public String Fields {get;set;}
        List <SelectOption> OPS = new List<SelectOption>

        public List <select SelectOption> getIndustryValues (Accounts ,String Industry__c, String Other)
    }
}
ManojjenaManojjena
Hi  Alexander ,

What exactly your requirment is ? Could you please explain bit more .
Alexander GoodmanAlexander Goodman
Hi Manoj

sure, I am as a bit of a exercise (as I am learning apex) I am trying to create a class/trigger that will fire when a mutiselect picklist called industry__c, is blank and when it is it then defaults the value to 'Other', all I want to know is how do I get the Apex to lookup the value then change it when its Blank.

Kind regards
 
ManojjenaManojjena
HI Alexander ,

Then you can check with instance of the object.industry__c == null ,then do your stuff .
 
This was selected as the best answer
Alexander GoodmanAlexander Goodman
Would this code work better in a Trigger or a class?
Alexander GoodmanAlexander Goodman
I got it working thank you.