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
Riby VargheseRiby Varghese 

Validation Error: Value is not valid on populating picklist

Hi I have picklist card status when selecting an inactivate field a seg card number is populated in another picklist.but try to save the details showing the error:: Validation Error: Value is not valid
function populateCard()
    {
        //alert('test');
         var accid = document.getElementById("LoyaltyPage:LoyaltyForm:loyaltyFormBlock:LoyaltySection1:LoyaltySectionItem1:targetId_lkid").value;
        Visualforce.remoting.Manager.invokeAction(
            '{!$RemoteAction.CaseLoyaltyCtrl.getCardNumber}',
            accid, 
            function(result,event){
                if (event.status) {
                     var x=document.getElementById("LoyaltyPage:LoyaltyForm:loyaltyFormBlock:j_id31:item2:j_id49:s1");
                    x.value="";
                    x.selectedIndex = 0;
                    
                    var optionlist =document.createElement("option");                                            
                   optionlist.text=result.Card_Number__c;
                     // option.text =cardno.Alias_Number__c ;
                     x.add(optionlist);
                }
            }, 
            {escape: true}
        );
          return true;
    }

Apex:

 @RemoteAction
    global static Account getCardNumber(String accountID) {
        Account account ;
  string soql = 'SELECT Card_number__c FROM Account WHERE Id=\''+accountID+'\'';
        account = Database.query(soql);
        System.debug('account'+account);
        return account;
    }