+ Start a Discussion
rebvijkumrebvijkum 

Error: Compile Error: Illegal assignment from LIST<String> to String at line 75 column 9

can u guy solve the error and the record is saving twice??
My Code:
public class GetURLnew {
    public Article_Feedback__c ArticleFeedbackObj = new Article_Feedback__c();
    //private final Article_Feedback__c artfeed;
    Public string Comments {get;set;}
       
    String[] reasons = new String[]{};
    public Core_Benefit__kav filterid;
    public string cbkId {get; set;}
    public String sfUrl=URL.getSalesforceBaseUrl().getHost();   
    public Core_Benefit__DataCategorySelection CatDetails;  
    public Core_Benefit__kav cbk {get; set;}
    public string ID=apexpages.currentpage(). getParameters().get('id');
    public GetURLnew(ApexPages.KnowledgeArticleVersionStandardController controller) {
        String message = '' + ApexPages.CurrentPage().GetParameters().Get('message');
            String pageHeaderReferer = ApexPages.currentPage().getHeaders().get('Referer'); 

            // Use the referrer parameter to only show the message when coming from Page 1
            if(pageHeaderReferer != null && pageHeaderReferer.containsIgnoreCase('PageName') && message != 'null')
            {

                ApexPages.AddMessage(new ApexPages.Message(ApexPages.Severity.CONFIRM, message)); 
            }
        cbkId = apexpages.currentpage(). getParameters().get('id');       
        cbk = new Core_Benefit__kav();
        if(cbkId != null && cbkId != '') {
         cbk = [Select Id, Title,Exam__c,Lens__c,UrlName, Lens_Enhancements__c,Frame__c,Contacts__c,Support_Queue_Steps__c,Doctor_Network__c,Lab__c,Additional_Benefits__c, ArticleType, ArticleNumber, CreatedById, OwnerId from Core_Benefit__kav where PublishStatus = 'online' AND Language = 'en_US' AND KnowledgeArticleId =: cbkId];           
         filterid=[SELECT Id,UrlName FROM Core_Benefit__kav WHERE ArticleNumber =: cbk.ArticleNumber AND PublishStatus = 'online' AND Language = 'en_US'];                
         CatDetails= [Select DataCategoryName,DataCategoryGroupName from Core_Benefit__DataCategorySelection where ParentId =:filterid.Id];          
        }        
    }
    public List<SelectOption> getItems() {
            List<SelectOption> options = new List<SelectOption>();
            options.add(new SelectOption('Broken Link','Broken Link'));
            options.add(new SelectOption('Page Unclear','Page Unclear'));
            options.add(new SelectOption('Missing Information','Missing Information'));
            options.add(new SelectOption('Hard to Find Page','Hard to Find Page'));
            options.add(new SelectOption('Other','Other'));
            return options;
        }
    public String[] getReasons() {
            return reasons;
        }
            
    public void setreasons(String[] reasons) {
            this.reasons = reasons;
        }   
    public String getart() {
        return ID;      
    }
    public String getsfurll() {
        return sfURL;      
    }
    public Article_Feedback__c getArticleFeedbackObj(){
      return ArticleFeedbackObj;
    }
    public void setArticleFeedbackObj(Article_Feedback__c ArticleFeedbackObj){
      this.ArticleFeedbackObj = ArticleFeedbackObj;
    }
    public String getReturnid() {
        return cbkId;
    }

    public Core_Benefit__DataCategorySelection getCategory() {
        return CatDetails;
    }
    public PageReference saveclick() {
                  
        ArticleFeedbackObj.Article_ID__c=ID;
        ArticleFeedbackObj.Article_Title__c=cbk.Title;
        ArticleFeedbackObj.Article_Type__c=cbk.ArticleType;        
        ArticleFeedbackObj.Article_URL__c=cbk.UrlName;
        ArticleFeedbackObj.Comments__c=Comments;
        ArticleFeedbackObj.Data_Category__c=CatDetails.DataCategoryName;
        ArticleFeedbackObj.Data_Category_Group__c=CatDetails.DataCategoryGroupName;
        ArticleFeedbackObj.Reason__c=reasons;
        insert ArticleFeedbackObj;
        PageReference pg = new PageReference('/apex/CoreBenefit_VFP?id='+ID);
        pg.getParameters().put('message', 'Record saved Successfully');
        pg.setRedirect(true);
        return pg;
         //return null;
    }   
}
Best Answer chosen by rebvijkum
Balaji BondarBalaji Bondar
Use below code:
String reasonsString = '';
for(count i =0;i<reasons.size();i++){
	reasonsString + = reasons[i];

	if(i!<reasons.size()-1)
		reasonsString + = ';';

}
ArticleFeedbackObj.Reason__c= reasonsString;

Important :
If this is what you were looking for then please mark it as a "SOLUTION" or You can Click on the "Like" Button if this was beneficial for you.

All Answers

Balaji BondarBalaji Bondar
Hi,
I think Reason__c is the text field so change this line :
ArticleFeedbackObj.Reason__c=reasons[0];
Important :
If this is what you were looking for then please mark it as a "SOLUTION" or You can Click on the "Like" Button if this was beneficial for you.
rebvijkumrebvijkum
reasons is a multipicklist selection, when i use ArticleFeedbackObj.Reason__c=reasons[0];
saves only one value
Balaji BondarBalaji Bondar
Use below code:
String reasonsString = '';
for(count i =0;i<reasons.size();i++){
	reasonsString + = reasons[i];

	if(i!<reasons.size()-1)
		reasonsString + = ';';

}
ArticleFeedbackObj.Reason__c= reasonsString;

