• rebvijkum
  • NEWBIE
  • 160 Points
  • Member since 2014

  • Chatter
    Feed
  • 1
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 44
    Questions
  • 51
    Replies
Hi Buddies,
I was not able to pass the parameters via actionfunction to the controller. Even controller is not executed by clicking the button. Please check it and let me know where i need to change.
VF Page:
      <apex:commandButton value="Next" style="width:90px;margin-left:360px;" onclick="changeValue();"/>
    <script>
        function changeValue() {
           var c=document.getElementById("mradio").value;
            priorityval(c);
            alert(c);
        }
    </script>
    <apex:actionFunction name="priorityval" action="{!runPriority}">
          <apex:param name="priorityname" value="" assignTo="{!priorityname}"/>
      </apex:actionFunction>
Class:
 public string priorityname{get;set;}
    Public Pagereference runPriority(){
        System.debug('Priority Value@@@'+priorityname+'**RecrdTypeId**'+recrdtypeid);
        PageReference pgRef=new PageReference('/apex/CasePage?RecordType='+recrdtypeid+'&priority='+priorityname);
        pgRef.setRedirect(true);
    return pgRef;   
 }

Please advice me, Thanks in advance!!
Public Class ICS_WR_Warranty_Util{
	public static Boolean Processorfraudcheck(MAP<string,string> mapQryParameter)
    {
        ICS_WR_ConsumingPMFTData.ValidateProcessorResult   Response = ICS_WR_ConsumingPMFTData.get_ValidateProcessor_data(mapQryParameter);
        //string boxtray =response.BoxTrayIndicator;
		//Response = ValidateProcessorResult:[BoxTrayIndicator=Boxed, Last_Ship_To_Date=20101227000000, ProductFrequencyData=null, ProtectionPlanData=null, Rtl_Box_Manufacture_Dt=null, Rtl_Box_Mtrl_Id=null, Rtl_Box_SN=null, Rtl_Box_Site_Id=null, ShipmentInfo=ShipmentInfo:[ShipmentData=(ShipmentData:[AGIDDate=2010-12-08 00:00:00, Batch=L040B436, BoxTrayIndicator=BOX, ChildBoxId=KN0RW873, Level4Prod=CM8062300833803, MaterialMasterNumber=909498, ShipToCustomerCountryCode=US, ShipToCustomerCountryName=United States, ShipToCustomerGeo=ASMO-NA, ShipToCustomerId=SUB-MLMIA, ShipToCustomerName=MODUSLINK, VisualId=null], ShipmentData:[AGIDDate=2010-12-08 00:00:00, Batch=L040B436, BoxTrayIndicator=BOX, ChildBoxId=KN0RW872, Level4Prod=CM8062300833803, MaterialMasterNumber=909498, ShipToCustomerCountryCode=US, ShipToCustomerCountryName=United States, ShipToCustomerGeo=ASMO-NA, ShipToCustomerId=SUB-MLMIA, ShipToCustomerName=MODUSLINK, VisualId=null], ShipmentData:[AGIDDate=2010-12-22 00:00:00, Batch=L040B436, BoxTrayIndicator=BOX, ChildBoxId=null, Level4Prod=BX80623I52500K, MaterialMasterNumber=910679, ShipToCustomerCountryCode=US, ShipToCustomerCountryName=United States, ShipToCustomerGeo=ASMO-NA, ShipToCustomerId=0007011339, ShipToCustomerName=INGRAM US (CA) DSS, VisualId=null], ShipmentData:[AGIDDate=2010-12-23 00:00:00, Batch=L040B436, BoxTrayIndicator=BOX, ChildBoxId=null, Level4Prod=BX80623I52500K, MaterialMasterNumber=910679, ShipToCustomerCountryCode=US, ShipToCustomerCountryName=United States, ShipToCustomerGeo=ASMO-NA, ShipToCustomerId=0002002899, ShipToCustomerName=#10; FRYS, VisualId=null], ShipmentData:[AGIDDate=2010-12-23 00:00:00, Batch=L040B436, BoxTrayIndicator=BOX, ChildBoxId=null, Level4Prod=BX80623I52500K, MaterialMasterNumber=910679, ShipToCustomerCountryCode=US, ShipToCustomerCountryName=United States, ShipToCustomerGeo=ASMO-NA, ShipToCustomerId=0002002900, ShipToCustomerName=#11; FRYS, VisualId=null], ShipmentData:[AGIDDate=2010-12-27 00:00:00, Batch=L040B436, BoxTrayIndicator=BOX, ChildBoxId=null, Level4Prod=BX80623I52500K, MaterialMasterNumber=910679, ShipToCustomerCountryCode=CA, ShipToCustomerCountryName=Canada, ShipToCustomerGeo=ASMO-NA, ShipToCustomerId=0002002614, ShipToCustomerName=INGRAM MICRO CANADA INCORPORATED, VisualId=null], ShipmentData:[AGIDDate=2010-12-27 00:00:00, Batch=L040B436, BoxTrayIndicator=BOX, ChildBoxId=null, Level4Prod=BX80623I52500K, MaterialMasterNumber=910679, ShipToCustomerCountryCode=CA, ShipToCustomerCountryName=Canada, ShipToCustomerGeo=ASMO-NA, ShipToCustomerId=0002002614, ShipToCustomerName=INGRAM MICRO CANADA INCORPORATED, VisualId=null])], ValidationResultCodes=ValidationResultCodes:[ValidationResultCode=(ValidationResultCode:[Remarks=null, ValidationResultCodeId=27, ValidationResult_Code=PMFT-027])]]
        return null;
    }
}



Public class  ICS_WR_ConsumingPMFTData{
	public static ValidateProcessorResult get_ValidateProcessor_data(MAP<string,string> mapQryParameter)
   {
        if(mapQryParameter!=null &&mapQryParameter.keyset()!=null )
        {
            try
            {
                string processorOutpuFormat;
                if(mapQryParameter.containskey('FPO') && mapQryParameter.keyset().size()==1) // If only FPO passing as input parameter
                {
                processorOutpuFormat='{ "Last_Ship_To_Date": "20101227000000","BoxTrayIndicator": "Boxed", "ValidationResultCodes":{"ValidationResultCode" : [{"ValidationResultCodeId": "27","ValidationResult_Code": "PMFT-027"}]},"ShipmentInfo": {"ShipmentData": [{"Batch": "L040B436","MaterialMasterNumber": "909498","ChildBoxId": "KN0RW873","Level4Prod": "CM8062300833803","ShipToCustomerId": "SUB-MLMIA","ShipToCustomerName": "MODUSLINK","ShipToCustomerCountryCode": "US", "ShipToCustomerCountryName": "United States", "ShipToCustomerGeo": "ASMO-NA", "AGIDDate": "2010-12-08T00:00:00Z", "BoxTrayIndicator": "BOX"},{ "Batch": "L040B436", "MaterialMasterNumber": "909498", "ChildBoxId": "KN0RW872","Level4Prod": "CM8062300833803", "ShipToCustomerId": "SUB-MLMIA", "ShipToCustomerName": "MODUSLINK","ShipToCustomerCountryCode": "US","ShipToCustomerCountryName": "United States","ShipToCustomerGeo": "ASMO-NA","AGIDDate": "2010-12-08T00:00:00Z", "BoxTrayIndicator": "BOX"},{"Batch": "L040B436", "MaterialMasterNumber": "910679", "Level4Prod": "BX80623I52500K", "ShipToCustomerId": "0007011339","ShipToCustomerName": "INGRAM US (CA) DSS","ShipToCustomerCountryCode": "US", "ShipToCustomerCountryName": "United States", "ShipToCustomerGeo": "ASMO-NA","AGIDDate": "2010-12-22T00:00:00Z","BoxTrayIndicator": "BOX"},{ "Batch": "L040B436", "MaterialMasterNumber": "910679", "Level4Prod": "BX80623I52500K", "ShipToCustomerId": "0002002899", "ShipToCustomerName": "#10; FRYS", "ShipToCustomerCountryCode": "US",  "ShipToCustomerCountryName": "United States","ShipToCustomerGeo": "ASMO-NA", "AGIDDate": "2010-12-23T00:00:00Z", "BoxTrayIndicator": "BOX"}, { "Batch": "L040B436", "MaterialMasterNumber": "910679","Level4Prod": "BX80623I52500K", "ShipToCustomerId": "0002002900", "ShipToCustomerName": "#11; FRYS",  "ShipToCustomerCountryCode": "US",  "ShipToCustomerCountryName": "United States", "ShipToCustomerGeo": "ASMO-NA",  "AGIDDate": "2010-12-23T00:00:00Z",  "BoxTrayIndicator": "BOX" },{   "Batch": "L040B436","MaterialMasterNumber": "910679",  "Level4Prod": "BX80623I52500K",  "ShipToCustomerId": "0002002614", "ShipToCustomerName": "INGRAM MICRO CANADA INCORPORATED", "ShipToCustomerCountryCode": "CA","ShipToCustomerCountryName": "Canada", "ShipToCustomerGeo": "ASMO-NA", "AGIDDate": "2010-12-27T00:00:00Z", "BoxTrayIndicator": "BOX" },{ "Batch": "L040B436",  "MaterialMasterNumber": "910679","Level4Prod": "BX80623I52500K","ShipToCustomerId": "0002002614", "ShipToCustomerName": "INGRAM MICRO CANADA INCORPORATED", "ShipToCustomerCountryCode": "CA",  "ShipToCustomerCountryName": "Canada", "ShipToCustomerGeo": "ASMO-NA", "AGIDDate": "2010-12-27T00:00:00Z", "BoxTrayIndicator": "BOX" } ]}}';
                }
                else if(mapQryParameter.containskey('FPO') && mapQryParameter.containskey('ATPO')&& mapQryParameter.keyset().size()==2) //if FPO & ATPO passing as input parameter
                {
                    processorOutpuFormat='{"Rtl_Box_SN": "2V034116A2110","Rtl_Box_Site_Id": "CS79","Rtl_Box_Mtrl_Id": "910679","Rtl_Box_Manufacture_Dt": "20101220000000","Last_Ship_To_Date": "20101223000000","BoxTrayIndicator": "Boxed","ValidationResultCodes":{"ValidationResultCode" : [{"ValidationResultCodeId": "28","ValidationResult_Code": "PMFT-028"},{"ValidationResultCodeId": "27","ValidationResult_Code": "PMFT-027"},{"ValidationResultCodeId": "35","ValidationResult_Code": "PMFT-035"}]},"ShipmentInfo":{"ShipmentData": [{"Batch": "L040B436","VisualId": "2V034116A2110","MaterialMasterNumber": "910679","ChildBoxId": "96200200","Level4Prod": "BX80623I52500K","ShipToCustomerId": "0002002899","ShipToCustomerName": "#10; FRYS","ShipToCustomerCountryCode": "US","ShipToCustomerCountryName": "United States","ShipToCustomerGeo": "ASMO-NA","AGIDDate": "2010-12-23T00:00:00Z","BoxTrayIndicator": "BOX"}]}}';
                }
                else if(mapQryParameter.containskey('FPO') && mapQryParameter.containskey('PAC')&& mapQryParameter.keyset().size()==2) //if FPO & PAC passing as input parameter
                {
                    processorOutpuFormat='{"Rtl_Box_SN": "2V034116A2110","Rtl_Box_Site_Id": "CS79","Rtl_Box_Mtrl_Id": "910679","Rtl_Box_Manufacture_Dt": "20101220000000","Last_Ship_To_Date": "20101223000000","BoxTrayIndicator": "Boxed","ValidationResultCodes": {"ValidationResultCode" : [{"ValidationResultCodeId": "28","ValidationResult_Code": "PMFT-028"},{"ValidationResultCodeId": "27","ValidationResult_Code": "PMFT-027"},{"ValidationResultCodeId": "35","ValidationResult_Code": "PMFT-035"},{"ValidationResultCodeId": "101","ValidationResult_Code": "PTP-101","Remarks": "Plan is available and authenticated."}]},"ShipmentInfo": {"ShipmentData":[{"Batch": "L040B436","VisualId": "2V034116A2110","MaterialMasterNumber": "910679","ChildBoxId": "96200200","Level4Prod": "BX80623I52500K","ShipToCustomerId": "0002002899","ShipToCustomerName": "#10; FRYS","ShipToCustomerCountryCode": "US","ShipToCustomerCountryName": "United States","ShipToCustomerGeo": "ASMO-NA","AGIDDate": "2010-12-23T00:00:00Z","BoxTrayIndicator": "BOX"}]},"ProtectionPlanData": {"TransactionId": "24","TransactionDate": "20111111213805","SKU": "BX80623I52500K","PlanActivationCode": "000AB3EO","PlanEffectiveDate": "20111212213805","PaidByUserId": "cpsdtest13@gmail.com","PaidByUserFullName": "E D","LastOwnedByUserId": "cpsdtest01@gmail.com","LastOwnedByUserFullName": "CPSD Test"}}';
                }
                ValidateProcessorResult prData =new ValidateProcessorResult();
                prData=(ValidateProcessorResult)JSON.deserialize(processorOutpuFormat,ValidateProcessorResult.class); //De-serializing output json format
                system.debug('prData##'+prData) ;
                return prData;
            }
            Catch(Exception e)
            {
                isError=true;
            }
        }
        return null;
        
    }

	public class ValidateProcessorResult{
        public ShipmentInfo ShipmentInfo{get;set;}
        public String Last_Ship_To_Date{get;set;}
        public String Rtl_Box_Manufacture_Dt{get;set;}
        public String BoxTrayIndicator{get;set;}
        public String Rtl_Box_Mtrl_Id{get;set;}
        public ValidationResultCodes ValidationResultCodes{get;set;}
        public ProductFrequencyData ProductFrequencyData{get;set;}
        public String Rtl_Box_Site_Id{get;set;}
        public ProtectionPlanData ProtectionPlanData{get;set;}
        public String Rtl_Box_SN{get;set;}
        }
   
    public class ProductFrequencyData
    {
         public list<ProductFrequency> ProductFrequency{get;set;}
    }
    public class ValidationResultCodes
    {
         public list<ValidationResultCode> ValidationResultCode{get;set;}
    }
    public class ShipmentInfo{
        public list<ShipmentData> ShipmentData{get;set;}
        
    }
    public class ProductFrequency{
        public Integer FrequencyType{get;set;}
        public String FreqeuncyCount{get;set;}
    }
     public class ValidationResultCode {
        public String ValidationResult_Code{get;set;}
        public String ValidationResultCodeId{get;set;}
        public String Remarks{get;set;}
    }
    public class ShipmentData{
        public String ShipToCustomerCountryCode{get;set;}
        public String ShipToCustomerCountryName{get;set;}
        public String ShipToCustomerGeo{get;set;}
        public String ShipToCustomerName{get;set;}
        public DateTime AGIDDate{get;set;}
        public String ShipToCustomerId{get;set;}
        public String BoxTrayIndicator{get;set;}
        public String Level4Prod{get;set;}
        public String MaterialMasterNumber{get;set;}
        public String VisualId{get;set;}
        public String ChildBoxId{get;set;}
        public String Batch{get;set;}
    }
    public class ProtectionPlanData{
        public String SKU{get;set;}
        public String PaidByUserId{get;set;}
        public String PlanEffectiveDate{get;set;}
        public String PaidByUserFullName{get;set;}
        public String PlanActivationCode{get;set;}
        public String LastOwnedByUserId{get;set;}
        public String TransactionDate{get;set;}
        public String LastOwnedByUserFullName{get;set;}
        public Integer TransactionId{get;set;}
    }

}

