• John Cleveland
  • NEWBIE
  • 50 Points
  • Member since 2012


  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 2
    Likes Given
  • 24
    Questions
  • 23
    Replies
Hello,

How is it possibel that the same person has differnct profiles in Production and Sandbox.Sandbox was created 1 day agao

thanks
  • October 02, 2015
  • Like
  • 0
We have built a acknowledgment VF page that has a controller which checks to see if the user has acknowledged the latest message and if they have it will route them to home.  I am trying to figure out how to have users routed to this VF page after logging in so that if they need to acknowledge one they are there, if they don't they will be directed to home.  We do use lightning.  Any ideas?
I'm working on a package.xml file to use for an automated ant retrieve that will push to our bitbucket repo.  Looking at the Metadata Types listing, it doesn't show that you can use the wildcard for custom fields and for custom objects it has limits.  Is there any way that you can set the package.xml file to pull all so that it will pull fields as they are created without having to add each specific field and even object to get the object items to the package.xml file?
I'm usually pretty great at writing validation rules but guess this Monday isn't off to a great start. I'm trying to write one with the below criteria and I'm not getting anywhere. 

Any help would be greatly appreciated! 

1) All profiles except 2.
2) Certain Record Types
3) Status__c can only be changed if current status is "Status A". 
4) Status__c can only be changed to "Status B". 
 
AND( 
$Profile.Name <> 'Custom A', 
$Profile.Name <> 'System Administrator', 
CONTAINS(RecordType.Name , "Custom"), 
OR( 
NOT(ISPICKVAL(PRIORVALUE(Status__c), "Status A")), 
AND( 
ISCHANGED(Status__c), 
ISPICKVAL(PRIORVALUE(Status__c), "Status A"), 
NOT(ISPICKVAL(Status__c, "Status B")) 
) 
) 
)

 
I have Custom Object A and Custom Object B which is a child of A.
I also have Custom Object C and Custom Object D which is a child of C.
When records are created in Custom Object A and B, I need to copy values from A and B to C and D. I have a trigger to copy A to C but need help with adding code to copy B to D. Can anyone help? It would be greatly appreciated.
 
trigger createCFromA on Custom_Object_A (after insert, after update) {

	Id RecTypeId =  [Select Id from RecordType where name = 'recordtype' and sObjectType = 'Custom_Object_C' limit 1].Id;

    
    List <Custom_Object_C> cToInsert = new List <Custom_Object_C>();

    
    for (Custom_Object_A a : Trigger.new){        

        if (a.Status__c == 'New' ) {
                
        Custom_Object_C c = new Custom_Object_C (); 
        
                c.Field_1__c = a.Field_1__c;
				c.Field_2__c = a.Field_2__c;
				c.Field_3__c = a.Field_3__c;
				c.RecordTypeId = RecTypeId;

        cToInsert.add(c);
        
        }
        
    }
    

    try {
        insert bToInsert; 
    } 
        catch (system.Dmlexception e) {
        system.debug (e);
    }
    
   
}

 
I have a lightning app with several components and when I go to the URL to complete the fields on the form in IE 11, I get the error below.  Also included screenshot.  I do not get this error in Chrome .  Any one have any ideas on this or ran into this before and know how to make it work for IE too?

"Sorry to interrupt This page has an error. You might just need to refresh it. Error during init [Unable to get property 'apply' of undefined or null reference]"

IE 11 Error

When using Firefox it loads and I can do the form, but every once in a while when I click a field to populate or to select something I get the error below.  Anyone else seen this and know how to resolve?

"Sorry to interrupt Error: Permission denied to access property "buffer" throws at https://myurl--sandboxname.lightning.force.com/auraFW/javascript/xH6sVFQUmvLYLsBsK3q02Q/aura_proddebug.js:17888:1

Firefox Error

Thank you in advance!
I had a previous post but found an issue with that and now hitting another error after I've changed my code up.  I've included my trigger and test class below, but I am not able to get around the error below.  I also can not get a few lines covered with my class.  Any help is greatly appreciated.
 
Error MessageSystem.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, NewCaseEmail: execution of AfterInsert caused by: System.EmailException: SendEmail failed. First exception on row 0; first error: INVALID_EMAIL_ADDRESS, Email address is invalid: null: [toAddresses, null]

Trigger.NewCaseEmail: line 77, column 1: []
Stack TraceClass.TestNewCaseEmailTrigger.testNewCase: line 23, column 1

I am using an actual email in the trigger though.
 
I am unable to get lines 44-51 and lines 66-71 covered with my test class.  

One thing to note is that I have a workflow rule with evaluation criteria of "Evaluate the rule when a record is created, and every time it's edited" and part of the criteria is status is New, so it's running on the cases created from this.  That's why I added lines 49-51 thinking it would help cover after the validation rule fired.

