• Mathew Abraham
  • NEWBIE
  • 0 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 6
    Questions
  • 7
    Replies
Could someone please help me write a test class for the attached Trigger?  I am completely lost - nothing I tried is working!!  Thank you for your help.  Appreciate it.
trigger SendUpdatedAccountToMirth on Account (after insert, after update){
    for (Account a : trigger.new){
        if(a.Status__c == 'Screening Scheduled' && a.Status_Detail__c == 'Scheduled'){
            String sendingJsonStr;
            Object sendingJson;
            
            sendingJson =
                new Map<String, String>{
                        'SalesForceId' => a.Id,
                        'CureMdId' => a.CureMD_Account__c,
                        'Title' => a.PersonTitle,
                        'FirstName'  => a.FirstName,
                        'MiddleName' => null,
                        'LastName' => a.LastName,
                        'Gender' => a.Gender__c,
                        'ClinicName' => a.Clinic_Name__c,
                        'BirthDate' => String.valueOf(a.PersonBirthDate),
                        'Status' => a.Status__c,
                        'StatusDetail' => a.Status_Detail__c,
                        'Street' => String.valueOf(a.BillingStreet),
                        'City' => a.BillingCity,                
                        'State' => a.BillingState,
                        'PostalCode' => a.BillingPostalCode,
                        'PhoneContacted' => a.Phone_Contacted__c,
                        'PhoneCell' => a.Phone_Cell__c,
                        'PhoneHome' => a.Phone_Home__c,
                        'PhoneWork' => a.Phone_Work__c,
                        'Email' => a.PersonEmail
                        };
                            
            sendingJsonStr = JSON.serialize(sendingJson);
            System.debug('Sending JSON: ' + sendingJsonStr);
            HttpMirthSender.sendAccount(sendingJsonStr);
        }
    }
}

 
Hello All,

We are planning to switch to Console application, and some of the Visualforce page buttons give error message like "Page Does not Exist:  Enter a valid URL and try again" !

Is there anyway to fix this, meaning make the VF page working in Console application.

Thank you for your expert advise and help.
Best wishes,
Mathew 
Hello, trust all are keeping well..

We are planning to switch to Console application, and some of the Visualforce page buttons give error message like "Page Does not Exist:  Enter a valid URL and try again" !

Is there anyway to fix this, meaning make the VF page working in Console application.

Thank you for your expert advise and help.
Best wishes,
Mathew 
Hi Trigger Experts!

Could someone please help me fix this trigger?  This is part of a huge Lead trigger, and I want to insert the following script to check if a phone number is on the Lead record is referenced in another object called 'NVMStatsSF__NVM_Call_Summary__c', and if so, get the three fields, i.e. Lead Campaign, Lead DMA, and Lead Clinic, with the values that are available in the NVM Call Summary object.

I inserted this script into the master Lead trigger, and when I try to deploy it to production, I get error 
values

1   trigger LeadTrigger on Lead (before insert, before update) {
2      for (Lead thisLead : trigger.new) {
3
4   Set<string> phoneContacted = new Set<string>();
5   for(Lead thisLead : trigger.new) {
6        string formatPhone = thisLead.Phone_Contacted__c.replaceAll('[^0-9]','');
7       phoneContacted.add(formatPhone);
8       }
9   List<NVMStatsSF__NVM_Call_Summary__c> NvmSumList = new list<NVMStatsSF__NVM_Call_Summary__c>();
10
11   NvmSumList = [SELECT Id, NVMStatsSF__CLID__c, Campaign__c, DMA__c, Clinic__c FROM NVMStatsSF__NVM_Call_Summary__c                WHERE NVMStatsSF__CLID__c IN: phoneContacted];   
12  
13   List<NVMStatsSF__NVM_Call_Summary__c> thisNvmSumList = new list<NVMStatsSF__NVM_Call_Summary__c>();   
14    for (integer i = 0; i < NvmSumList.size(); i++) {
15          if (NvmSumList[i].NVMStatsSF__CLID__c == thisLead.Phone_Contacted__c) {                        
16                    thisNvmSumList.add(NvmSumList[i]);
17                    }
18                }
19                
20          if (thisNvmSumList.size() >= 1 && thisLead.Campaign__c == Null ) {
21                    thisLead.Campaign__c = thisNvmSumList[0].Campaign__c;
22                    thisLead.Clinic__c = thisNvmSumList[0].Clinic__c;
23                    thisLead.DMA__c = thisNvmSumList[0].DMA__c;
24                }
25        }
26   }

