• Adam Bengtson
  • NEWBIE
  • 20 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 7
    Questions
  • 7
    Replies
I am trying to setup a custom domain name in salesforce mypage.example.com and point it to a visualforce page I have created.  I followed the instructions here , https://help.salesforce.com/apex/HTViewSolution?id=000205653&language=en_US.

It keeps telling me I need to add the CNAME to my DNS, which I have looked at over and over again and it is there and shows when i do an nslookup and to clarify we own the domain name and looking to point the subdomain to SF.  Is there a step I am not doing? Do I need to set up My Domain first? I am not sure what My Domain actually does so that would be helpful to know as well if you could include that.

THanks!
I have a visualforce page that talks to an Apex class.  I would like to log errors in a separate file that will allow me to check at anytime the errors we have encountered.  How would I implement this in Salesforce?
I have an issue where I created a visualforce page that uses js visualforce remoting.  I have to move this page into a communities subpage which does not allow you to host it as it is, instead you have to drop it in as html but in the process you cannot carry over the apex tags:
 
<apex:page controller="ApexController" sidebar="false" showHeader="false" applyBodyTag="false" applyHtmlTag="false">
Now I no longer have the connection to my controller.  Is there a way I can connect this back in a different way so I can use the visualforce remoting api?
I created a community within SalesForce and made the homepage a visualforce page and that works great.  Now I am trying to add a 2nd visual force page as a subpage in the same community, how do I achieve this?  I can't really figure out how to add lightning apps or just straight visual force pages.

THanks
I have a dynamic soql query that I am trying to run and then update based on what is being passed in.
 
global static Contact submitContactById_test(Map<String, String> basicInfo, Map<String, Boolean> preferences, String user_id) {
    	String s = 'SELECT ';
    	String f = ' FROM Contact';
    	String w = ' WHERE Individual_Auto_ID__c=\''+user_id+'\'';
    	Integer i = 0;
    	
    	preferences.remove('unsubscribe');
    	
    	for(String name: basicInfo.keySet()){
    		s += name + ', ';
    	}
    	
    	for(String name: preferences.keySet()){  						
			if(i != 0)
				 s += ', ';
			
			s += name;
			i++;
    	}
    	
    	contact = Database.query(s+f+w);

		for(String name: basicInfo.keySet()){
    		contact.put(name,basicInfo.get(name));
    	}
    	
    	for(String name: preferences.keySet()){
    		contact.put(name,preferences.get(name));
    	}
        Database.update(contact);

		return contact;
        
    }

I've run test on everything from top to bottom and the query and what is being updated should be exactly what I want, but the problem is I cannot get passed "Visualforce Remoting Exception: Collection is read-only" error.  I tried using .clone() which worked for some people I found when searching on this but it did not seem to change anything for me.

Another thing I find interesting is that I have this same functionality in another function I wrote and it works fine.

Thanks!
I need help creating a dynamic query for a global newsletter unsubscribe (20 newsletters or more that can change at any given time).  I don't want to have to constantly update so many fields in the apex code every time we create new newsletters.

Here is the only code I could get working:
global static boolean unsubscribe(string user_id, string newsletterField) {
        Boolean valid = true;
         
        contacts = [SELECT field1, field2, field3
        FROM Contact
        WHERE Id = :user_id];
        
        if(contacts.size() < 1) {
            valid = false;
        } else {
            if(newsletterField == 'field1'){
                contacts[0].field1 = false;
            } else if(newsletterField == 'field2') {
                contacts[0].field2 = false;
            } else if(newsletterField == 'field3') {
                contacts[0].field3 = false;
            } 
        
            update contacts[0];
        }
            
        return valid;
    }
Basically a huge list of if/else statements and its making me crazy that I can't seem to find a way to make dynamic query where I can set the field to be updated a variable like contacts[0].myVar = false instead of hard coding every field.

Maybe I am approaching this issue completely wrong.  Some advice would be great.

Thanks!
 
I am having issues getting all of my code covered or at least 75% of it.

I have tested my class manually and everything seems to work properly, but when I run my test class it does not cover the code I expected it to.  I am creating a contact con1 and retrieving the Individual_Auto_ID__c is an auto generated unique custom field.  When passed to the function it should find the newly created con and return exactly 1 result since I just created that contact.  This works perfect when testing manually but not when the Test function runs it.  Am I missing something?

Test Class:
@isTest
private class myController_Test {