Apex Trigger: 
trigger  NewCaseEmail on Case (after insert,after update) {

for(Case t : trigger.new){
// Criteria for record type
 Id RecTypeId =  [Select Id, Name from RecordType where name = 'Test Record Type' limit 1].Id;

    if (t.Status == 'New' && t.Field_2__c  == 0 && t.RecordTypeId == RecTypeId ){
// New Email
    Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
// Setting the from to the OrgWideEmailAddress for Shared Inbox
    OrgWideEmailAddress[] owea = [select Id from OrgWideEmailAddress where Address = 'test@test.com'];    //Looking for ID for Email Address
    if ( owea.size() > 0 ) {
       email.setOrgWideEmailAddressId(owea.get(0).Id);    //Setting email from address to the ID of the Inbox
    } 

      Case cse = [SELECT id,  Case.owner.Name, Case.owner.Email,  Status, CaseNumber, Field_1__c , Field_2__c from Case WHERE Id = :t.Id];                    


        // create email content
        String CaseId = cse.id; 
        
        CaseId = CaseId.substring(0,CaseId.length()-3);
        
        String subject = 'Test Subject: ' + Cse.Field_2__c + '- Case #: ' + Cse.CaseNumber; 
        email.setSubject(subject);


        String line1 = 'Line 1. ' + '\n\n';
        String line2 = 'Line 2: ' +  cse.owner.Name + '\n';
        String line3 = 'Line 3: '+ Cse.Field_1__c  + '\n'; 
        String line4 = 'Line 4: '+ Cse.Field_2__c + '\n'; 
        
        
        
        String body = line1 + line2 + line3 + line4;
        email.setPlainTextBody(body);
        
       
        //Put your record id in ParentId
List<Attachment> attList = [SELECT id, Name, body, ContentType FROM Attachment WHERE ParentId = : CaseId];
// List of attachments handler
Messaging.EmailFileAttachment[] efaList = new List<Messaging.EmailFileAttachment>();
for(Attachment att : attList)
{ // Create the email attachment 
Messaging.EmailFileAttachment efa = new Messaging.EmailFileAttachment();
efa.setFileName(att.Name);
efa.setBody(att.body);
efa.setContentType(att.ContentType);
efa.setInline(false);
efaList.add(efa);
 }
// Attach files to email instance
email.setFileAttachments(efaList);

email.setPlainTextBody(body);

Id caseTeamRoleId= [SELECT Id FROM CaseTeamRole WHERE Name = 'Test Role' LIMIT 1].id;

List<CaseTeamMember> catmlst = [select Id, MemberId from CaseTeamMember where TeamRoleId = :caseTeamRoleId and ParentId = :t.Id];

String [] toEmails = new List<String>();

toEmails.add(cse.owner.Email);

for(CaseTeamMember ctm : catmlst)
{   
    String teamMemId = ctm.MemberId;
    teamMemId = teamMemId.substring(0, teamMemId.length()-3);  
    String userEmailId = [select Id, Email from User where Id = :teamMemId].Email;   
    toEmails.add(userEmailId);
}    


   
        email.setToAddresses(toEmails);
        if(email != null){
            Messaging.sendEmail(new Messaging.singleEmailMessage[] {email});
                           
          }
          
    
}
}

}

Test Class:
@isTest(seeAllData=true)
private class TestNewCaseEmailTrigger  {

    
    public static Case newCse;
    
   
    static void init(){
    
    newCse = new Case();

    newCse.Status = 'New';
    newCse.Field_2__c = 0;
    newCse.RecordTypeID = [select ID from RecordType where Name = 'Test Record Type' and sObjectType = 'Case'].ID;
    newCse.OwnerId= [select ID from Group where Name = 'Queue1' and Type = 'Queue'].ID;


    }

    static testMethod void testNewCase() {
    init();
    Test.startTest();
    insert newCse;    
        
    Case cse = [select Id, Field_2__c from Case where Id = :newCse.id];
    cse.Field_2__c  = 1;
    update cse;
        
    Attachment attach=new Attachment(); 
    attach.Name='Test Attachment'; 
    Blob bodyBlob=Blob.valueOf('Test Attachment Body'); 
    attach.body=bodyBlob; attach.parentId=newCse.Id;
    insert attach;
        
        Id userId = [SELECT Id FROM User WHERE IsActive = true AND Profile.Name = 'System Administrator' LIMIT 1].id;
  
   
        Id caseTeamRoleId= [SELECT Id FROM CaseTeamRole WHERE Name = 'Test Role' LIMIT 1].id;
        List<CaseTeamMember> catmList=new List<CaseTeamMember>();
        
        CaseTeamMember tm=new CaseTeamMember();
        tm.ParentId=newCse.Id;
        tm.MemberId=userId;
        tm.TeamRoleId =caseTeamRoleId;
        catmList.add(tm);
        
        upsert catmList;
        
    cse.Status = 'Pending';
    cse.OwnerId = 'newCse.OwnerId';
    update newCse;
        
        
    Case cse2 = [select Id, Field_2__c  from Case where Id = :newCse.id];
    cse2.Field_2__c  = 0;
    update cse2;
                
    Test.stopTest();
    }
   

}

 
I have a trigger and a test class and am in need of getting about 11 more lines covered and I'm in desperate need of help to get this.  Any help would be greatly appreciated.  I've listed the lines that aren't covered in the test below that I need help, as well as the trigger and test class.

Line 44-51

