• Eric Delgado
  • NEWBIE
  • 65 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 8
    Questions
  • 28
    Replies

I am new to Salesforce development and Apex. I like to create a force.com page, but prefer to work with my comfort ide, tools, and workflow such as writing my AngularJS code with Typescript and compile and run my workflow using gulp. I have check the Canvas, but I don't really like the idea of iframe. Is there any way to do what I want within the force.com ide or build it externally then deploy to force.com? Any guide will be helpful to get me started. Thanks.
Hi,
Can someone guide me into the right direction to automatically create a new case everytime after a live agent chat session is ended? Should I do it with a trigger? If so, where and how can I do that? Thanks.
I am trying to create a Salesforce unit test for a new trigger I created.
trigger SOSCreateCaseCustom on SOSSession (before insert) {
    List<Event> aplist = new List<Event>();
    List<SOSSession> sosSess = Trigger.new;
    for (SOSSession s : sosSess) {
        try {
            Case caseToAdd = new Case();
            caseToAdd.Subject = 'SOS Video Chat';
            if (s.ContactId != null) {
                caseToAdd.ContactId = s.ContactId;
            } else {
                List<Contact> contactInfo = [SELECT Id from Contact WHERE Email = :s.AppVersion];
                if (!contactInfo.isEmpty()) {
                    caseToAdd.ContactId = contactInfo[0].Id;
                    s.ContactId = contactInfo[0].Id;
                }
            }
            insert caseToAdd; s.CaseId = caseToAdd.Id;
        }catch(Exception e){}
    }
}
Here is my unit test:
@isTest
private class SOSCreateCaseCustomTest {
    static testMethod void validateSOSCreateCase() {
        String caseSubject = 'SOS Video Chat';

        // set up case to add 
        SOSSession s = new SOSSession();
        insert s;

        Case caseToAdd = new Case(Subject='SOS Video Chat');
        caseToAdd.ContactId = s.ContactId;
        insert caseToAdd;

        Case ca = [SELECT Subject, ContactId from Case where Subject =: caseSubject];
        // Test that escaltion trigger correctly escalate the question to a case
        System.assertEquals(s.ContactId, ca.ContactId);
    }
}
I keep getting this error:
System.QueryException: List has more than 1 row for assignment to SObject

I am new to Apex and I have no idea how to fix this. Can someone give me some idea how to fix this? Thanks!
Hi,
I am trying to deploy from sandbox to production. However I keep getting validation errors. 
 
Code Coverage Failure
Your organization's code coverage is 4%. You need at least 75% coverage to complete this deployment. Also, the following triggers have 0% code coverage. Each trigger must have at least 1% code coverage. SOSCreateCaseCustom
 
User-added image

However, I already created a unit test for it. Does anyone know how to get over this issue? Thanks.
Hi,
I am trying to create a new unit test for a trigger I am creating based on this example. 
https://developer.salesforce.com/docs/atlas.en-us.196.0.sos.meta/sos/service_cloud_guides-auto_case_pop.htm
trigger SOSCreateCaseCustom on SOSSession (before insert) {
    List<SOSSession> sosSess = Trigger.new;
    for (SOSSession s : sosSess) {
        try {
            Case caseToAdd = new Case();
            caseToAdd.Subject = 'SOS Video Chat';
            if (s.ContactId != null) {
                caseToAdd.ContactId = s.ContactId;
            } else {
                List<Contact> contactInfo = [SELECT Id from Contact WHERE Email = :s.AppVersion];
                if (!contactInfo.isEmpty()) {
                    caseToAdd.ContactId = contactInfo[0].Id;
                    s.ContactId = contactInfo[0].Id;
                }
            }
            insert caseToAdd; s.CaseId = caseToAdd.Id;
        }catch(Exception e){}
    }
}

Here is the unit test I created for the trigger.
@isTest
private class SOSCreateCaseCustomTest {
	static testMethod void validateSOSCreateCase() {
        init();
        Test.startTest();
        
        String caseSubject = 'SOS Video Chat';
        
		// set up case to add 
        Case caseToAdd = new Case(Subject='SOS Video Chat');
        insert caseToAdd;
        
		Case ca = [SELECT Subject, ContactId from Case where Subject =: caseSubject];
		System.assertEquals(caseSubject, ca.Subject);
        
        Test.stopTest();
	}
}

The unit test doesn't seem to test against the trigger I created above. How can I map this unit test to the trigger? Thanks.
 