I'm calling a method ICS_WR_ConsumingPMFTData.get_ValidateProcessor_data(mapQryParameter) and I get a deserialized Json response which I shown as a comment in the class. How can I read the response into different variables to use ?
Hi All,

I have created a public custom metadata types and I wanted to provide access to salesforce end users to allow create, edit and delete the records in custom metadata type through profiles or permission sets. How can I do that?

Thanks,
Vijay.
A case record is created in case object, i have to write a trigger if the case is created from salesforce1?
How can we achieve this?
My usecase is, the BatchApex creates a record on QNews__c object whenever a new article is published or new versioned.
In execute method of BatchApex i wrote a code to send email with pdf as attachment. But i'm getting an email with empty pdf file. Any help???

My Execute Batch Code:
public class QNewsUpdateBatch {  
    public class QnewsWrapper{
        public String strArticleId{get;set;}
        public String strArticleTitle{get;set;}
        public String strArticleType{get;set;}
        public String strArticleURL{get;set;}
        public String strArticelVersionNumber{get;set;}
        public String strDataCategory{get;set;}
        public String strDataCategoryGroupName{get;set;}
        public String strDataCategorySelectionId{get;set;}
        public Boolean blnFederalCompliance{get;set;}
        public DateTime lastPublishedDate{get;set;}
        public Boolean blnStateCompliance{get;set;}
        public String strVersionComments{get;set;}
        public String strVersionHistoryId{get;set;}
        public String strVersionHistoryParentid{get;set;}
        public String strVrsionHistoryVersionId{get;set;} 
        public boolean blnBestPractice{get;set;}
        public String strDataCategoryParentId{get;set;}
    }
    public void insertQnewsData(String strArticleType){
        
        Map<Id,Id> VersionParentMap = new Map<Id,Id>();
        Map<Id,Id> VersionIdMap = new Map<Id,Id>();
        List<SObject> lst_versionhistory = Database.Query('SELECT VersionNumber,VersionId,ParentSobjectType,ParentId,Id,EventType,CreatedDate FROM '+strArticleType+'__VersionHistory  where (EventType=\'KavPublishedNew\' or EventType=\'KavPublished\') and ParentSobjectType=\''+strArticleType+'\'');  
        List<QnewsWrapper> listQnews = new List<QnewsWrapper>();
        for(SObject obj:lst_versionhistory){
            VersionParentMap.put((Id)obj.get('versionId'),(Id)obj.get('ParentId'));
            VersionIdMap.put((Id)obj.get('versionId'),(Id)obj.get('Id'));
        }         
        if(VersionParentMap!=null && VersionParentMap.size()>0){
            Set<Id> VersionParentSet = VersionParentMap.keySet();
            List<SObject> lst_DataCategory = Database.Query('Select Id,DataCategoryName,DataCategoryGroupName,ParentId from '+strArticleType+'__DataCategorySelection where ParentId IN :VersionParentSet');
            for(SObject obj:lst_DataCategory){
                        QnewsWrapper qnewsObj = new QnewsWrapper();
                        
                        qnewsObj.strDataCategory = (String)obj.get('DataCategoryName');
                        qnewsObj.strDataCategoryGroupName = (String)obj.get('DataCategoryGroupName');
                        qnewsObj.strDataCategorySelectionId = (String)obj.get('Id');
                        qnewsObj.strDataCategoryParentId = (String)obj.get('ParentId');
                        
                        listQnews.add(qnewsObj);
            }
            List<SObject> lst_ArticleKAV = Database.Query('Select Id,Version_Comments__c,VersionNumber,UrlName,Title,State_Compliance__c,LastPublishedDate,KnowledgeArticleId,Federal_Compliance__c,Best_Practice__c,ArticleType From '+strArticleType+'__kav where Id IN :VersionParentSet');
            for(SObject obj:lst_ArticleKAV){
                for(QnewsWrapper qnewsObj:listQnews){
                    if(qnewsObj.strDataCategoryParentId == obj.get('Id')){
                        qnewsObj.strVersionComments = (String)obj.get('Version_Comments__c');
                        qnewsObj.strArticelVersionNumber = String.valueOf(obj.get('VersionNumber'));
                        qnewsObj.strArticleURL = (String)obj.get('UrlName');
                        qnewsObj.strArticleTitle = (String)obj.get('Title');
                        qnewsObj.blnStateCompliance = (Boolean)obj.get('State_Compliance__c');
                        qnewsObj.lastPublishedDate = (DateTime)obj.get('LastPublishedDate');
                        qnewsObj.strArticleId = (String)obj.get('KnowledgeArticleId');
                        qnewsObj.blnFederalCompliance = (Boolean)obj.get('Federal_Compliance__c');
                        qnewsObj.blnBestPractice = (Boolean)obj.get('Best_Practice__c');
                        qnewsObj.strArticleType = (String)obj.get('ArticleType');
                        qnewsObj.strVersionHistoryParentid = (String)VersionParentMap.get((Id)obj.get('Id'));
                        qnewsObj.strVersionHistoryId = (String)VersionIdMap.get((Id)obj.get('Id'));
                        qnewsObj.strVrsionHistoryVersionId = (String)obj.get('Id');
                    }
                }
            }
        }
        Set<String> existingQNewsVersionsId = new Set<String>();
        for(QNews__c obj:[Select Id,Version_History_Version_Id__c from QNews__c]){
            existingQNewsVersionsId.add(obj.Version_History_Version_Id__c);
        }
        
        List<QNews__c> qnewsToInsert = new List<QNews__c>();
        
        for(QnewsWrapper obj:listQnews){
            if(!existingQNewsVersionsId.contains(obj.strVrsionHistoryVersionId)){   
                QNews__c qnewsObj = new QNews__c();
                qnewsObj.Data_Category_Selection_Id__c = obj.strDataCategorySelectionId;
                qnewsObj.Data_Category_Group__c = obj.strDataCategoryGroupName;
                qnewsObj.Data_Category__c = obj.strDataCategory;
                qnewsObj.Article_ID__c = obj.strArticleId;
                qnewsObj.Article_URL__c = obj.strArticleURL;
                qnewsObj.Article_Title__c = obj.strArticleTitle;
                qnewsObj.Article_Version_Number__c = obj.strArticelVersionNumber;
                qnewsObj.Version_Comments__c = obj.strVersionComments;
                qnewsObj.Last_Published__c = obj.lastPublishedDate;
                qnewsObj.Article_Type__c = obj.strArticleType;
                qnewsObj.Federal_Compliance__c = obj.blnFederalCompliance;
                qnewsObj.State_Compliance__c = obj.blnStateCompliance;
                qnewsObj.Best_Practice__c = obj.blnBestPractice;
                qnewsObj.Version_History_Id__c = obj.strVersionHistoryId;
                qnewsObj.Version_History_Version_Id__c = obj.strVrsionHistoryVersionId;
                qnewsObj.Version_History_Parent_Id__c = obj.strVersionHistoryParentid;
                string filename = qnewsObj.Article_Title__c+'_'+qnewsObj.Article_Version_Number__c+'.pdf';
                string newarticleID = String.valueOf(qnewsObj.Article_ID__c);
                String emailbody='This attachment is the PDF copy of Article:  '+qnewsObj.Article_Title__c+' with version number '+qnewsObj.Article_Version_Number__c;                  GETPDFContentnew.sendEmail('vijaku@vsp.com',qnewsObj.Data_Category__c,emailbody,newarticleID,filename,qnewsObj.Article_Title__c,qnewsObj.Article_Type__c);  
   
                qnewsToInsert.add(qnewsObj);      
            }
        }
 if(qnewsToInsert!=null && qnewsToInsert.size()>0){
            insert qnewsToInsert;
        }    
    }
}