{ // Create the email attachment 
Messaging.EmailFileAttachment efa = new Messaging.EmailFileAttachment();
efa.setFileName(att.Name);
efa.setBody(att.body);
efa.setContentType(att.ContentType);
efa.setInline(false);
efaList.add(efa);
 }

Line 66-71
{   
    String teamMemId = ctm.MemberId;
    teamMemId = teamMemId.substring(0, teamMemId.length()-3);  
    String userEmailId = [select Id, Email from User where Id = :teamMemId].Email;   
    toEmails.add(userEmailId);
}    

Apex Trigger:
trigger  NewCaseEmail on Case (after insert,after update) {

for(Case t : trigger.new){
// Criteria for record type
 Id RecTypeId =  [Select Id, Name from RecordType where name = 'Test Record Type' limit 1].Id;

    if (t.Status == 'New' && t.Field_1__c  == 0 && t.RecordTypeId == RecTypeId ){
// New Email
    Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
// Setting the from to the OrgWideEmailAddress for Shared Inbox
    OrgWideEmailAddress[] owea = [select Id from OrgWideEmailAddress where Address = 'testemail@email.com'];    //Looking for ID for Email Address
    if ( owea.size() > 0 ) {
       email.setOrgWideEmailAddressId(owea.get(0).Id);    //Setting email from address to the ID of the Inbox
    } 

      Case cse = [SELECT id,  Case.owner.Name, Case.owner.Email,  Status, CaseNumber, Field_2__c , Field_2__c from Case WHERE Id = :t.Id];                    


        // create email content
        String CaseId = cse.id; 
        
        CaseId = CaseId.substring(0,CaseId.length()-3);
        
        String subject = 'Test Subject: ' + Cse.Field_2__c + '- Case #: ' + Cse.CaseNumber; 
        email.setSubject(subject);


		String line1 = 'Line 1. ' + '\n\n';
        String line2 = 'Line 2: ' +  cse.owner.Name + '\n';
        String line3 = 'Line 3: '+ Cse. Field_1__c  + '\n'; 
        String line4 = 'Line 4: '+ Cse.Field_2__c + '\n'; 
        
        
        
        String body = line1 + line2 + line3 + line4;
        email.setPlainTextBody(body);
        
       
        //Put your record id in ParentId
List<Attachment> attList = [SELECT id, Name, body, ContentType FROM Attachment WHERE ParentId = : CaseId];
// List of attachments handler
Messaging.EmailFileAttachment[] efaList = new List<Messaging.EmailFileAttachment>();
for(Attachment att : attList)
{ // Create the email attachment 
Messaging.EmailFileAttachment efa = new Messaging.EmailFileAttachment();
efa.setFileName(att.Name);
efa.setBody(att.body);
efa.setContentType(att.ContentType);
efa.setInline(false);
efaList.add(efa);
 }
// Attach files to email instance
email.setFileAttachments(efaList);

email.setPlainTextBody(body);

Id caseTeamRoleId= [SELECT Id FROM CaseTeamRole WHERE Name = 'Test Role' LIMIT 1].id;

List<CaseTeamMember> catmlst = [select Id, MemberId from CaseTeamMember where TeamRoleId = :caseTeamRoleId and ParentId = :t.Id];

String [] toEmails = new List<String>();

toEmails.add(cse.owner.Email);

for(CaseTeamMember ctm : catmlst)
{   
    String teamMemId = ctm.MemberId;
    teamMemId = teamMemId.substring(0, teamMemId.length()-3);  
    String userEmailId = [select Id, Email from User where Id = :teamMemId].Email;   
    toEmails.add(userEmailId);
}    


   
        email.setToAddresses(toEmails);
        if(email != null){
            Messaging.sendEmail(new Messaging.singleEmailMessage[] {email});
                           
          }
          
    
}
}

}

Test Class:
@isTest(seeAllData=true)
private class TestNewCaseEmailTrigger  {

    
    public static Case newCse;
    
   
    static void init(){
    
    newCse = new Case();

    newCse.Status = 'New';
    newCse.Field_1__c  = 0;
    newCse.RecordTypeID = [select ID from RecordType where Name = 'Test Record Type' and sObjectType = 'Case'].ID;

    }

    static testMethod void testNewCase() {
    init();
    Test.startTest();
    insert newCse;    
        
    Case cse = [select Id, Field_1__c from Case where Id = :newCse.id];
    cse.Field_1__c  = 1;
    update cse;
        
    Attachment attach=new Attachment(); 
    attach.Name='Test Attachment'; 
    Blob bodyBlob=Blob.valueOf('Test Attachment Body'); 
    attach.body=bodyBlob; attach.parentId=newCse.Id;
    insert attach;
        
        Id userId = [SELECT Id FROM User WHERE IsActive = true AND Profile.Name = 'System Administrator' LIMIT 1].id;
  
   
        Id caseTeamRoleId= [SELECT Id FROM CaseTeamRole WHERE Name = 'Test Role' LIMIT 1].id;
        List<CaseTeamMember> catmList=new List<CaseTeamMember>();
        
        CaseTeamMember tm=new CaseTeamMember();
        tm.ParentId=newCse.Id;
        tm.MemberId=userId;
        tm.TeamRoleId =caseTeamRoleId;
        catmList.add(tm);
        
        upsert catmList;
        
        
    Case cse2 = [select Id, Field_1__c  from Case where Id = :newCse.id];
    cse2.Field_1__c  = 0;
    update cse2;
                
    Test.stopTest();
    }
   

}

 
I accidentally deleted the Apex Test Results and need to find a way to restore them.  Can anyone help with this? Anyone know how?
What page layout or layout is used when a user clicks the "Close" button from a Case List View? I need to know how I can add fields to the page that's displayed there.
Is there anyone out there that is using OppScore by C9 Predictive Analytics? If so, can you let me know what you think about it, pros and cons? 

