public with sharing class CampaignRelationshipController { public string campaignId {get; set;} public List CRList {get; set;} public List RVICRList {get; set;} public List NDTCRList {get; set;} public List ANICRList {get; set;} public List IECRList {get; set;} public String baseUrl { get; set; } public CampaignRelationshipController(){ baseUrl = URL.getSalesforceBaseUrl().toExternalForm(); String path = URL.getCurrentRequestUrl().getPath(); if (path.indexOf('/apex') > 0) { baseUrl += path.substring(0, path.indexOf('/apex')); } campaignId = System.currentPageReference().getParameters().get('campaignId'); } public CampaignRelationshipController(ApexPages.StandardController controller) { campaignId = controller.getRecord().Id; system.debug('campaignId---->'+campaignId); baseUrl = URL.getSalesforceBaseUrl().toExternalForm(); String path = URL.getCurrentRequestUrl().getPath(); if (path.indexOf('/apex') > 0) { baseUrl += path.substring(0, path.indexOf('/apex')); } } public PageReference init() { CRList = new List(); CRList = [SELECT Id,Name,RelationshipAccount__c,RelationshipAccount__r.Name, RelationshipAccountStatus__c,RelationshipProductSegment__c, RelationshipCampaign__c,ManagementCode__c FROM CampaignRelationship__c WHERE RelationshipCampaign__c = :campaignId Order by Id]; RVICRList = new List(); NDTCRList = new List(); ANICRList = new List(); IECRList = new List(); if (CRList.size() > 0) { for (CampaignRelationship__c cr:CRList) { if (cr.RelationshipProductSegment__c == 'RVI') { RVICRList.add(cr); } else if (cr.RelationshipProductSegment__c == 'NDT') { NDTCRList.add(cr); } else if (cr.RelationshipProductSegment__c == 'ANI') { ANICRList.add(cr); } else if (cr.RelationshipProductSegment__c == 'IE') { IECRList.add(cr); } } } return null; } public PageReference DataLoadAccount(){ PageReference ref = new Pagereference(baseUrl +'/apex/DataLoadAccount?campaignId=' + campaignId); ref.setRedirect(true); return ref; //return null ; } //public PageReference UnabletoEdit() { // PageReference ref = new Pagereference('/apex/TSRepair?Id=' + repairId); // ref.setRedirect(true); // return ref; // } }