• Rachel van den Berg 1
  • 0 Points
  • Member since 2017

  • Chatter
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
  • 1

Hi all,


I've got some Campaign Member custom fields that I'm trying to update with a VisualForce page.  The page exists to receive a URL, which consists of a Campaign Member ID and a flag to tell me which field to update.


I am able to query the Campaign Member table, find the right Campaign Member, but then when it comes to making the actual data update, I keep getting an Authorization Required page and nothing actually updates.


The relevant part of my code is below, any ideas?


public without sharing class ControllerWebIQUpdate { public string campaignMemberID{get;set;} public string progressType{get;set;} public string textDisplay{get;set;} public string gettextDisplay(){ return textDisplay; } public ControllerWebIQUpdate(){ PageReference pr = System.currentPageReference(); campaignMemberID = System.currentPageReference().getParameters().get('cmid'); progressType = System.currentPageReference().getParameters().get('ft'); if(campaignMemberID == null){ //Error condition, don't have a 'cmid' value, do something textDisplay = 'Didnt get a CMID'; } else{ CampaignMember testCM = new CampaignMember(); List<CampaignMember> listCM = [Select Passed_Screener__c, Completed__c From CampaignMember Where Id = : campaignMemberID]; if(listCM.size() == 1){ textDisplay = 'Found the CM!'; if(progressType == 'screener'){ testCM = listCM.get(0); testCM.Passed_Screener__c = true; update testCM; textDisplay = 'Passed the screener!'; } else if(progressType == 'completed'){ testCM = listCM.get(0); testCM.Completed__c = true; update testCM; textDisplay = 'Finished the survey!'; } else{ textDisplay = 'Something was wrong with the FT parameter'; //Error condition, incorrect 'ft' value, do something } } else{ textDisplay = 'This shouldnt happen, bad news.'; //Error condition, something went wrong with the CampaignMember query } } } }