To any MOD: I didn't see a section for this type of question, is there a way to add a section to post asking for reviews or other users that may use an appexchange product one may be interested in?
I don't know how to get this in Salesforce so wanted to post here to see if anyone knows of an app in the appexchange to get this or if anyone has coded a solution to capture it in a custom object, if that's even possible.

Is there a way to get click results to see what users are viewing or actions they're doing? Basically we want to see how many times a user clicks on the account tab or any other tab and how many times they click on a specific record and if they edited it when they viewed it and what else users click/view, rather it's a report or document or whatever
How many of you have a picklist as a merge field in an HTML email template? I have a very basic html email template where I'm using our company letterhead, and here's the line where I'm using a picklist.  The value on the record is not showing on the email templates that are going out via approval process.  After a few days, Salesforce is trying to tell me picklist fields aren't supported, but it worked one time where I used the "Send Test and Verify Merge Fields" button within the email template.  I'm meeting with support today, but wanted to check with the community to see if anyone else is using picklist fields in email templates.

Reason: {!Object_Name__c.Picklist_Field__c}
I know rally offers an appexchange package that works with Cases, but has anyone done anything to automate creation of a rally card from an opportunity?
I just got a new laptop and trying to get Eclipse up and running again.  When I go to create a new project and enter my credentials and click Next, it says fetching and then I get this screen.  Any help would be appreciated.

User-added image
Curious if anyone has or is using OwnBackup for Salesforce (http://www.ownbackup.com/products/backup-for-salesforce) and how they like it.  Or if anyone is using another company that offers the same service.  Use to you had to have a jenkins server and scripts to schedule the pull from your org and send it to a git repo.  At Dreamforce 15 I found this booth and they offer the service, it backs up your metadata and data.
For those of you that's built a ticketing system in salesforce, do you mind sharing the page layouts or VFpages the user sees to create the ticket?
I have this VF section in a standard case page layout.
User-added image

After I check the box and save, the VF section of the layout shows the whole case page.  Why doesn't it just refresh with showing what was there before save?
User-added image


 
The issue I have with this is the case could be for an employee that is not a Salesforce user, therefor they don't have a license.  I really don't want to load all employees as contacts and use contacts cause they're really not contacts.  Is anyone using Cases for Internal HD Ticketing system and if so, did you find a way to select an inactive user in a user lookup field from Cases? 

I've done something like this in the past with a custom controller that searched inactive users and a VF page, on the case there was a field with a url to click to open the VF page, you searched for the name and it searhed inacitve users and we related them that way.  Just looking to see how everyone else does this.  I would think Salesforce has something to offer since it has Service Cloud and promotes it as a Ticketing system in a way.
Trying to test the connection between Visual Studio and Salesforce but getting this error.  Anyone ever run into this?
 
A first chance exception of type 'System.ServiceModel.CommunicationException' occurred in mscorlib.dll
The thread 0x2b80 has exited with code 259 (0x103).
The thread 0x14c8 has exited with code 259 (0x103).
The program '[12284] VerifyWSDLTest.vshost.exe' has exited with code 0 (0x0).



This url has the steps I'm following.
https://developer.salesforce.com/docs/atlas.en-us.salesforce_developer_environment_dotnet_tipsheet.meta/salesforce_developer_environment_dotnet_tipsheet/salesforce_developer_environment_verify_dotnet_wsdl.htm
 
We have jenkins setup with our internal GIT repos and backing up our production org and a few sandboxes. I'm trying to add a few more builds in Jenkins for a few other sandboxes, but when I run the build I'm getting this error. Anyone ever ran across this or know what it could mean? I've even created another build to a sandbox that another one is working on and this new one is giving the error.

retrieve: parsing buildfile jar:file:/path/home/jenkins/jusr/Ant/apache-ant-1.9.4/lib/ant-salesforce.jar!/com/salesforce/antlib.xml with URI = jar:file:/path/home/jenkins/jusr/Ant/apache-ant-1.9.4/lib/ant-salesforce.jar!/com/salesforce/antlib.xml from a zip file

BUILD FAILED /path/home/jenkins/.jenkins/tools/deployScripts/lib/retrieve.xml:24: Should provide a valid retrieve manifest 'unpackaged'. at com.salesforce.ant.RetrieveTask.execute(RetrieveTask.java:104) at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106) at org.apache.tools.ant.Task.perform(Task.java:348) at org.apache.tools.ant.Target.execute(Target.java:435) at org.apache.tools.ant.Target.performTasks(Target.java:456) at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1393) at org.apache.tools.ant.Project.executeTarget(Project.java:1364) at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41) at org.apache.tools.ant.Project.executeTargets(Project.java:1248) at org.apache.tools.ant.Main.runBuild(Main.java:851) at org.apache.tools.ant.Main.startAnt(Main.java:235) at org.apache.tools.ant.launch.Launcher.run(Launcher.java:280) at org.apache.tools.ant.launch.Launcher.main(Launcher.java:109)