Class to send email:
Global class GETPDFContentnew{
    global static void sendEmail(String EmailIdCSV, String Subject, String body,string newID,string attachmentfilename,string ArticleTitle,string ArticleType) {
    List<String> EmailIds = EmailIdCSV.split(',');
        PageReference ref = null;      
        if(ArticleType=='Multi_Topic__kav'){
             
            ref = Page.Multi_Topic_PDF; 
          }
         if(ArticleType=='Additional_Benefits__kav'){
            ref = Page.AdditionalBenefits_PDF; 
          }
         if(ArticleType=='Core_Benefit__kav'){
            ref = Page.CoreBenefit_PDF; 
          }
         if(ArticleType=='Multi_Topic_Details__kav'){
            ref = Page.MultiTopicDetails_PDF; 
          }
         if(ArticleType=='Open_Enrollment__kav'){
            ref = Page.OpenEnrollment_PDF; 
          }
         if(ArticleType=='Single_Topic__kav'){
            ref = Page.SingleTopic_PDF; 
          }
        ref.getParameters().put('id',newID); 
            ref.setRedirect(true);
        Blob b = ref.getContentAsPDF();
        Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
        Messaging.EmailFileAttachment efa1 = new Messaging.EmailFileAttachment();
        efa1.setFileName(attachmentfilename);
        efa1.setBody(b);
        String addresses;
        email.setSubject( Subject );
        email.setToAddresses(EmailIds);
        email.setPlainTextBody(Body);
        email.setFileAttachments(new Messaging.EmailFileAttachment[] {efa1});
        Messaging.SendEmailResult [] r = Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email});
    }
}
The tag that constructs Edit|Delete|Create New View is <div id="j_id0:QNewsList_filterLinks" class="filterLinks">.
<apex:page tabStyle="Quest__tab" sidebar="false">
    <apex:includeScript value="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"/>
    <script>
        j$ = jQuery.noConflict();
        j$(document).ready(function() {
        j$("#j_id0:QNewsList_filterLinks").hide();
        });
    </script>
    <apex:enhancedList type="QNews__c" height="500" rowsPerPage="10" id="QNewsList"/> 
</apex:page>
So my use case is, when a BatchApex runs for every one hour, it inserts records on QNews custom object.
After Trigger fire every time when a record is inserted on QNews object and  sends an email with a PDF attachment.
I’m getting following error when Batch Apex runs, FATAL_ERROR|System.AsyncException: Future method cannot be called from a future or batch method: SendVFAsAttachment.sendVF(String, String, String, String, Id, String, String, String).

My ApexBatch:
global with sharing class ArticleBatch implements Database.Batchable<string>{
public Iterable<string> start(Database.BatchableContext bc)
    return new ArticleBatchIterable();  }

public void execute(Database.BatchableContext bc, List<string> scope){
    string articleTypeName = scope[0];    
    QNewsUpdateBatch batchClassObj = new QNewsUpdateBatch();
    batchClassObj.insertQnewsData(articleTypeName);
}
global void finish(Database.BatchableContext bc){
      //code that sends an email for execution of Batch    
}

My Trigger:
trigger Send_PDF_to_SharePointhelp on QNews__c (after insert, after update) {
    for(QNews__c qn: Trigger.new){
        string filename = qn.Article_Title__c+'_'+qn.Article_Version_Number__c+'.pdf';
        String emailbody='This attachment is the PDF copy of Article:  '+qn.Article_Title__c+' with version number '+qn.Article_Version_Number__c;   SendVFAsAttachment.sendVF('vijaku@vsp.com',qn.Data_Category__c,emailbody,UserInfo.getSessionId(),qn.Article_ID__c,qn.Article_Title__c,filename,qn.Article_Type__c); 
    }  
}

Future Method:
public class SendVFAsAttachment{
    @future(callout=true)
    public static void sendVF(String EmailIdCSV, String Subject,String body,String userSessionId, ID articleid,String ArticleTitle,String attachmentfilename,String ArticleType)
    {
        string newID = String.valueOf(articleid);
        String addr = 'https://vsp--kmbuild.cs10.my.salesforce.com/services/apexrest/sendPDFEmail';
        HttpRequest req = new HttpRequest();
        req.setEndpoint( addr );
        req.setMethod('POST');
        req.setHeader('Authorization', 'OAuth ' + userSessionId);
        req.setHeader('Content-Type','application/json');
        Map<String,String> postBody = new Map<String,String>();
        postBody.put('EmailIdCSV',EmailIdCSV);
        postBody.put('Subject',Subject);
        postBody.put('body',body);
        postBody.put('newID',newID);
        postBody.put('attachmentfilename',attachmentfilename);
        postBody.put('ArticleTitle',ArticleTitle);
        postBody.put('ArticleType',ArticleType);
        String reqBody = JSON.serialize(postBody);
        req.setBody(reqBody);
        Http http = new Http();
        HttpResponse response = http.send(req);
    }
}

Class to send email, exposed to REST API:
@RestResource(urlMapping='/sendPDFEmail/*')
Global class GETPDFContent{
     @HttpPost
    global static void sendEmail(String EmailIdCSV, String Subject, String body,string newID,string attachmentfilename,string ArticleTitle,string ArticleType) {
    List<String> EmailIds = EmailIdCSV.split(',');
        PageReference ref = Page.Multi_Topic_PDF;
        if(ArticleType=='Multi_Topic__kav'){
            ref = Page.Multi_Topic_PDF; 
          }
         if(ArticleType=='Additional_Benefits__kav'){
            ref = Page.AdditionalBenefits_PDF; 
          }
         if(ArticleType=='Core_Benefit__kav'){
            ref = Page.CoreBenefit_PDF; 
          }
         if(ArticleType=='Multi_Topic_Details__kav'){
            ref = Page.MultiTopicDetails_PDF; 
          }
         if(ArticleType=='Open_Enrollment__kav'){
            ref = Page.OpenEnrollment_PDF; 
          }
         if(ArticleType=='Single_Topic__kav'){
            ref = Page.SingleTopic_PDF; 
          }
            ref.getParameters().put('id',newID); 
            ref.setRedirect(true);
        Blob b = ref.getContentAsPDF();
        Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
        Messaging.EmailFileAttachment efa1 = new Messaging.EmailFileAttachment();
        efa1.setFileName(attachmentfilename);
        efa1.setBody(b);
        String addresses;
        email.setSubject( Subject );
        email.setToAddresses(EmailIds);
        email.setPlainTextBody(Body);
        email.setFileAttachments(new Messaging.EmailFileAttachment[] {efa1});
        Messaging.SendEmailResult [] r = Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email});
    }
}
I wanted to use if condition, but in order to do that i need to remove static keyword, but Http method are supposed to be static.
How can i solve this???


@RestResource(urlMapping='/sendPDFEmail/*')
Global class GETPDFContent{
     @HttpPost
    global static void sendEmail(String EmailIdCSV, String Subject, String body,string newID,string attachmentfilename,string ArticleTitle,string ArticleType) {
    List<String> EmailIds = EmailIdCSV.split(',');
        if(ArticleType=='Multi_Topic_PDF__kav'){
            PageReference ref = Page.Multi_Topic_PDF; 
          }
 
   
            ref.getParameters().put('id',newID); 
            ref.setRedirect(true);
        Blob b = ref.getContentAsPDF();


        Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();

        Messaging.EmailFileAttachment efa1 = new Messaging.EmailFileAttachment();
        efa1.setFileName(attachmentfilename);
        efa1.setBody(b);

        String addresses;
        email.setSubject( Subject );
        email.setToAddresses(EmailIds);
        email.setPlainTextBody(Body);
        email.setFileAttachments(new Messaging.EmailFileAttachment[] {efa1});
        Messaging.SendEmailResult [] r = Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email});

    }
}
My Code:
trigger Send_PDF_to_SharePointhelp on QNews__c (after insert, after update) {
    for(QNews__c qn: Trigger.new){    
        SendVFAsAttachment.sendVF('vijaku@xxx.com','Sample Test from Trigger','Sample Email Body',UserInfo.getSessionId(),qn.Article_ID__c); 
    }
}





public class SendVFAsAttachment{

    @future(callout=true)
    public static void sendVF(String EmailIdCSV, String Subject,String body,String userSessionId, ID articleid)
    {
        system.debug('====================6=====');
        //Replace below URL with your Salesforce instance host
        String addr = 'https://xxx--kmbuild.cs10.my.salesforce.com/services/apexrest/sendPDFEmail';
        HttpRequest req = new HttpRequest();
        req.setEndpoint( addr );
        req.setMethod('POST');
        req.setHeader('Authorization', 'OAuth ' + userSessionId);
        req.setHeader('Content-Type','application/json');

        Map<String,String> postBody = new Map<String,String>();
        postBody.put('EmailIdCSV',EmailIdCSV);
        postBody.put('Subject',Subject);
        postBody.put('body',body);
        postBody.put(articleid,articleid);
        String reqBody = JSON.serialize(postBody);

        req.setBody(reqBody);
        Http http = new Http();
        HttpResponse response = http.send(req);
    }
}




@RestResource(urlMapping='/sendPDFEmail/*')
Global class GETPDFContent{
     @HttpPost
    global static void sendEmail(String EmailIdCSV, String Subject, String body,ID articleid) {

    List<String> EmailIds = EmailIdCSV.split(',');
        system.debug('====================7=====articleid:'+articleid);
        PageReference ref = Page.Multi_Topic_PDF;
        ref.getParameters().put('id',(String)articleid); 
            ref.setRedirect(true);
        Blob b = ref.getContentAsPDF();
        system.debug('====================10====blob:'+b);
        Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();

        Messaging.EmailFileAttachment efa1 = new Messaging.EmailFileAttachment();
        efa1.setFileName('attachment_WORK.pdf');
        efa1.setBody(b);

        String addresses;
        email.setSubject( Subject +String.valueOf(DateTime.now()));
        email.setToAddresses(EmailIds);
        email.setPlainTextBody(Body);
        email.setFileAttachments(new Messaging.EmailFileAttachment[] {efa1});
        Messaging.SendEmailResult [] r = Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email});

    }
}
I wrote a trigger to send email with attachment generated from vfp,