Error Message:
System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, LeadTrigger: execution of BeforeInsert caused by: System.NullPointerException: Attempt to de-reference a null object Trigger.LeadTrigger: line 6, column 1: []
Stack Trace: Class.TestCaseTrigger.leadCase: line 9, column 1

By the way, the same line 6 is causing several issues on the Test Class, but I just want to fix the Trigger for now, and will worry about  Test Class later!  :)

Thank you for your helps..
Mathew
I did it exactly per trailhead but get this error:
"Challenge Not yet complete... here's what's wrong:  Please check that your report includes at least all of these columns: 'Supply: Supply Name', 'Unit Cost', 'Quantity' and 'Total Cost'."
I do have these fields perfecty correct, then why this error?  I have recreated the report and dashboard 5 times, but still the same error!
To the best of my knowledge, I have done the challenge correctly, but I get the following error message.  Can someone help me understand what is wrong?    Following is the message I get:
"Challenge Not yet complete... here's what's wrong:  There was an unexpected error while verifying this challenge. Usually this is due to some pre-existing configuration or code in the challenge Org. We recommend using a new Developer Edition (DE) to check this challenge. If you're using a new DE and seeing this error, please post to the developer forums and reference error id: SFWXDUII"
Hi Trigger Experts!

Could someone please help me fix this trigger?  This is part of a huge Lead trigger, and I want to insert the following script to check if a phone number is on the Lead record is referenced in another object called 'NVMStatsSF__NVM_Call_Summary__c', and if so, get the three fields, i.e. Lead Campaign, Lead DMA, and Lead Clinic, with the values that are available in the NVM Call Summary object.

I inserted this script into the master Lead trigger, and when I try to deploy it to production, I get error 
values

1   trigger LeadTrigger on Lead (before insert, before update) {
2      for (Lead thisLead : trigger.new) {
3
4   Set<string> phoneContacted = new Set<string>();
5   for(Lead thisLead : trigger.new) {
6        string formatPhone = thisLead.Phone_Contacted__c.replaceAll('[^0-9]','');
7       phoneContacted.add(formatPhone);
8       }
9   List<NVMStatsSF__NVM_Call_Summary__c> NvmSumList = new list<NVMStatsSF__NVM_Call_Summary__c>();
10
11   NvmSumList = [SELECT Id, NVMStatsSF__CLID__c, Campaign__c, DMA__c, Clinic__c FROM NVMStatsSF__NVM_Call_Summary__c                WHERE NVMStatsSF__CLID__c IN: phoneContacted];   
12  
13   List<NVMStatsSF__NVM_Call_Summary__c> thisNvmSumList = new list<NVMStatsSF__NVM_Call_Summary__c>();   
14    for (integer i = 0; i < NvmSumList.size(); i++) {
15          if (NvmSumList[i].NVMStatsSF__CLID__c == thisLead.Phone_Contacted__c) {                        
16                    thisNvmSumList.add(NvmSumList[i]);
17                    }
18                }
19                
20          if (thisNvmSumList.size() >= 1 && thisLead.Campaign__c == Null ) {
21                    thisLead.Campaign__c = thisNvmSumList[0].Campaign__c;
22                    thisLead.Clinic__c = thisNvmSumList[0].Clinic__c;
23                    thisLead.DMA__c = thisNvmSumList[0].DMA__c;
24                }
25        }
26   }

Error Message:
System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, LeadTrigger: execution of BeforeInsert caused by: System.NullPointerException: Attempt to de-reference a null object Trigger.LeadTrigger: line 6, column 1: []
Stack Trace: Class.TestCaseTrigger.leadCase: line 9, column 1

By the way, the same line 6 is causing several issues on the Test Class, but I just want to fix the Trigger for now, and will worry about  Test Class later!  :)

Thank you for your helps..
Mathew
I did it exactly per trailhead but get this error:
"Challenge Not yet complete... here's what's wrong:  Please check that your report includes at least all of these columns: 'Supply: Supply Name', 'Unit Cost', 'Quantity' and 'Total Cost'."
I do have these fields perfecty correct, then why this error?  I have recreated the report and dashboard 5 times, but still the same error!