Total time: 1 second fatal: pathspec '*' did not match any files

On branch master

#

Initial commit

# nothing to commit (create/copy files and use "git add" to track) error: src refspec master does not match any. error: failed to push some refs to 'ssh://user@git.abc.com//server/repo/dev/environments/environment.git' Build step 'Execute shell' marked build as failure Sending e-mails to: test@test.com Finished: FAILURE
Hi team,
In opportunity object I have created new user lookup field that is "second owner".
if user select the second owner(user lookup) field and create new record on opportunity object.
automatically give read access to the second owner on this opportunity record.

Note:opportunity owd is private.

Please help me 

Thanks
Sathish k
I'm usually pretty great at writing validation rules but guess this Monday isn't off to a great start. I'm trying to write one with the below criteria and I'm not getting anywhere. 

Any help would be greatly appreciated! 

1) All profiles except 2.
2) Certain Record Types
3) Status__c can only be changed if current status is "Status A". 
4) Status__c can only be changed to "Status B". 
 
AND( 
$Profile.Name <> 'Custom A', 
$Profile.Name <> 'System Administrator', 
CONTAINS(RecordType.Name , "Custom"), 
OR( 
NOT(ISPICKVAL(PRIORVALUE(Status__c), "Status A")), 
AND( 
ISCHANGED(Status__c), 
ISPICKVAL(PRIORVALUE(Status__c), "Status A"), 
NOT(ISPICKVAL(Status__c, "Status B")) 
) 
) 
)

 
I have Custom Object A and Custom Object B which is a child of A.
I also have Custom Object C and Custom Object D which is a child of C.
When records are created in Custom Object A and B, I need to copy values from A and B to C and D. I have a trigger to copy A to C but need help with adding code to copy B to D. Can anyone help? It would be greatly appreciated.
 
trigger createCFromA on Custom_Object_A (after insert, after update) {

	Id RecTypeId =  [Select Id from RecordType where name = 'recordtype' and sObjectType = 'Custom_Object_C' limit 1].Id;

    
    List <Custom_Object_C> cToInsert = new List <Custom_Object_C>();

    
    for (Custom_Object_A a : Trigger.new){        

        if (a.Status__c == 'New' ) {
                
        Custom_Object_C c = new Custom_Object_C (); 
        
                c.Field_1__c = a.Field_1__c;
				c.Field_2__c = a.Field_2__c;
				c.Field_3__c = a.Field_3__c;
				c.RecordTypeId = RecTypeId;

        cToInsert.add(c);
        
        }
        
    }
    

    try {
        insert bToInsert; 
    } 
        catch (system.Dmlexception e) {
        system.debug (e);
    }
    
   
}

 
I had a previous post but found an issue with that and now hitting another error after I've changed my code up.  I've included my trigger and test class below, but I am not able to get around the error below.  I also can not get a few lines covered with my class.  Any help is greatly appreciated.
 
Error MessageSystem.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, NewCaseEmail: execution of AfterInsert caused by: System.EmailException: SendEmail failed. First exception on row 0; first error: INVALID_EMAIL_ADDRESS, Email address is invalid: null: [toAddresses, null]

Trigger.NewCaseEmail: line 77, column 1: []
Stack TraceClass.TestNewCaseEmailTrigger.testNewCase: line 23, column 1

I am using an actual email in the trigger though.
 
I am unable to get lines 44-51 and lines 66-71 covered with my test class.  

One thing to note is that I have a workflow rule with evaluation criteria of "Evaluate the rule when a record is created, and every time it's edited" and part of the criteria is status is New, so it's running on the cases created from this.  That's why I added lines 49-51 thinking it would help cover after the validation rule fired.