--->trigger Send_PDF_to_SharePointhelp on QNews__c (after insert, after update) {
  SendVFAsAttachment.sendVF('vijaku@xxx.com','Sample Test from Trigger','Sample Email Body',UserInfo.getSessionId()); 
}

--->public class SendVFAsAttachment{

    @future(callout=true)
    public static void sendVF(String EmailIdCSV, String Subject,String body,String userSessionId)
    {
        //Replace below URL with your Salesforce instance host
        String addr = 'https://vsp--kmbuild.cs10.my.salesforce.com/services/apexrest/sendPDFEmail';
        HttpRequest req = new HttpRequest();
        req.setEndpoint( addr );
        req.setMethod('POST');
        req.setHeader('Authorization', 'OAuth ' + userSessionId);
        req.setHeader('Content-Type','application/json');

        Map<String,String> postBody = new Map<String,String>();
        postBody.put('EmailIdCSV',EmailIdCSV);
        postBody.put('Subject',Subject);
        postBody.put('body',body);
        String reqBody = JSON.serialize(postBody);

        req.setBody(reqBody);
        Http http = new Http();
        HttpResponse response = http.send(req);
    }
}

------>@RestResource(urlMapping='/sendPDFEmail/*')
Global class GETPDFContent{
     @HttpPost
    global static void sendEmail(String EmailIdCSV, String Subject, String body) {

    List<String> EmailIds = EmailIdCSV.split(',');

        PageReference ref = Page.Multi_Topic_PDF;
        Blob b = ref.getContentAsPDF();
        system.debug('====================10====blob:'+b);
        Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();

        Messaging.EmailFileAttachment efa1 = new Messaging.EmailFileAttachment();
        efa1.setFileName('attachment_WORK.pdf');
        efa1.setBody(b);

        String addresses;
        email.setSubject( Subject +String.valueOf(DateTime.now()));
        email.setToAddresses(EmailIds);
        email.setPlainTextBody(Body);
        email.setFileAttachments(new Messaging.EmailFileAttachment[] {efa1});
        Messaging.SendEmailResult [] r = Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email});

    }
}
I'm getting error because i'm using getcontent() method in trigger, is there any other way to solve??
My code:
trigger Send_PDF_to_SharePoint on QNews__c (after insert, after update) {
    for(QNews__c qn: Trigger.new)
    {
        Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
        // Reference the attachment page and pass in the ID
        if(qn.Article_Type__c=='Multi_Topic__kav'){
            PageReference pdf =  Page.Multi_Topic_PDF;
            pdf.getParameters().put('id',(String)qn.Article_ID__c); 
            pdf.setRedirect(true);
            system.debug('================10========'+qn.Article_Title__c+'========='+qn.Article_ID__c);
            system.debug('================11==========='+pdf);
        // Take the PDF content
        Blob b = pdf.getContent();//line 13

        // Create the email attachment
        Messaging.EmailFileAttachment efa = new Messaging.EmailFileAttachment();
        efa.setBody(b);
        efa.setContentType('application/pdf');
        efa.setFileName(qn.Article_Title__c+'_'+qn.Article_Version_Number__c+'.pdf');
        
        String body='This attachment is the PDF copy of Article:'+qn.Article_Title__c+'with version number'+qn.Article_Version_Number__c;    
        String[] toAddresses = new String[]{'vijaku@vsp.com'};
        email.setToAddresses(toAddresses);
        email.setSubject(qn.Data_Category__c);
        email.setPlainTextBody( body );
        email.setFileAttachments(new Messaging.EmailFileAttachment[] {efa});
        Messaging.SendEmailResult [] r = Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email});           
       } 
    }
       
}
I have a Vfp with standard controller="Single_Topic__KAV" and controller extension="Feedbackctrl".
There is a custom checkbox field in Single_Topic__KAV, i want that field value in controller.

In VFP:
i can get the checkbox field by:
<apex:outputfield value="Single_Topic__KAV.Preview_Flag__c"/>

i need the field value to use in controller for:
If(Preview_Flag__c==false){---------------------------}
else{---------------------}
else{--------------------------------}
I have set the size of batch to 1 in apex scheduler, i don't know how to set in test class. please help
My apex scheduler code:
global class ArticleBatchScheduler implements Schedulable{
   global void execute(SchedulableContext sc) {
      // Implement any logic to be scheduled. We now call the batch class to be scheduled. Parameters of ExecuteBatch(context,BatchSize)
      database.executebatch(New ArticleBatch(),1);
   } 
}

Test Class:
@isTest(SeeAllData=true)
public class TestBatchApex{
    static testmethod void validateArticleBatchScheduler(){
        Test.startTest();
            String CRON_EXP = '0 0 0 1 1 ? 2025';  
            String jobId = System.schedule('testScheduledApex', CRON_EXP, new ArticleBatchScheduler());
            CronTrigger ct = [select id, CronExpression, TimesTriggered, NextFireTime from CronTrigger where id = :jobId];
            System.assertEquals(CRON_EXP, ct.CronExpression); 
            System.assertEquals(0, ct.TimesTriggered);
            System.assertEquals('2025-01-01 00:00:00', String.valueOf(ct.NextFireTime));
        Test.stopTest();
    }
}
I'm opening a VFP2 in a frame in VFP1. In VFP2 i hava an enhanced list. when i click on edit it shows the error"This content cannot be displayed in a frame". please i need help

VFP1:
<apex:page sidebar="false" showHeader="true"  id="page" title="Quest">
    <script language="JavaScript" type="text/javascript">    
    function cleariFrame(source){        
        if(source == '')
        {
            var iframe = document.getElementById('questframe').src="";     
        }else{
            var iframe = document.getElementById('questframe').src=""; 
            var iframe = document.getElementById('questframe').src=source;
        }        
    }
    </script>
    <apex:tabPanel selectedTab="News" id="QuestTabPanel"  tabClass="activeTab" inactiveTabClass="inactiveTab"  switchType="client">
        <apex:tab label="News" name="News" id="tab1" ontabenter="cleariFrame('/apex/QNewsList_VFP')"/>
    </apex:tab>
</apex:tabpanel>
<apex:iframe id="questframe" src="/apex/QNewsList_VFP" scrolling="true"/>
</apex:page>

VFP2:
<apex:page sidebar="false">
    <script language="JavaScript" type="text/javascript">  
            if (window.location != window.parent.location) {        
                document.getElementById('AppBodyHeader').style.display = "none";
                document.getElementById('sidebarCell').style.display = "none";               
            }     
    </script>
    <apex:includeScript value="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"/>
    <script>
        j$ = jQuery.noConflict();
        j$(document).ready(function() {
        j$('.bPageFooter').hide();
        });
    </script>
    <apex:enhancedList type="QNews__c" height="500" rowsPerPage="10" id="QNewsList"   />
</apex:page>
                                          
The code coverage is still 0%, even though it is successfull. need some help plz
My Trigger:
trigger ArticleFeedbackAfterTrigger on Article_Feedback__c (after insert, after update) {
    List<FeedItem> lstFeeds = new List<FeedItem>();  
    for(Article_Feedback__c af : Trigger.new) {
        FeedItem fi = new FeedItem();
        fi.Type = 'TextPost';
        fi.Title= af.Name;
        fi.ParentId = af.Article_ID__c;
        fi.Body = af.Comments__c;
        fi.CreatedById=af.CreatedById;
        lstFeeds.add(fi);
    }
    if(lstFeeds.size() > 0) { insert lstFeeds; }
}
My Test Class:
@isTest
private class ArticleFeedbackTrigger_test {

    static testmethod void test_trigger(){
        Article_Feedback__c af =new Article_Feedback__c(Article_ID__c='kac236789045672000',Comments__c='Body for the feed');
        //insert af;
        List<FeedItem> lstFeeds = new List<FeedItem>();
        FeedItem fi = new FeedItem();
        fi.Type = 'TextPost';
        fi.Title= 'test article';
        //fi.ParentId = af.Article_ID__c;
        fi.Body = af.Comments__c;       
        //Name='test_article',,CreatedById='kac895643289456000'
        lstFeeds.add(fi);
        system.assertEquals(fi.Body ,'Body for the feed');
    }
}
Never wrote a test class before, need some help.Here i'm getting data from custom settings

My_Class:
public class EligibilityTabController{
    public CatTabDefault__c EligibilityTab {get; set;}
    public list<CatTabDefault__c> catset {get; set;}   
    public String links;     
    public EligibilityTabController() { 
        catset = CatTabDefault__c.getAll().values();
        EligibilityTab = CatTabDefault__c.getInstance('Eligibility');           
        links= [SELECT Links__c FROM Category_Tab_Link__kav WHERE PublishStatus = 'online' AND Language = 'en_US' AND UrlName =:                           EligibilityTab.Category_Links__c].Links__c;      
         }                
    public String getEligicatlinks() {
        return links;      
    }    
}

Test class:
@isTest
public class EligibilityTabController_TestClass{
    public static testMethod void myUnitTesting(){
        //test coding
    }    
}
I need to move the text to right side by certain points on visualforce page:
<apex:outputText >At least one Reason is required</apex:outputText>
<apex:outputText >Use Ctrl+Click to select more than One Reason</apex:outputText> 
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 List<Core_Benefit__DataCategorySelection> CatDetails;  
    public Core_Benefit__kav cbk {get; set;}
    public Boolean hiddenvaluesflag {get;set;}    
    public string ID=apexpages.currentpage(). getParameters().get('id');
    
    
    public GetURLnew(ApexPages.KnowledgeArticleVersionStandardController controller) {
        hiddenvaluesflag=false;
        String message = '' + ApexPages.CurrentPage().GetParameters().Get('message');
        String pageHeaderReferer = ApexPages.currentPage().getHeaders().get('Referer');             
        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 List<Core_Benefit__DataCategorySelection> getCategory() {
        return CatDetails;
    }
    public PageReference saveclick() {
        ArticleFeedbackObj = new Article_Feedback__c();          
        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__c = '';
        if(CatDetails.DataCategoryName != null && !CatDetails.DataCategoryName.isEmpty()) {
            for(Integer i=0; i < CatDetails.DataCategoryName.size(); i++) {
                ArticleFeedbackObj.Data_Category__c  = ArticleFeedbackObj.Data_Category__c+';'+CatDetails.DataCategoryName[i];
            }
        }

        //ArticleFeedbackObj.Data_Category_Group__c=CatDetails.DataCategoryGroupName;
        system.debug('----------------------76--reasons:'+reasons);
        ArticleFeedbackObj.Reason__c = '';
        if(reasons != null && !reasons.isEmpty()) {
            for(Integer i=0; i < reasons.size(); i++) {
                ArticleFeedbackObj.Reason__c = ArticleFeedbackObj.Reason__c+';'+reasons[i];
            }
        }
        
        system.debug('----------------------78---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('----------------------83--pg:'+pg);
        return pg;
        */
        reasons = new List<String>();
        comments = '';
        ApexPages.addMessage(new ApexPages.Message ( ApexPages.Severity.INFO, 'Successfully Inserted.'));
        return null;
    }   
}
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;
    }   
}
I need to pass 'BenefitsTab' string from vfp1 to vfp2 when i click command button in vfp1 which calls vfp2 into iframe. Plz help.This avoids me to write 11 VFP's
VFP 1:
<apex:page controller="BenefitsTabControllernew" access="global" id="benecomp">
    <apex:iframe src="/{!BenefitsTab.Default_Article__c}&isdtp=vw" id="mainframe" rendered="{!Benefitsframeflag}" scrolling="true" />
    <apex:commandButton value="Search Articles" onclick="document.getElementById('mainframe').src='/apex/Article_ResultsList';return false" id="submitButton" rerender="benefitspanel"/>
  <!-- I Need To pass 'BenefitsTab' string from this page to another VFP2-->
         