    static testMethod void myTestController_Test() {
        //----------------------------------------
        //TEST CLASS FOR myController
        //----------------------------------------
    
        Contact con1 = new Contact(firstname='Test', lastname='Test', email='test@aei.org');
        
        insert con1;

        string con_id = con1.Individual_Auto_ID__c;
        string field_name = 'test';
         
        //unsubscribe - good and bad values
        boolean valid = myController.unsubscribe(con_id, field_name);
}

My Controller:
global with sharing class myController {
    public static List<Contact> contacts {get; set;}

    @RemoteAction    
    global static boolean unsubscribe(string user_id, string newsletterField) {
        Boolean valid = true;
         
        contacts = [SELECT FirstName
        FROM Contact
        WHERE Individual_Auto_ID__c = :user_id];
        
        if(contacts.size() < 1) {
            valid = false;
        } else {
            //This is not being covered 
        }
            
        return valid;
    }
}

 
I have a visualforce page that talks to an Apex class.  I would like to log errors in a separate file that will allow me to check at anytime the errors we have encountered.  How would I implement this in Salesforce?
I have a dynamic soql query that I am trying to run and then update based on what is being passed in.
 
global static Contact submitContactById_test(Map<String, String> basicInfo, Map<String, Boolean> preferences, String user_id) {
    	String s = 'SELECT ';
    	String f = ' FROM Contact';
    	String w = ' WHERE Individual_Auto_ID__c=\''+user_id+'\'';
    	Integer i = 0;
    	
    	preferences.remove('unsubscribe');
    	
    	for(String name: basicInfo.keySet()){
    		s += name + ', ';
    	}
    	
    	for(String name: preferences.keySet()){  						
			if(i != 0)
				 s += ', ';
			
			s += name;
			i++;
    	}
    	
    	contact = Database.query(s+f+w);

		for(String name: basicInfo.keySet()){
    		contact.put(name,basicInfo.get(name));
    	}
    	
    	for(String name: preferences.keySet()){
    		contact.put(name,preferences.get(name));
    	}
        Database.update(contact);

		return contact;
        
    }

I've run test on everything from top to bottom and the query and what is being updated should be exactly what I want, but the problem is I cannot get passed "Visualforce Remoting Exception: Collection is read-only" error.  I tried using .clone() which worked for some people I found when searching on this but it did not seem to change anything for me.

Another thing I find interesting is that I have this same functionality in another function I wrote and it works fine.

Thanks!
I need help creating a dynamic query for a global newsletter unsubscribe (20 newsletters or more that can change at any given time).  I don't want to have to constantly update so many fields in the apex code every time we create new newsletters.

Here is the only code I could get working:
global static boolean unsubscribe(string user_id, string newsletterField) {
        Boolean valid = true;
         
        contacts = [SELECT field1, field2, field3
        FROM Contact
        WHERE Id = :user_id];
        
        if(contacts.size() < 1) {
            valid = false;
        } else {
            if(newsletterField == 'field1'){
                contacts[0].field1 = false;
            } else if(newsletterField == 'field2') {
                contacts[0].field2 = false;
            } else if(newsletterField == 'field3') {
                contacts[0].field3 = false;
            } 
        
            update contacts[0];
        }
            
        return valid;
    }
Basically a huge list of if/else statements and its making me crazy that I can't seem to find a way to make dynamic query where I can set the field to be updated a variable like contacts[0].myVar = false instead of hard coding every field.

Maybe I am approaching this issue completely wrong.  Some advice would be great.

Thanks!
 
I am having issues getting all of my code covered or at least 75% of it.

I have tested my class manually and everything seems to work properly, but when I run my test class it does not cover the code I expected it to.  I am creating a contact con1 and retrieving the Individual_Auto_ID__c is an auto generated unique custom field.  When passed to the function it should find the newly created con and return exactly 1 result since I just created that contact.  This works perfect when testing manually but not when the Test function runs it.  Am I missing something?

Test Class:
@isTest
private class myController_Test {

    static testMethod void myTestController_Test() {
        //----------------------------------------
        //TEST CLASS FOR myController
        //----------------------------------------
    
        Contact con1 = new Contact(firstname='Test', lastname='Test', email='test@aei.org');
        
        insert con1;

        string con_id = con1.Individual_Auto_ID__c;
        string field_name = 'test';
         
        //unsubscribe - good and bad values
        boolean valid = myController.unsubscribe(con_id, field_name);
}

My Controller:
global with sharing class myController {
    public static List<Contact> contacts {get; set;}

    @RemoteAction    
    global static boolean unsubscribe(string user_id, string newsletterField) {
        Boolean valid = true;
         
        contacts = [SELECT FirstName
        FROM Contact
        WHERE Individual_Auto_ID__c = :user_id];
        
        if(contacts.size() < 1) {
            valid = false;
        } else {
            //This is not being covered 
        }
            
        return valid;
    }
}