Apex Trigger: 
trigger  NewCaseEmail on Case (after insert,after update) {

for(Case t : trigger.new){
// Criteria for record type
 Id RecTypeId =  [Select Id, Name from RecordType where name = 'Test Record Type' limit 1].Id;

    if (t.Status == 'New' && t.Field_2__c  == 0 && t.RecordTypeId == RecTypeId ){
// New Email
    Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
// Setting the from to the OrgWideEmailAddress for Shared Inbox
    OrgWideEmailAddress[] owea = [select Id from OrgWideEmailAddress where Address = 'test@test.com'];    //Looking for ID for Email Address
    if ( owea.size() > 0 ) {
       email.setOrgWideEmailAddressId(owea.get(0).Id);    //Setting email from address to the ID of the Inbox
    } 

      Case cse = [SELECT id,  Case.owner.Name, Case.owner.Email,  Status, CaseNumber, Field_1__c , Field_2__c from Case WHERE Id = :t.Id];                    


        // create email content
        String CaseId = cse.id; 
        
        CaseId = CaseId.substring(0,CaseId.length()-3);
        
        String subject = 'Test Subject: ' + Cse.Field_2__c + '- Case #: ' + Cse.CaseNumber; 
        email.setSubject(subject);


        String line1 = 'Line 1. ' + '\n\n';
        String line2 = 'Line 2: ' +  cse.owner.Name + '\n';
        String line3 = 'Line 3: '+ Cse.Field_1__c  + '\n'; 
        String line4 = 'Line 4: '+ Cse.Field_2__c + '\n'; 
        
        
        
        String body = line1 + line2 + line3 + line4;
        email.setPlainTextBody(body);
        
       
        //Put your record id in ParentId
List<Attachment> attList = [SELECT id, Name, body, ContentType FROM Attachment WHERE ParentId = : CaseId];
// List of attachments handler
Messaging.EmailFileAttachment[] efaList = new List<Messaging.EmailFileAttachment>();
for(Attachment att : attList)
{ // Create the email attachment 
Messaging.EmailFileAttachment efa = new Messaging.EmailFileAttachment();
efa.setFileName(att.Name);
efa.setBody(att.body);
efa.setContentType(att.ContentType);
efa.setInline(false);
efaList.add(efa);
 }
// Attach files to email instance
email.setFileAttachments(efaList);

email.setPlainTextBody(body);

Id caseTeamRoleId= [SELECT Id FROM CaseTeamRole WHERE Name = 'Test Role' LIMIT 1].id;

List<CaseTeamMember> catmlst = [select Id, MemberId from CaseTeamMember where TeamRoleId = :caseTeamRoleId and ParentId = :t.Id];

String [] toEmails = new List<String>();

toEmails.add(cse.owner.Email);

for(CaseTeamMember ctm : catmlst)
{   
    String teamMemId = ctm.MemberId;
    teamMemId = teamMemId.substring(0, teamMemId.length()-3);  
    String userEmailId = [select Id, Email from User where Id = :teamMemId].Email;   
    toEmails.add(userEmailId);
}    


   
        email.setToAddresses(toEmails);
        if(email != null){
            Messaging.sendEmail(new Messaging.singleEmailMessage[] {email});
                           
          }
          
    
}
}

}

Test Class:
@isTest(seeAllData=true)
private class TestNewCaseEmailTrigger  {

    
    public static Case newCse;
    
   
    static void init(){
    
    newCse = new Case();

    newCse.Status = 'New';
    newCse.Field_2__c = 0;
    newCse.RecordTypeID = [select ID from RecordType where Name = 'Test Record Type' and sObjectType = 'Case'].ID;
    newCse.OwnerId= [select ID from Group where Name = 'Queue1' and Type = 'Queue'].ID;


    }

    static testMethod void testNewCase() {
    init();
    Test.startTest();
    insert newCse;    
        
    Case cse = [select Id, Field_2__c from Case where Id = :newCse.id];
    cse.Field_2__c  = 1;
    update cse;
        
    Attachment attach=new Attachment(); 
    attach.Name='Test Attachment'; 
    Blob bodyBlob=Blob.valueOf('Test Attachment Body'); 
    attach.body=bodyBlob; attach.parentId=newCse.Id;
    insert attach;
        
        Id userId = [SELECT Id FROM User WHERE IsActive = true AND Profile.Name = 'System Administrator' LIMIT 1].id;
  
   
        Id caseTeamRoleId= [SELECT Id FROM CaseTeamRole WHERE Name = 'Test Role' LIMIT 1].id;
        List<CaseTeamMember> catmList=new List<CaseTeamMember>();
        
        CaseTeamMember tm=new CaseTeamMember();
        tm.ParentId=newCse.Id;
        tm.MemberId=userId;
        tm.TeamRoleId =caseTeamRoleId;
        catmList.add(tm);
        
        upsert catmList;
        
    cse.Status = 'Pending';
    cse.OwnerId = 'newCse.OwnerId';
    update newCse;
        
        
    Case cse2 = [select Id, Field_2__c  from Case where Id = :newCse.id];
    cse2.Field_2__c  = 0;
    update cse2;
                
    Test.stopTest();
    }
   

}

 
I have a trigger and a test class and am in need of getting about 11 more lines covered and I'm in desperate need of help to get this.  Any help would be greatly appreciated.  I've listed the lines that aren't covered in the test below that I need help, as well as the trigger and test class.

Line 44-51

{ // Create the email attachment 
Messaging.EmailFileAttachment efa = new Messaging.EmailFileAttachment();
efa.setFileName(att.Name);
efa.setBody(att.body);
efa.setContentType(att.ContentType);
efa.setInline(false);
efaList.add(efa);
 }

Line 66-71
{   
    String teamMemId = ctm.MemberId;
    teamMemId = teamMemId.substring(0, teamMemId.length()-3);  
    String userEmailId = [select Id, Email from User where Id = :teamMemId].Email;   
    toEmails.add(userEmailId);
}    