</apex:page>


VFP 2:
<apex:page sidebar="false" title="Article List" controller="BenefitsTabControllernew" standardStylesheets="false" showHeader="false" >
<knowledge:articleList articleVar="article" pageNumber="{!currentPageNumber}" categories="{!BenefitsTab.Search_Category__c}" Keyword="{!searchstring}" hasMoreVar="false" pageSize="10">
</knowledge:articleList>
</apex:page>
Trigger on a object Article_Feedback__c triggers whenever a record is created, and gets Article_ID__c,Comments__c,CreatedById,Name FROM Article_Feedback__c and creates a new record in Core_Benefit__Feed obj.

So far i got:
My Code:
trigger createfeed on Article_Feedback__c (after insert,after update) {
    public Core_Benefit__Feed feedobj = new Core_Benefit__Feed();
    Public Article_Feedback__c FeedItem;
   
    FeedItem=[SELECT Article_ID__c,Comments__c,CreatedById,Name FROM Article_Feedback__c];
   
    if(Trigger.isAfter){
        if(Trigger.isInsert || Trigger.isUpdate){
       
        //feedobj.ParentId=FeedItem.Article_ID__c;
        //feedobj.Title=FeedItem.Name;
        //feedobj.InsertedById=FeedItem.CreatedById;
        //feedobj.Body=FeedItem.Comments__c;
        //feedobj.Type='Textpost';
        }
    }
}
Hi All,

I have created a public custom metadata types and I wanted to provide access to salesforce end users to allow create, edit and delete the records in custom metadata type through profiles or permission sets. How can I do that?

Thanks,
Vijay.
Public Class ICS_WR_Warranty_Util{
	public static Boolean Processorfraudcheck(MAP<string,string> mapQryParameter)
    {
        ICS_WR_ConsumingPMFTData.ValidateProcessorResult   Response = ICS_WR_ConsumingPMFTData.get_ValidateProcessor_data(mapQryParameter);
        //string boxtray =response.BoxTrayIndicator;
		//Response = ValidateProcessorResult:[BoxTrayIndicator=Boxed, Last_Ship_To_Date=20101227000000, ProductFrequencyData=null, ProtectionPlanData=null, Rtl_Box_Manufacture_Dt=null, Rtl_Box_Mtrl_Id=null, Rtl_Box_SN=null, Rtl_Box_Site_Id=null, ShipmentInfo=ShipmentInfo:[ShipmentData=(ShipmentData:[AGIDDate=2010-12-08 00:00:00, Batch=L040B436, BoxTrayIndicator=BOX, ChildBoxId=KN0RW873, Level4Prod=CM8062300833803, MaterialMasterNumber=909498, ShipToCustomerCountryCode=US, ShipToCustomerCountryName=United States, ShipToCustomerGeo=ASMO-NA, ShipToCustomerId=SUB-MLMIA, ShipToCustomerName=MODUSLINK, VisualId=null], ShipmentData:[AGIDDate=2010-12-08 00:00:00, Batch=L040B436, BoxTrayIndicator=BOX, ChildBoxId=KN0RW872, Level4Prod=CM8062300833803, MaterialMasterNumber=909498, ShipToCustomerCountryCode=US, ShipToCustomerCountryName=United States, ShipToCustomerGeo=ASMO-NA, ShipToCustomerId=SUB-MLMIA, ShipToCustomerName=MODUSLINK, VisualId=null], ShipmentData:[AGIDDate=2010-12-22 00:00:00, Batch=L040B436, BoxTrayIndicator=BOX, ChildBoxId=null, Level4Prod=BX80623I52500K, MaterialMasterNumber=910679, ShipToCustomerCountryCode=US, ShipToCustomerCountryName=United States, ShipToCustomerGeo=ASMO-NA, ShipToCustomerId=0007011339, ShipToCustomerName=INGRAM US (CA) DSS, VisualId=null], ShipmentData:[AGIDDate=2010-12-23 00:00:00, Batch=L040B436, BoxTrayIndicator=BOX, ChildBoxId=null, Level4Prod=BX80623I52500K, MaterialMasterNumber=910679, ShipToCustomerCountryCode=US, ShipToCustomerCountryName=United States, ShipToCustomerGeo=ASMO-NA, ShipToCustomerId=0002002899, ShipToCustomerName=#10; FRYS, VisualId=null], ShipmentData:[AGIDDate=2010-12-23 00:00:00, Batch=L040B436, BoxTrayIndicator=BOX, ChildBoxId=null, Level4Prod=BX80623I52500K, MaterialMasterNumber=910679, ShipToCustomerCountryCode=US, ShipToCustomerCountryName=United States, ShipToCustomerGeo=ASMO-NA, ShipToCustomerId=0002002900, ShipToCustomerName=#11; FRYS, VisualId=null], ShipmentData:[AGIDDate=2010-12-27 00:00:00, Batch=L040B436, BoxTrayIndicator=BOX, ChildBoxId=null, Level4Prod=BX80623I52500K, MaterialMasterNumber=910679, ShipToCustomerCountryCode=CA, ShipToCustomerCountryName=Canada, ShipToCustomerGeo=ASMO-NA, ShipToCustomerId=0002002614, ShipToCustomerName=INGRAM MICRO CANADA INCORPORATED, VisualId=null], ShipmentData:[AGIDDate=2010-12-27 00:00:00, Batch=L040B436, BoxTrayIndicator=BOX, ChildBoxId=null, Level4Prod=BX80623I52500K, MaterialMasterNumber=910679, ShipToCustomerCountryCode=CA, ShipToCustomerCountryName=Canada, ShipToCustomerGeo=ASMO-NA, ShipToCustomerId=0002002614, ShipToCustomerName=INGRAM MICRO CANADA INCORPORATED, VisualId=null])], ValidationResultCodes=ValidationResultCodes:[ValidationResultCode=(ValidationResultCode:[Remarks=null, ValidationResultCodeId=27, ValidationResult_Code=PMFT-027])]]
        return null;
    }
}