Hi,
I am trying to login to the sandbox, and I am prompted to enter the verification code but the email seems to have sent to a different email (*******@****le.com) than the email (*******@****nk.com) I have in Salesforce personal information. The verification email was sent to the correct email when I login to the Salesforce.com account the first time. I have verified my email in the personal information page. Any idea what is going wrong? I can't access the sandbox without the verification code. Thanks!
Hi,
I am able to integrate the live agent into my app, but it always pop up a new window. I am trying to make it display in an iframe within the page to avoid a pop up window. I have look into liveagent.startChatWithWindow(), but I couldn't get it to work when I pass the iframe id as parameter to the function. Is it possible to do that? Thanks!
Hi,
I am new to SF REST API. I am trying to create an angular app and retrieve data from salesforce rest api with SF OAuth authentication. I get the bearer access token after authentication and have set it in the header for the api request. However, everytime I made a $http.get from angular, I get no data. The dev tool console shows this error:
XMLHttpRequest cannot load https://na34.salesforce.com/services/data. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8080' is therefore not allowed access.

However, when I look at the network tab in chrome dev tool, I see the status was 200 OK. I tested the request from fiddler and postman and I am able to get the data without problem. I also added my localhost:8080 to whitelist in CORS from the SF. Any idea what I am missing? Thanks!
I am trying to create a Salesforce unit test for a new trigger I created.
trigger SOSCreateCaseCustom on SOSSession (before insert) {
    List<Event> aplist = new List<Event>();
    List<SOSSession> sosSess = Trigger.new;
    for (SOSSession s : sosSess) {
        try {
            Case caseToAdd = new Case();
            caseToAdd.Subject = 'SOS Video Chat';
            if (s.ContactId != null) {
                caseToAdd.ContactId = s.ContactId;
            } else {
                List<Contact> contactInfo = [SELECT Id from Contact WHERE Email = :s.AppVersion];
                if (!contactInfo.isEmpty()) {
                    caseToAdd.ContactId = contactInfo[0].Id;
                    s.ContactId = contactInfo[0].Id;
                }
            }
            insert caseToAdd; s.CaseId = caseToAdd.Id;
        }catch(Exception e){}
    }
}
Here is my unit test:
@isTest
private class SOSCreateCaseCustomTest {
    static testMethod void validateSOSCreateCase() {
        String caseSubject = 'SOS Video Chat';

        // set up case to add 
        SOSSession s = new SOSSession();
        insert s;

        Case caseToAdd = new Case(Subject='SOS Video Chat');
        caseToAdd.ContactId = s.ContactId;
        insert caseToAdd;

        Case ca = [SELECT Subject, ContactId from Case where Subject =: caseSubject];
        // Test that escaltion trigger correctly escalate the question to a case
        System.assertEquals(s.ContactId, ca.ContactId);
    }
}
I keep getting this error:
System.QueryException: List has more than 1 row for assignment to SObject

I am new to Apex and I have no idea how to fix this. Can someone give me some idea how to fix this? Thanks!
Hi,
I am trying to deploy from sandbox to production. However I keep getting validation errors. 
 
Code Coverage Failure
Your organization's code coverage is 4%. You need at least 75% coverage to complete this deployment. Also, the following triggers have 0% code coverage. Each trigger must have at least 1% code coverage. SOSCreateCaseCustom
 
User-added image

However, I already created a unit test for it. Does anyone know how to get over this issue? Thanks.
Hi,
I am trying to create a new unit test for a trigger I am creating based on this example. 
https://developer.salesforce.com/docs/atlas.en-us.196.0.sos.meta/sos/service_cloud_guides-auto_case_pop.htm
trigger SOSCreateCaseCustom on SOSSession (before insert) {
    List<SOSSession> sosSess = Trigger.new;
    for (SOSSession s : sosSess) {
        try {
            Case caseToAdd = new Case();
            caseToAdd.Subject = 'SOS Video Chat';
            if (s.ContactId != null) {
                caseToAdd.ContactId = s.ContactId;
            } else {
                List<Contact> contactInfo = [SELECT Id from Contact WHERE Email = :s.AppVersion];
                if (!contactInfo.isEmpty()) {
                    caseToAdd.ContactId = contactInfo[0].Id;
                    s.ContactId = contactInfo[0].Id;
                }
            }
            insert caseToAdd; s.CaseId = caseToAdd.Id;
        }catch(Exception e){}
    }
}

Here is the unit test I created for the trigger.
@isTest
private class SOSCreateCaseCustomTest {
	static testMethod void validateSOSCreateCase() {
        init();
        Test.startTest();
        
        String caseSubject = 'SOS Video Chat';
        
		// set up case to add 
        Case caseToAdd = new Case(Subject='SOS Video Chat');
        insert caseToAdd;
        
		Case ca = [SELECT Subject, ContactId from Case where Subject =: caseSubject];
		System.assertEquals(caseSubject, ca.Subject);
        
        Test.stopTest();
	}
}

The unit test doesn't seem to test against the trigger I created above. How can I map this unit test to the trigger? Thanks.
 
Hi,
I am trying to login to the sandbox, and I am prompted to enter the verification code but the email seems to have sent to a different email (*******@****le.com) than the email (*******@****nk.com) I have in Salesforce personal information. The verification email was sent to the correct email when I login to the Salesforce.com account the first time. I have verified my email in the personal information page. Any idea what is going wrong? I can't access the sandbox without the verification code. Thanks!