Apex Trigger:
trigger  NewCaseEmail on Case (after insert,after update) {

for(Case t : trigger.new){
// Criteria for record type
 Id RecTypeId =  [Select Id, Name from RecordType where name = 'Test Record Type' limit 1].Id;

    if (t.Status == 'New' && t.Field_1__c  == 0 && t.RecordTypeId == RecTypeId ){
// New Email
    Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
// Setting the from to the OrgWideEmailAddress for Shared Inbox
    OrgWideEmailAddress[] owea = [select Id from OrgWideEmailAddress where Address = 'testemail@email.com'];    //Looking for ID for Email Address
    if ( owea.size() > 0 ) {
       email.setOrgWideEmailAddressId(owea.get(0).Id);    //Setting email from address to the ID of the Inbox
    } 

      Case cse = [SELECT id,  Case.owner.Name, Case.owner.Email,  Status, CaseNumber, Field_2__c , Field_2__c from Case WHERE Id = :t.Id];                    


        // create email content
        String CaseId = cse.id; 
        
        CaseId = CaseId.substring(0,CaseId.length()-3);
        
        String subject = 'Test Subject: ' + Cse.Field_2__c + '- Case #: ' + Cse.CaseNumber; 
        email.setSubject(subject);


		String line1 = 'Line 1. ' + '\n\n';
        String line2 = 'Line 2: ' +  cse.owner.Name + '\n';
        String line3 = 'Line 3: '+ Cse. Field_1__c  + '\n'; 
        String line4 = 'Line 4: '+ Cse.Field_2__c + '\n'; 
        
        
        
        String body = line1 + line2 + line3 + line4;
        email.setPlainTextBody(body);
        
       
        //Put your record id in ParentId
List<Attachment> attList = [SELECT id, Name, body, ContentType FROM Attachment WHERE ParentId = : CaseId];
// List of attachments handler
Messaging.EmailFileAttachment[] efaList = new List<Messaging.EmailFileAttachment>();
for(Attachment att : attList)
{ // Create the email attachment 
Messaging.EmailFileAttachment efa = new Messaging.EmailFileAttachment();
efa.setFileName(att.Name);
efa.setBody(att.body);
efa.setContentType(att.ContentType);
efa.setInline(false);
efaList.add(efa);
 }
// Attach files to email instance
email.setFileAttachments(efaList);

email.setPlainTextBody(body);

Id caseTeamRoleId= [SELECT Id FROM CaseTeamRole WHERE Name = 'Test Role' LIMIT 1].id;

List<CaseTeamMember> catmlst = [select Id, MemberId from CaseTeamMember where TeamRoleId = :caseTeamRoleId and ParentId = :t.Id];

String [] toEmails = new List<String>();

toEmails.add(cse.owner.Email);

for(CaseTeamMember ctm : catmlst)
{   
    String teamMemId = ctm.MemberId;
    teamMemId = teamMemId.substring(0, teamMemId.length()-3);  
    String userEmailId = [select Id, Email from User where Id = :teamMemId].Email;   
    toEmails.add(userEmailId);
}    


   
        email.setToAddresses(toEmails);
        if(email != null){
            Messaging.sendEmail(new Messaging.singleEmailMessage[] {email});
                           
          }
          
    
}
}

}

Test Class:
@isTest(seeAllData=true)
private class TestNewCaseEmailTrigger  {

    
    public static Case newCse;
    
   
    static void init(){
    
    newCse = new Case();

    newCse.Status = 'New';
    newCse.Field_1__c  = 0;
    newCse.RecordTypeID = [select ID from RecordType where Name = 'Test Record Type' and sObjectType = 'Case'].ID;

    }

    static testMethod void testNewCase() {
    init();
    Test.startTest();
    insert newCse;    
        
    Case cse = [select Id, Field_1__c from Case where Id = :newCse.id];
    cse.Field_1__c  = 1;
    update cse;
        
    Attachment attach=new Attachment(); 
    attach.Name='Test Attachment'; 
    Blob bodyBlob=Blob.valueOf('Test Attachment Body'); 
    attach.body=bodyBlob; attach.parentId=newCse.Id;
    insert attach;
        
        Id userId = [SELECT Id FROM User WHERE IsActive = true AND Profile.Name = 'System Administrator' LIMIT 1].id;
  
   
        Id caseTeamRoleId= [SELECT Id FROM CaseTeamRole WHERE Name = 'Test Role' LIMIT 1].id;
        List<CaseTeamMember> catmList=new List<CaseTeamMember>();
        
        CaseTeamMember tm=new CaseTeamMember();
        tm.ParentId=newCse.Id;
        tm.MemberId=userId;
        tm.TeamRoleId =caseTeamRoleId;
        catmList.add(tm);
        
        upsert catmList;
        
        
    Case cse2 = [select Id, Field_1__c  from Case where Id = :newCse.id];
    cse2.Field_1__c  = 0;
    update cse2;
                
    Test.stopTest();
    }
   

}

 
I accidentally deleted the Apex Test Results and need to find a way to restore them.  Can anyone help with this? Anyone know how?
What page layout or layout is used when a user clicks the "Close" button from a Case List View? I need to know how I can add fields to the page that's displayed there.
How many of you have a picklist as a merge field in an HTML email template? I have a very basic html email template where I'm using our company letterhead, and here's the line where I'm using a picklist.  The value on the record is not showing on the email templates that are going out via approval process.  After a few days, Salesforce is trying to tell me picklist fields aren't supported, but it worked one time where I used the "Send Test and Verify Merge Fields" button within the email template.  I'm meeting with support today, but wanted to check with the community to see if anyone else is using picklist fields in email templates.