Public class  ICS_WR_ConsumingPMFTData{
	public static ValidateProcessorResult get_ValidateProcessor_data(MAP<string,string> mapQryParameter)
   {
        if(mapQryParameter!=null &&mapQryParameter.keyset()!=null )
        {
            try
            {
                string processorOutpuFormat;
                if(mapQryParameter.containskey('FPO') && mapQryParameter.keyset().size()==1) // If only FPO passing as input parameter
                {
                processorOutpuFormat='{ "Last_Ship_To_Date": "20101227000000","BoxTrayIndicator": "Boxed", "ValidationResultCodes":{"ValidationResultCode" : [{"ValidationResultCodeId": "27","ValidationResult_Code": "PMFT-027"}]},"ShipmentInfo": {"ShipmentData": [{"Batch": "L040B436","MaterialMasterNumber": "909498","ChildBoxId": "KN0RW873","Level4Prod": "CM8062300833803","ShipToCustomerId": "SUB-MLMIA","ShipToCustomerName": "MODUSLINK","ShipToCustomerCountryCode": "US", "ShipToCustomerCountryName": "United States", "ShipToCustomerGeo": "ASMO-NA", "AGIDDate": "2010-12-08T00:00:00Z", "BoxTrayIndicator": "BOX"},{ "Batch": "L040B436", "MaterialMasterNumber": "909498", "ChildBoxId": "KN0RW872","Level4Prod": "CM8062300833803", "ShipToCustomerId": "SUB-MLMIA", "ShipToCustomerName": "MODUSLINK","ShipToCustomerCountryCode": "US","ShipToCustomerCountryName": "United States","ShipToCustomerGeo": "ASMO-NA","AGIDDate": "2010-12-08T00:00:00Z", "BoxTrayIndicator": "BOX"},{"Batch": "L040B436", "MaterialMasterNumber": "910679", "Level4Prod": "BX80623I52500K", "ShipToCustomerId": "0007011339","ShipToCustomerName": "INGRAM US (CA) DSS","ShipToCustomerCountryCode": "US", "ShipToCustomerCountryName": "United States", "ShipToCustomerGeo": "ASMO-NA","AGIDDate": "2010-12-22T00:00:00Z","BoxTrayIndicator": "BOX"},{ "Batch": "L040B436", "MaterialMasterNumber": "910679", "Level4Prod": "BX80623I52500K", "ShipToCustomerId": "0002002899", "ShipToCustomerName": "#10; FRYS", "ShipToCustomerCountryCode": "US",  "ShipToCustomerCountryName": "United States","ShipToCustomerGeo": "ASMO-NA", "AGIDDate": "2010-12-23T00:00:00Z", "BoxTrayIndicator": "BOX"}, { "Batch": "L040B436", "MaterialMasterNumber": "910679","Level4Prod": "BX80623I52500K", "ShipToCustomerId": "0002002900", "ShipToCustomerName": "#11; FRYS",  "ShipToCustomerCountryCode": "US",  "ShipToCustomerCountryName": "United States", "ShipToCustomerGeo": "ASMO-NA",  "AGIDDate": "2010-12-23T00:00:00Z",  "BoxTrayIndicator": "BOX" },{   "Batch": "L040B436","MaterialMasterNumber": "910679",  "Level4Prod": "BX80623I52500K",  "ShipToCustomerId": "0002002614", "ShipToCustomerName": "INGRAM MICRO CANADA INCORPORATED", "ShipToCustomerCountryCode": "CA","ShipToCustomerCountryName": "Canada", "ShipToCustomerGeo": "ASMO-NA", "AGIDDate": "2010-12-27T00:00:00Z", "BoxTrayIndicator": "BOX" },{ "Batch": "L040B436",  "MaterialMasterNumber": "910679","Level4Prod": "BX80623I52500K","ShipToCustomerId": "0002002614", "ShipToCustomerName": "INGRAM MICRO CANADA INCORPORATED", "ShipToCustomerCountryCode": "CA",  "ShipToCustomerCountryName": "Canada", "ShipToCustomerGeo": "ASMO-NA", "AGIDDate": "2010-12-27T00:00:00Z", "BoxTrayIndicator": "BOX" } ]}}';
                }
                else if(mapQryParameter.containskey('FPO') && mapQryParameter.containskey('ATPO')&& mapQryParameter.keyset().size()==2) //if FPO & ATPO passing as input parameter
                {
                    processorOutpuFormat='{"Rtl_Box_SN": "2V034116A2110","Rtl_Box_Site_Id": "CS79","Rtl_Box_Mtrl_Id": "910679","Rtl_Box_Manufacture_Dt": "20101220000000","Last_Ship_To_Date": "20101223000000","BoxTrayIndicator": "Boxed","ValidationResultCodes":{"ValidationResultCode" : [{"ValidationResultCodeId": "28","ValidationResult_Code": "PMFT-028"},{"ValidationResultCodeId": "27","ValidationResult_Code": "PMFT-027"},{"ValidationResultCodeId": "35","ValidationResult_Code": "PMFT-035"}]},"ShipmentInfo":{"ShipmentData": [{"Batch": "L040B436","VisualId": "2V034116A2110","MaterialMasterNumber": "910679","ChildBoxId": "96200200","Level4Prod": "BX80623I52500K","ShipToCustomerId": "0002002899","ShipToCustomerName": "#10; FRYS","ShipToCustomerCountryCode": "US","ShipToCustomerCountryName": "United States","ShipToCustomerGeo": "ASMO-NA","AGIDDate": "2010-12-23T00:00:00Z","BoxTrayIndicator": "BOX"}]}}';
                }
                else if(mapQryParameter.containskey('FPO') && mapQryParameter.containskey('PAC')&& mapQryParameter.keyset().size()==2) //if FPO & PAC passing as input parameter
                {
                    processorOutpuFormat='{"Rtl_Box_SN": "2V034116A2110","Rtl_Box_Site_Id": "CS79","Rtl_Box_Mtrl_Id": "910679","Rtl_Box_Manufacture_Dt": "20101220000000","Last_Ship_To_Date": "20101223000000","BoxTrayIndicator": "Boxed","ValidationResultCodes": {"ValidationResultCode" : [{"ValidationResultCodeId": "28","ValidationResult_Code": "PMFT-028"},{"ValidationResultCodeId": "27","ValidationResult_Code": "PMFT-027"},{"ValidationResultCodeId": "35","ValidationResult_Code": "PMFT-035"},{"ValidationResultCodeId": "101","ValidationResult_Code": "PTP-101","Remarks": "Plan is available and authenticated."}]},"ShipmentInfo": {"ShipmentData":[{"Batch": "L040B436","VisualId": "2V034116A2110","MaterialMasterNumber": "910679","ChildBoxId": "96200200","Level4Prod": "BX80623I52500K","ShipToCustomerId": "0002002899","ShipToCustomerName": "#10; FRYS","ShipToCustomerCountryCode": "US","ShipToCustomerCountryName": "United States","ShipToCustomerGeo": "ASMO-NA","AGIDDate": "2010-12-23T00:00:00Z","BoxTrayIndicator": "BOX"}]},"ProtectionPlanData": {"TransactionId": "24","TransactionDate": "20111111213805","SKU": "BX80623I52500K","PlanActivationCode": "000AB3EO","PlanEffectiveDate": "20111212213805","PaidByUserId": "cpsdtest13@gmail.com","PaidByUserFullName": "E D","LastOwnedByUserId": "cpsdtest01@gmail.com","LastOwnedByUserFullName": "CPSD Test"}}';
                }
                ValidateProcessorResult prData =new ValidateProcessorResult();
                prData=(ValidateProcessorResult)JSON.deserialize(processorOutpuFormat,ValidateProcessorResult.class); //De-serializing output json format
                system.debug('prData##'+prData) ;
                return prData;
            }
            Catch(Exception e)
            {
                isError=true;
            }
        }
        return null;
        
    }

	public class ValidateProcessorResult{
        public ShipmentInfo ShipmentInfo{get;set;}
        public String Last_Ship_To_Date{get;set;}
        public String Rtl_Box_Manufacture_Dt{get;set;}
        public String BoxTrayIndicator{get;set;}
        public String Rtl_Box_Mtrl_Id{get;set;}
        public ValidationResultCodes ValidationResultCodes{get;set;}
        public ProductFrequencyData ProductFrequencyData{get;set;}
        public String Rtl_Box_Site_Id{get;set;}
        public ProtectionPlanData ProtectionPlanData{get;set;}
        public String Rtl_Box_SN{get;set;}
        }
   
    public class ProductFrequencyData
    {
         public list<ProductFrequency> ProductFrequency{get;set;}
    }
    public class ValidationResultCodes
    {
         public list<ValidationResultCode> ValidationResultCode{get;set;}
    }
    public class ShipmentInfo{
        public list<ShipmentData> ShipmentData{get;set;}
        
    }
    public class ProductFrequency{
        public Integer FrequencyType{get;set;}
        public String FreqeuncyCount{get;set;}
    }
     public class ValidationResultCode {
        public String ValidationResult_Code{get;set;}
        public String ValidationResultCodeId{get;set;}
        public String Remarks{get;set;}
    }
    public class ShipmentData{
        public String ShipToCustomerCountryCode{get;set;}
        public String ShipToCustomerCountryName{get;set;}
        public String ShipToCustomerGeo{get;set;}
        public String ShipToCustomerName{get;set;}
        public DateTime AGIDDate{get;set;}
        public String ShipToCustomerId{get;set;}
        public String BoxTrayIndicator{get;set;}
        public String Level4Prod{get;set;}
        public String MaterialMasterNumber{get;set;}
        public String VisualId{get;set;}
        public String ChildBoxId{get;set;}
        public String Batch{get;set;}
    }
    public class ProtectionPlanData{
        public String SKU{get;set;}
        public String PaidByUserId{get;set;}
        public String PlanEffectiveDate{get;set;}
        public String PaidByUserFullName{get;set;}
        public String PlanActivationCode{get;set;}
        public String LastOwnedByUserId{get;set;}
        public String TransactionDate{get;set;}
        public String LastOwnedByUserFullName{get;set;}
        public Integer TransactionId{get;set;}
    }

}

I'm calling a method ICS_WR_ConsumingPMFTData.get_ValidateProcessor_data(mapQryParameter) and I get a deserialized Json response which I shown as a comment in the class. How can I read the response into different variables to use ?
My usecase is, the BatchApex creates a record on QNews__c object whenever a new article is published or new versioned.
In execute method of BatchApex i wrote a code to send email with pdf as attachment. But i'm getting an email with empty pdf file. Any help???

My Execute Batch Code:
public class QNewsUpdateBatch {  
    public class QnewsWrapper{
        public String strArticleId{get;set;}
        public String strArticleTitle{get;set;}
        public String strArticleType{get;set;}
        public String strArticleURL{get;set;}
        public String strArticelVersionNumber{get;set;}
        public String strDataCategory{get;set;}
        public String strDataCategoryGroupName{get;set;}
        public String strDataCategorySelectionId{get;set;}
        public Boolean blnFederalCompliance{get;set;}
        public DateTime lastPublishedDate{get;set;}
        public Boolean blnStateCompliance{get;set;}
        public String strVersionComments{get;set;}
        public String strVersionHistoryId{get;set;}
        public String strVersionHistoryParentid{get;set;}
        public String strVrsionHistoryVersionId{get;set;} 
        public boolean blnBestPractice{get;set;}
        public String strDataCategoryParentId{get;set;}
    }
    public void insertQnewsData(String strArticleType){
        
        Map<Id,Id> VersionParentMap = new Map<Id,Id>();
        Map<Id,Id> VersionIdMap = new Map<Id,Id>();
        List<SObject> lst_versionhistory = Database.Query('SELECT VersionNumber,VersionId,ParentSobjectType,ParentId,Id,EventType,CreatedDate FROM '+strArticleType+'__VersionHistory  where (EventType=\'KavPublishedNew\' or EventType=\'KavPublished\') and ParentSobjectType=\''+strArticleType+'\'');  
        List<QnewsWrapper> listQnews = new List<QnewsWrapper>();
        for(SObject obj:lst_versionhistory){
            VersionParentMap.put((Id)obj.get('versionId'),(Id)obj.get('ParentId'));
            VersionIdMap.put((Id)obj.get('versionId'),(Id)obj.get('Id'));
        }         
        if(VersionParentMap!=null && VersionParentMap.size()>0){
            Set<Id> VersionParentSet = VersionParentMap.keySet();
            List<SObject> lst_DataCategory = Database.Query('Select Id,DataCategoryName,DataCategoryGroupName,ParentId from '+strArticleType+'__DataCategorySelection where ParentId IN :VersionParentSet');
            for(SObject obj:lst_DataCategory){
                        QnewsWrapper qnewsObj = new QnewsWrapper();
                        
                        qnewsObj.strDataCategory = (String)obj.get('DataCategoryName');
                        qnewsObj.strDataCategoryGroupName = (String)obj.get('DataCategoryGroupName');
                        qnewsObj.strDataCategorySelectionId = (String)obj.get('Id');
                        qnewsObj.strDataCategoryParentId = (String)obj.get('ParentId');
                        
                        listQnews.add(qnewsObj);
            }
            List<SObject> lst_ArticleKAV = Database.Query('Select Id,Version_Comments__c,VersionNumber,UrlName,Title,State_Compliance__c,LastPublishedDate,KnowledgeArticleId,Federal_Compliance__c,Best_Practice__c,ArticleType From '+strArticleType+'__kav where Id IN :VersionParentSet');
            for(SObject obj:lst_ArticleKAV){
                for(QnewsWrapper qnewsObj:listQnews){
                    if(qnewsObj.strDataCategoryParentId == obj.get('Id')){
                        qnewsObj.strVersionComments = (String)obj.get('Version_Comments__c');
                        qnewsObj.strArticelVersionNumber = String.valueOf(obj.get('VersionNumber'));
                        qnewsObj.strArticleURL = (String)obj.get('UrlName');
                        qnewsObj.strArticleTitle = (String)obj.get('Title');
                        qnewsObj.blnStateCompliance = (Boolean)obj.get('State_Compliance__c');
                        qnewsObj.lastPublishedDate = (DateTime)obj.get('LastPublishedDate');
                        qnewsObj.strArticleId = (String)obj.get('KnowledgeArticleId');
                        qnewsObj.blnFederalCompliance = (Boolean)obj.get('Federal_Compliance__c');
                        qnewsObj.blnBestPractice = (Boolean)obj.get('Best_Practice__c');
                        qnewsObj.strArticleType = (String)obj.get('ArticleType');
                        qnewsObj.strVersionHistoryParentid = (String)VersionParentMap.get((Id)obj.get('Id'));
                        qnewsObj.strVersionHistoryId = (String)VersionIdMap.get((Id)obj.get('Id'));
                        qnewsObj.strVrsionHistoryVersionId = (String)obj.get('Id');
                    }
                }
            }
        }
        Set<String> existingQNewsVersionsId = new Set<String>();
        for(QNews__c obj:[Select Id,Version_History_Version_Id__c from QNews__c]){
            existingQNewsVersionsId.add(obj.Version_History_Version_Id__c);
        }
        
        List<QNews__c> qnewsToInsert = new List<QNews__c>();
        
        for(QnewsWrapper obj:listQnews){
            if(!existingQNewsVersionsId.contains(obj.strVrsionHistoryVersionId)){   
                QNews__c qnewsObj = new QNews__c();
                qnewsObj.Data_Category_Selection_Id__c = obj.strDataCategorySelectionId;
                qnewsObj.Data_Category_Group__c = obj.strDataCategoryGroupName;
                qnewsObj.Data_Category__c = obj.strDataCategory;
                qnewsObj.Article_ID__c = obj.strArticleId;
                qnewsObj.Article_URL__c = obj.strArticleURL;
                qnewsObj.Article_Title__c = obj.strArticleTitle;
                qnewsObj.Article_Version_Number__c = obj.strArticelVersionNumber;
                qnewsObj.Version_Comments__c = obj.strVersionComments;
                qnewsObj.Last_Published__c = obj.lastPublishedDate;
                qnewsObj.Article_Type__c = obj.strArticleType;
                qnewsObj.Federal_Compliance__c = obj.blnFederalCompliance;
                qnewsObj.State_Compliance__c = obj.blnStateCompliance;
                qnewsObj.Best_Practice__c = obj.blnBestPractice;
                qnewsObj.Version_History_Id__c = obj.strVersionHistoryId;
                qnewsObj.Version_History_Version_Id__c = obj.strVrsionHistoryVersionId;
                qnewsObj.Version_History_Parent_Id__c = obj.strVersionHistoryParentid;
                string filename = qnewsObj.Article_Title__c+'_'+qnewsObj.Article_Version_Number__c+'.pdf';
                string newarticleID = String.valueOf(qnewsObj.Article_ID__c);
                String emailbody='This attachment is the PDF copy of Article:  '+qnewsObj.Article_Title__c+' with version number '+qnewsObj.Article_Version_Number__c;                  GETPDFContentnew.sendEmail('vijaku@vsp.com',qnewsObj.Data_Category__c,emailbody,newarticleID,filename,qnewsObj.Article_Title__c,qnewsObj.Article_Type__c);  
   
                qnewsToInsert.add(qnewsObj);      
            }
        }
 if(qnewsToInsert!=null && qnewsToInsert.size()>0){
            insert qnewsToInsert;
        }    
    }
}