Important :
If this is what you were looking for then please mark it as a "SOLUTION" or You can Click on the "Like" Button if this was beneficial for you.
This was selected as the best answer
rebvijkumrebvijkum
Thanks for your quick reply.
I'm getting
Error: Compile Error: expecting right curly bracket, found 'for' at line 13 column 4

public class GetURLnew {
    public Article_Feedback__c ArticleFeedbackObj = new Article_Feedback__c();
    Public string Comments {get;set;}      
    String[] reasons = new String[]{};
    public Core_Benefit__kav filterid;
    public string cbkId {get; set;}
    public String sfUrl=URL.getSalesforceBaseUrl().getHost();   
    public Core_Benefit__DataCategorySelection CatDetails;  
    public Core_Benefit__kav cbk {get; set;}
    public Boolean hiddenvaluesflag {get;set;}    
    public string ID=apexpages.currentpage(). getParameters().get('id');
    String reasonsString = '';
    for(count i =0;i<reasons.size();i++){
    reasonsString + = reasons[i];

    if(i!<reasons.size()-1)
        reasonsString + = ';';
}

    public GetURLnew(ApexPages.KnowledgeArticleVersionStandardController controller) {
        hiddenvaluesflag=false;
        String message = '' + ApexPages.CurrentPage().GetParameters().Get('message');
            String pageHeaderReferer = ApexPages.currentPage().getHeaders().get('Referer'); 

            // Use the referrer parameter to only show the message when coming from Page 1
            if(pageHeaderReferer != null && pageHeaderReferer.containsIgnoreCase('PageName') && message != 'null')
            {

                ApexPages.AddMessage(new ApexPages.Message(ApexPages.Severity.CONFIRM, message)); 
            }
        cbkId = apexpages.currentpage(). getParameters().get('id');       
        cbk = new Core_Benefit__kav();
        if(cbkId != null && cbkId != '') {
         cbk = [Select Id, Title,Exam__c,Lens__c,UrlName, Lens_Enhancements__c,Frame__c,Contacts__c,Support_Queue_Steps__c,Doctor_Network__c,Lab__c,Additional_Benefits__c, ArticleType, ArticleNumber, CreatedById, OwnerId from Core_Benefit__kav where PublishStatus = 'online' AND Language = 'en_US' AND KnowledgeArticleId =: cbkId];           
         filterid=[SELECT Id,UrlName FROM Core_Benefit__kav WHERE ArticleNumber =: cbk.ArticleNumber AND PublishStatus = 'online' AND Language = 'en_US'];                
         CatDetails= [Select DataCategoryName,DataCategoryGroupName from Core_Benefit__DataCategorySelection where ParentId =:filterid.Id];          
        }        
    }
    public List<SelectOption> getItems() {
            List<SelectOption> options = new List<SelectOption>();
            options.add(new SelectOption('Broken Link','Broken Link'));
            options.add(new SelectOption('Page Unclear','Page Unclear'));
            options.add(new SelectOption('Missing Information','Missing Information'));
            options.add(new SelectOption('Hard to Find Page','Hard to Find Page'));
            options.add(new SelectOption('Other','Other'));
            return options;
        }
    public String[] getReasons() {
            return reasons;
        }
            
    public void setreasons(String[] reasons) {
            this.reasons = reasons;
        }   
    public String getart() {
        return ID;      
    }
    public String getsfurll() {
        return sfURL;      
    }
    public Article_Feedback__c getArticleFeedbackObj(){
      return ArticleFeedbackObj;
    }
    public void setArticleFeedbackObj(Article_Feedback__c ArticleFeedbackObj){
      this.ArticleFeedbackObj = ArticleFeedbackObj;
    }
    public String getReturnid() {
        return cbkId;
    }

    public Core_Benefit__DataCategorySelection getCategory() {
        return CatDetails;
    }
           
        ArticleFeedbackObj.Article_ID__c=ID;
        ArticleFeedbackObj.Article_Title__c=cbk.Title;
        ArticleFeedbackObj.Article_Type__c=cbk.ArticleType;        
        ArticleFeedbackObj.Article_URL__c=cbk.UrlName;
        ArticleFeedbackObj.Comments__c=Comments;
        ArticleFeedbackObj.Data_Category__c=CatDetails.DataCategoryName;
        ArticleFeedbackObj.Data_Category_Group__c=CatDetails.DataCategoryGroupName;
        ArticleFeedbackObj.Reason__c=reasonsString;
        system.debug('----------------------74---ArticleFeedbackObj:'+ArticleFeedbackObj);
        insert ArticleFeedbackObj;
        PageReference pg = new PageReference('/apex/CoreBenefit_VFP?id='+ID);
        pg.getParameters().put('message', 'Record saved Successfully');
        pg.setRedirect(true);
        system.debug('----------------------74--pg:'+pg);
        return pg;
        
         //return null;
    }   
}
rebvijkumrebvijkum
Thanks Balaji, it worked