Reason: {!Object_Name__c.Picklist_Field__c}
I just got a new laptop and trying to get Eclipse up and running again.  When I go to create a new project and enter my credentials and click Next, it says fetching and then I get this screen.  Any help would be appreciated.

User-added image
Hi,

I am trying to deploy a change set from Developer Pro Sandbox to Full Sandbox. When I tried to validate inbound change on Full Sandbox it is saying Run Apex Test is not required. Could you please let me know how can I run Apex test on full sandbox while deploying from Dev Pro sandbox?

Best Regards,

Rahul
Hello,

How is it possibel that the same person has differnct profiles in Production and Sandbox.Sandbox was created 1 day agao

thanks
  • October 02, 2015
  • Like
  • 0
Getting all the time error while running flow

Encountered unhandled fault when running process Candidate_Wizard/30128000000LNdW exception by user/organization: 00528000000H3cM/00D28000000dzkyErrorcaused by element : FlowRecordCreate.Create_Candidate
caused by: UPSERT --- UPSERT FAILED --- ERRORS : (INVALID_EMAIL_ADDRESS) Email: invalid email address: Screen Input Fields | Email_Address --- for SFDC record with ID : null, 
I have this VF section in a standard case page layout.
User-added image

After I check the box and save, the VF section of the layout shows the whole case page.  Why doesn't it just refresh with showing what was there before save?
User-added image


 
The issue I have with this is the case could be for an employee that is not a Salesforce user, therefor they don't have a license.  I really don't want to load all employees as contacts and use contacts cause they're really not contacts.  Is anyone using Cases for Internal HD Ticketing system and if so, did you find a way to select an inactive user in a user lookup field from Cases? 

I've done something like this in the past with a custom controller that searched inactive users and a VF page, on the case there was a field with a url to click to open the VF page, you searched for the name and it searhed inacitve users and we related them that way.  Just looking to see how everyone else does this.  I would think Salesforce has something to offer since it has Service Cloud and promotes it as a Ticketing system in a way.
Hello,

How is it possible to calculate distance between two points given the lattitude and longitude.
Also, are there other geolocalization apps i can have a look

Thanks
 
  • October 01, 2015
  • Like
  • 2
As a certified Salesforce consulting partner, PDO, and ISV, ForceBrain.com builds cloud & mobile apps. We've been a salesforce partner for over 6 years and you'll be joining a super fun team of true rockstars. We're seeking a Technical Architect who will work-from-home as a full-time employee, assisting Project Leads in designing and building solutions for multiple projects (zero travel required).

RESPONSIBILITIES
• Lead the design, architecture, and development for salesforce CRM solutions for multiple projects in a deadline-focused and fast-paced environment
• Perform detailed evaluation of business requirements and produce clear technical & design specifications, defining customer's business objectives and needs
• Mentor team members on the overall implementation strategy and solutions
• Deliver excellent presentation, technical design, and architecture documentation
• Assist sales engineers in building and demonstrating prototypes in Salesforce
• Participate in scoping development projects and estimate resource requirements
• Oversee onshore and offshore teams in executing technical solutions on complex development projects

REQUIREMENTS
• You have a minimum of 3 years of Force.com Development experience.
• You have architected, designed, and developed over 5 Force.com projects, including ui design, functional design, data modeling, security, etc…
• Proficient with the Force.com Developer Toolkit including: Apex, Visualforce, Force.com IDE, Force.com Migration Tool, Web Services/SOA, & Metadata APIs.
• Expert knowledge of how to work within the the limitations of the Salesforce.com platform, including governor limits, code coverage, etc...
• Experience integrating the Salesforce platform with other systems, whether it is using the web services API, restful API, or http post.
• You are comfortable giving direction to more junior consultants and mentoring.
• You have expertise in understanding the business processes, and systems involved in
running organizations.
• You thrive in a startup organization / entrepreneurial environment.

PREFERRED SKILLS
• XML, CSS, HTML, Javascript, J-Query, etc... 
• Understanding of the entire SDLC and various methodologies.
• You have a good sense of humor, tough-skinned, and handle stress well.

INTERESTED?
• Send your resume to jobs(at)forcebrain.com
• Answer the questions on this form: http://goo.gl/forms/QtaEm7aeQJ

GENERAL STATS
• Full Time Employee
• Location: Remote, Work & Live Anywhere
• Salary with bonus and generous benefit package
• Applicant must be willing to work 8am PST - 5pm PST shift
• Principals only. No recruiters please.

ABOUT FORCEBRAIN.COM
• Established in 2008, ForceBrain.com manages an all-star team of Salesforce Consultants, Force.com Developers, and Technical Architects to design, develop, deploy, and support cloud & mobile solutions . 
• We offer a competitive salary and benefits package, opportunity for continuous education, flexible working hours, and tools for working remotely.
• In 2010, ForceBrain.com became certified as a B-Corporation, recognizing the transparency in which we run our organization and our accountability in giving back.