Class to send email:
Global class GETPDFContentnew{
    global static void sendEmail(String EmailIdCSV, String Subject, String body,string newID,string attachmentfilename,string ArticleTitle,string ArticleType) {
    List<String> EmailIds = EmailIdCSV.split(',');
        PageReference ref = null;      
        if(ArticleType=='Multi_Topic__kav'){
             
            ref = Page.Multi_Topic_PDF; 
          }
         if(ArticleType=='Additional_Benefits__kav'){
            ref = Page.AdditionalBenefits_PDF; 
          }
         if(ArticleType=='Core_Benefit__kav'){
            ref = Page.CoreBenefit_PDF; 
          }
         if(ArticleType=='Multi_Topic_Details__kav'){
            ref = Page.MultiTopicDetails_PDF; 
          }
         if(ArticleType=='Open_Enrollment__kav'){
            ref = Page.OpenEnrollment_PDF; 
          }
         if(ArticleType=='Single_Topic__kav'){
            ref = Page.SingleTopic_PDF; 
          }
        ref.getParameters().put('id',newID); 
            ref.setRedirect(true);
        Blob b = ref.getContentAsPDF();
        Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
        Messaging.EmailFileAttachment efa1 = new Messaging.EmailFileAttachment();
        efa1.setFileName(attachmentfilename);
        efa1.setBody(b);
        String addresses;
        email.setSubject( Subject );
        email.setToAddresses(EmailIds);
        email.setPlainTextBody(Body);
        email.setFileAttachments(new Messaging.EmailFileAttachment[] {efa1});
        Messaging.SendEmailResult [] r = Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email});
    }
}
Hi All,

We are showing a visualforce page that shows some rows of data and added it as a Visualforce page component and showing it in a homepage. But we need to set the height manually. Is there a way we can dynamically set the height of the VF pafe based on the data it shows on the homepage? Any javascript workaround?

Thanks,
Raghu
So my use case is, when a BatchApex runs for every one hour, it inserts records on QNews custom object.
After Trigger fire every time when a record is inserted on QNews object and  sends an email with a PDF attachment.
I’m getting following error when Batch Apex runs, FATAL_ERROR|System.AsyncException: Future method cannot be called from a future or batch method: SendVFAsAttachment.sendVF(String, String, String, String, Id, String, String, String).

My ApexBatch:
global with sharing class ArticleBatch implements Database.Batchable<string>{
public Iterable<string> start(Database.BatchableContext bc)
    return new ArticleBatchIterable();  }

public void execute(Database.BatchableContext bc, List<string> scope){
    string articleTypeName = scope[0];    
    QNewsUpdateBatch batchClassObj = new QNewsUpdateBatch();
    batchClassObj.insertQnewsData(articleTypeName);
}
global void finish(Database.BatchableContext bc){
      //code that sends an email for execution of Batch    
}

My Trigger:
trigger Send_PDF_to_SharePointhelp on QNews__c (after insert, after update) {
    for(QNews__c qn: Trigger.new){
        string filename = qn.Article_Title__c+'_'+qn.Article_Version_Number__c+'.pdf';
        String emailbody='This attachment is the PDF copy of Article:  '+qn.Article_Title__c+' with version number '+qn.Article_Version_Number__c;   SendVFAsAttachment.sendVF('vijaku@vsp.com',qn.Data_Category__c,emailbody,UserInfo.getSessionId(),qn.Article_ID__c,qn.Article_Title__c,filename,qn.Article_Type__c); 
    }  
}

Future Method:
public class SendVFAsAttachment{
    @future(callout=true)
    public static void sendVF(String EmailIdCSV, String Subject,String body,String userSessionId, ID articleid,String ArticleTitle,String attachmentfilename,String ArticleType)
    {
        string newID = String.valueOf(articleid);
        String addr = 'https://vsp--kmbuild.cs10.my.salesforce.com/services/apexrest/sendPDFEmail';
        HttpRequest req = new HttpRequest();
        req.setEndpoint( addr );
        req.setMethod('POST');
        req.setHeader('Authorization', 'OAuth ' + userSessionId);
        req.setHeader('Content-Type','application/json');
        Map<String,String> postBody = new Map<String,String>();
        postBody.put('EmailIdCSV',EmailIdCSV);
        postBody.put('Subject',Subject);
        postBody.put('body',body);
        postBody.put('newID',newID);
        postBody.put('attachmentfilename',attachmentfilename);
        postBody.put('ArticleTitle',ArticleTitle);
        postBody.put('ArticleType',ArticleType);
        String reqBody = JSON.serialize(postBody);
        req.setBody(reqBody);
        Http http = new Http();
        HttpResponse response = http.send(req);
    }
}

Class to send email, exposed to REST API:
@RestResource(urlMapping='/sendPDFEmail/*')
Global class GETPDFContent{
     @HttpPost
    global static void sendEmail(String EmailIdCSV, String Subject, String body,string newID,string attachmentfilename,string ArticleTitle,string ArticleType) {
    List<String> EmailIds = EmailIdCSV.split(',');
        PageReference ref = Page.Multi_Topic_PDF;
        if(ArticleType=='Multi_Topic__kav'){
            ref = Page.Multi_Topic_PDF; 
          }
         if(ArticleType=='Additional_Benefits__kav'){
            ref = Page.AdditionalBenefits_PDF; 
          }
         if(ArticleType=='Core_Benefit__kav'){
            ref = Page.CoreBenefit_PDF; 
          }
         if(ArticleType=='Multi_Topic_Details__kav'){
            ref = Page.MultiTopicDetails_PDF; 
          }
         if(ArticleType=='Open_Enrollment__kav'){
            ref = Page.OpenEnrollment_PDF; 
          }
         if(ArticleType=='Single_Topic__kav'){
            ref = Page.SingleTopic_PDF; 
          }
            ref.getParameters().put('id',newID); 
            ref.setRedirect(true);
        Blob b = ref.getContentAsPDF();
        Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
        Messaging.EmailFileAttachment efa1 = new Messaging.EmailFileAttachment();
        efa1.setFileName(attachmentfilename);
        efa1.setBody(b);
        String addresses;
        email.setSubject( Subject );
        email.setToAddresses(EmailIds);
        email.setPlainTextBody(Body);
        email.setFileAttachments(new Messaging.EmailFileAttachment[] {efa1});
        Messaging.SendEmailResult [] r = Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email});
    }
}
My Code:
trigger Send_PDF_to_SharePointhelp on QNews__c (after insert, after update) {
    for(QNews__c qn: Trigger.new){    
        SendVFAsAttachment.sendVF('vijaku@xxx.com','Sample Test from Trigger','Sample Email Body',UserInfo.getSessionId(),qn.Article_ID__c); 
    }
}





public class SendVFAsAttachment{

    @future(callout=true)
    public static void sendVF(String EmailIdCSV, String Subject,String body,String userSessionId, ID articleid)
    {
        system.debug('====================6=====');
        //Replace below URL with your Salesforce instance host
        String addr = 'https://xxx--kmbuild.cs10.my.salesforce.com/services/apexrest/sendPDFEmail';
        HttpRequest req = new HttpRequest();
        req.setEndpoint( addr );
        req.setMethod('POST');
        req.setHeader('Authorization', 'OAuth ' + userSessionId);
        req.setHeader('Content-Type','application/json');

        Map<String,String> postBody = new Map<String,String>();
        postBody.put('EmailIdCSV',EmailIdCSV);
        postBody.put('Subject',Subject);
        postBody.put('body',body);
        postBody.put(articleid,articleid);
        String reqBody = JSON.serialize(postBody);

        req.setBody(reqBody);
        Http http = new Http();
        HttpResponse response = http.send(req);
    }
}




@RestResource(urlMapping='/sendPDFEmail/*')
Global class GETPDFContent{
     @HttpPost
    global static void sendEmail(String EmailIdCSV, String Subject, String body,ID articleid) {

    List<String> EmailIds = EmailIdCSV.split(',');
        system.debug('====================7=====articleid:'+articleid);
        PageReference ref = Page.Multi_Topic_PDF;
        ref.getParameters().put('id',(String)articleid); 
            ref.setRedirect(true);
        Blob b = ref.getContentAsPDF();
        system.debug('====================10====blob:'+b);
        Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();

        Messaging.EmailFileAttachment efa1 = new Messaging.EmailFileAttachment();
        efa1.setFileName('attachment_WORK.pdf');
        efa1.setBody(b);

        String addresses;
        email.setSubject( Subject +String.valueOf(DateTime.now()));
        email.setToAddresses(EmailIds);
        email.setPlainTextBody(Body);
        email.setFileAttachments(new Messaging.EmailFileAttachment[] {efa1});
        Messaging.SendEmailResult [] r = Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email});

    }
}
The code coverage is still 0%, even though it is successfull. need some help plz
My Trigger:
trigger ArticleFeedbackAfterTrigger on Article_Feedback__c (after insert, after update) {
    List<FeedItem> lstFeeds = new List<FeedItem>();  
    for(Article_Feedback__c af : Trigger.new) {
        FeedItem fi = new FeedItem();
        fi.Type = 'TextPost';
        fi.Title= af.Name;
        fi.ParentId = af.Article_ID__c;
        fi.Body = af.Comments__c;
        fi.CreatedById=af.CreatedById;
        lstFeeds.add(fi);
    }
    if(lstFeeds.size() > 0) { insert lstFeeds; }
}
My Test Class:
@isTest
private class ArticleFeedbackTrigger_test {

    static testmethod void test_trigger(){
        Article_Feedback__c af =new Article_Feedback__c(Article_ID__c='kac236789045672000',Comments__c='Body for the feed');
        //insert af;
        List<FeedItem> lstFeeds = new List<FeedItem>();
        FeedItem fi = new FeedItem();
        fi.Type = 'TextPost';
        fi.Title= 'test article';
        //fi.ParentId = af.Article_ID__c;
        fi.Body = af.Comments__c;       
        //Name='test_article',,CreatedById='kac895643289456000'
        lstFeeds.add(fi);
        system.assertEquals(fi.Body ,'Body for the feed');
    }
}
Never wrote a test class before, need some help.Here i'm getting data from custom settings

My_Class:
public class EligibilityTabController{
    public CatTabDefault__c EligibilityTab {get; set;}
    public list<CatTabDefault__c> catset {get; set;}   
    public String links;     
    public EligibilityTabController() { 
        catset = CatTabDefault__c.getAll().values();
        EligibilityTab = CatTabDefault__c.getInstance('Eligibility');           
        links= [SELECT Links__c FROM Category_Tab_Link__kav WHERE PublishStatus = 'online' AND Language = 'en_US' AND UrlName =:                           EligibilityTab.Category_Links__c].Links__c;      
         }                
    public String getEligicatlinks() {
        return links;      
    }    
}

Test class:
@isTest
public class EligibilityTabController_TestClass{
    public static testMethod void myUnitTesting(){
        //test coding
    }    
}
I need to move the text to right side by certain points on visualforce page:
<apex:outputText >At least one Reason is required</apex:outputText>
<apex:outputText >Use Ctrl+Click to select more than One Reason</apex:outputText> 
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 List<Core_Benefit__DataCategorySelection> CatDetails;  
    public Core_Benefit__kav cbk {get; set;}
    public Boolean hiddenvaluesflag {get;set;}    
    public string ID=apexpages.currentpage(). getParameters().get('id');
    
    
    public GetURLnew(ApexPages.KnowledgeArticleVersionStandardController controller) {
        hiddenvaluesflag=false;
        String message = '' + ApexPages.CurrentPage().GetParameters().Get('message');
        String pageHeaderReferer = ApexPages.currentPage().getHeaders().get('Referer');             
        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 List<Core_Benefit__DataCategorySelection> getCategory() {
        return CatDetails;
    }
    public PageReference saveclick() {
        ArticleFeedbackObj = new Article_Feedback__c();          
        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__c = '';
        if(CatDetails.DataCategoryName != null && !CatDetails.DataCategoryName.isEmpty()) {
            for(Integer i=0; i < CatDetails.DataCategoryName.size(); i++) {
                ArticleFeedbackObj.Data_Category__c  = ArticleFeedbackObj.Data_Category__c+';'+CatDetails.DataCategoryName[i];
            }
        }

        //ArticleFeedbackObj.Data_Category_Group__c=CatDetails.DataCategoryGroupName;
        system.debug('----------------------76--reasons:'+reasons);
        ArticleFeedbackObj.Reason__c = '';
        if(reasons != null && !reasons.isEmpty()) {
            for(Integer i=0; i < reasons.size(); i++) {
                ArticleFeedbackObj.Reason__c = ArticleFeedbackObj.Reason__c+';'+reasons[i];
            }
        }
        
        system.debug('----------------------78---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('----------------------83--pg:'+pg);
        return pg;
        */
        reasons = new List<String>();
        comments = '';
        ApexPages.addMessage(new ApexPages.Message ( ApexPages.Severity.INFO, 'Successfully Inserted.'));
        return null;
    }   
}
Hi Buddies,
I was not able to pass the parameters via actionfunction to the controller. Even controller is not executed by clicking the button. Please check it and let me know where i need to change.
VF Page:
      <apex:commandButton value="Next" style="width:90px;margin-left:360px;" onclick="changeValue();"/>
    <script>
        function changeValue() {
           var c=document.getElementById("mradio").value;
            priorityval(c);
            alert(c);
        }
    </script>
    <apex:actionFunction name="priorityval" action="{!runPriority}">
          <apex:param name="priorityname" value="" assignTo="{!priorityname}"/>
      </apex:actionFunction>
Class:
 public string priorityname{get;set;}
    Public Pagereference runPriority(){
        System.debug('Priority Value@@@'+priorityname+'**RecrdTypeId**'+recrdtypeid);
        PageReference pgRef=new PageReference('/apex/CasePage?RecordType='+recrdtypeid+'&priority='+priorityname);
        pgRef.setRedirect(true);
    return pgRef;   
 }

Please advice me, Thanks in advance!!
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;
    }   
}
I need to pass 'BenefitsTab' string from vfp1 to vfp2 when i click command button in vfp1 which calls vfp2 into iframe. Plz help.This avoids me to write 11 VFP's
VFP 1:
<apex:page controller="BenefitsTabControllernew" access="global" id="benecomp">
    <apex:iframe src="/{!BenefitsTab.Default_Article__c}&isdtp=vw" id="mainframe" rendered="{!Benefitsframeflag}" scrolling="true" />
    <apex:commandButton value="Search Articles" onclick="document.getElementById('mainframe').src='/apex/Article_ResultsList';return false" id="submitButton" rerender="benefitspanel"/>
  <!-- I Need To pass 'BenefitsTab' string from this page to another VFP2-->
         
</apex:page>


VFP 2:
<apex:page sidebar="false" title="Article List" controller="BenefitsTabControllernew" standardStylesheets="false" showHeader="false" >
<knowledge:articleList articleVar="article" pageNumber="{!currentPageNumber}" categories="{!BenefitsTab.Search_Category__c}" Keyword="{!searchstring}" hasMoreVar="false" pageSize="10">
</knowledge:articleList>
</apex:page>
Trigger on a object Article_Feedback__c triggers whenever a record is created, and gets Article_ID__c,Comments__c,CreatedById,Name FROM Article_Feedback__c and creates a new record in Core_Benefit__Feed obj.

So far i got:
My Code:
trigger createfeed on Article_Feedback__c (after insert,after update) {
    public Core_Benefit__Feed feedobj = new Core_Benefit__Feed();
    Public Article_Feedback__c FeedItem;
   
    FeedItem=[SELECT Article_ID__c,Comments__c,CreatedById,Name FROM Article_Feedback__c];
   
    if(Trigger.isAfter){
        if(Trigger.isInsert || Trigger.isUpdate){
       
        //feedobj.ParentId=FeedItem.Article_ID__c;
        //feedobj.Title=FeedItem.Name;
        //feedobj.InsertedById=FeedItem.CreatedById;
        //feedobj.Body=FeedItem.Comments__c;
        //feedobj.Type='Textpost';
        }
    }
}
i don't knw how to write a record to custom object after querying the data from another objects.Plz help me
The feilds in custom obj(Article_Feedback__c) are Article_ID__c,Article_Title__c,Article_Type__c,Comments__c,Data_Category__c,Data_Category_Group__c and Reason__c.

My VFP:
<apex:page standardController="Core_Benefit__kav" extensions="GetURLnew"  >

            <apex:form>
                    <apex:outputField id="id" value="{!cbk.Id}"/>
                    <apex:outputField id="title" value="{!cbk.Title}"/>
                    <apex:outputField id="arttype" value="{!cbk.ArticleType}"/>
                    <apex:outputField id="artnumb" value="{!cbk.ArticleNumber}"/>
                    <apex:outputField id="urlname" value="{!cbk.UrlName}"/>
                    <apex:outputField id="createdby" value="{!cbk.CreatedById}"/>
                    <apex:outputField id="ownerid" value="{!cbk.OwnerId}"/>
                    <apex:inputField id="comments" value="{!cbk.Comments__c}"/>
                    <apex:inputField id="reason" value="{!cbk.Reason__c}"/>
                    <apex:outputText id="datacatname" value="{!Category.DataCategoryName}"/>
                    <apex:outputText id="datacatgrpname" value="{!Category.DataCategoryGroupName}"/>
                    <apex:commandButton action="{!save}" value="save"/>        
              </apex:form>

</apex:page>

My controller:

public class GetURLnew {
    public List<Article_Feedback__c> artfeed=new List<Article_Feedback__c>();
    public Core_Benefit__kav filterid;
    public string cbkId {get; set;}
    public Core_Benefit__DataCategorySelection CatDetails;
    public Core_Benefit__kav cbk {get; set;}
 
    public GetURLnew(ApexPages.KnowledgeArticleVersionStandardController controller) {
        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, Comments__c, Reason__c from Core_Benefit__kav where PublishStatus = 'online' AND Language = 'en_US' AND KnowledgeArticleId =: cbkId];
        }
      
    }
  
    public Core_Benefit__DataCategorySelection getCategory() {
        return CatDetails;
    }
    public PageReference save() {
       
         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];
        
        insert artfeed;
       
    } 
}
i don't knw how to write a record to custom object after querying the data from another objects.Plz help me
The feilds in custom obj(Article_Feedback__c) are Article_ID__c,Article_Title__c,Article_Type__c,Comments__c,Data_Category__c,Data_Category_Group__c and Reason__c.

My VFP:
<apex:page standardController="Core_Benefit__kav" extensions="GetURLnew"  >

            <apex:form>
                    <apex:outputField id="id" value="{!cbk.Id}"/>
                    <apex:outputField id="title" value="{!cbk.Title}"/>
                    <apex:outputField id="arttype" value="{!cbk.ArticleType}"/>
                    <apex:outputField id="artnumb" value="{!cbk.ArticleNumber}"/>
                    <apex:outputField id="urlname" value="{!cbk.UrlName}"/>
                    <apex:outputField id="createdby" value="{!cbk.CreatedById}"/>
                    <apex:outputField id="ownerid" value="{!cbk.OwnerId}"/>
                    <apex:inputField id="comments" value="{!cbk.Comments__c}"/>
                    <apex:inputField id="reason" value="{!cbk.Reason__c}"/>
                    <apex:outputText id="datacatname" value="{!Category.DataCategoryName}"/>
                    <apex:outputText id="datacatgrpname" value="{!Category.DataCategoryGroupName}"/>
                    <apex:commandButton action="{!save}" value="save"/>         
              </apex:form> 

</apex:page>

My controller:

public class GetURLnew {
    public List<Article_Feedback__c> artfeed=new List<Article_Feedback__c>();
    public Core_Benefit__kav filterid;
    public string cbkId {get; set;}
    public Core_Benefit__DataCategorySelection CatDetails;
    public Core_Benefit__kav cbk {get; set;}
  
    public GetURLnew(ApexPages.KnowledgeArticleVersionStandardController controller) {
        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, Comments__c, Reason__c from Core_Benefit__kav where PublishStatus = 'online' AND Language = 'en_US' AND KnowledgeArticleId =: cbkId];
        }
       
    }
   
    public Core_Benefit__DataCategorySelection getCategory() {
        return CatDetails;
    }
    public PageReference save() {
        
         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];
         
        insert artfeed;
        
    }  
}

Hi,

 

Could anyone tell me how can i get multi select pick list on visual force page with custom controller. I was trying the same with newly custom object and then using that as custom controller and things were fine but now i want to have a) visual force page b) custom controller and c) data (picklist data) pulled from custom object.

 

 

Thanks,

Dilip

  • October 09, 2012
  • Like
  • 1