• Kiran Chodavadiya
  • NEWBIE
  • 55 Points
  • Member since 2020

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 10
    Replies
How to write an apex program when Bill amount and Discount given as follows

    Bill amount value           Discount(%)
     
      1000 - 5000                     5%   
      5001 - 10000                    10%

 print the net amount to pay(After Discount)
Hello,
I am facing this error while creating Test Class on Line No-25
What is solution or reson behind it ?
if anyone know how to solve this error, please share your knowledge.

Thank You.
@isTest
public class TestApexHourTrigger {
        
        @isTest
        Static Void test(){
    	Invoice__c inv = new invoice__c();
        inv.Name = 'Test Invoice';
        insert inv;
        
        Invoice_Line_Up__c invlnup = new Invoice_Line_Up__c();
        invlnup.Name = 'Part 1';
        invlnup.Price__c = 500;
        invlnup.Invoice_Name__c = inv.Id;
        insert invlnup;
        
        Invoice_Line_Up__c invlnup2 = new Invoice_Line_Up__c();
        invlnup2.Name = 'Part 2';
        invlnup2.Price__c = 5000;
        invlnup2.Invoice_Name__c = inv.Id;
        insert invlnup2;
        
        Invoice__c verify = [select Total_Amount__c From Invoice__c where id =:inv.Id];
        
        System.debug('List======>'+verify);
        system.assertEqual(5500,verify.Total_Amount__c);
    }
    
}


 
Hello,
I have this Requirement
Make Call-out to SmartyStreets API –

SmartyStreets API is used to verify the address. In this milestone you need to consume https://smartystreets.com/products/apis/us-street-api

Requirement – The business ask is to verify the address of the event. Use the above API to verify the address & update “Location Verified” field on Event.

Must Have – Use of Error Handling and code re-usability

I tried with following code< but it showing 404 Error.
Could you please help how to come out from this Error And How i Upadate Field.
 
public class ApexHourIntigration {
    public static void verifyAddress(String Address){
        
        Http Http = new Http();
        HttpRequest Request = new HttpRequest();
        Request.setEndpoint('https://us-street.api.smartystreets.com/street-address?auth-id=6baff965-c2ed-eb53-7f43-e615db469a24&auth-token=pq7dRFqRoxtHiXKtCsOt'+ Address);
        Request.setMethod('GET');
        //Request.setHeader('contentType', 'application-json;charset=UTF-8');
        //Request.setBody('[{"candidates":10,"match":"invalid","street":"3901 SW 154th Ave","street2":"","city":"Davie","state":"FL","zipcode":"33331"}]');
        HttpResponse Response = Http.send(Request);
        
        if(Response.getStatusCode()!=200){
            system.debug(Response.getBody());
        }
        
        if(Response.getStatusCode()==200){
            Map<string,object> Results = (Map<string,object>) JSON.deserializeUntyped(Response.getBody());
            
            List<object> items = (List<object>) Results.get('items');
            for(object item :items){
                Map<string,object> components = (Map<string,object>)item;
                system.debug(components.get('components'));
           }
            try{
            	Event e = new Event();
                e.Location = 'Verified';
                update e;
           }
            catch(Exception e){
                system.debug('Error is :'+e.getMessage());
           }
        }
    }
}



 
Hi,
I'd like to set up the email notification for email update in contact field. once existing email field has been update, Account owner of this related contact recieve email notification.
Hello,
I am facing this error while creating Test Class on Line No-25
What is solution or reson behind it ?
if anyone know how to solve this error, please share your knowledge.

Thank You.
@isTest
public class TestApexHourTrigger {
        
        @isTest
        Static Void test(){
    	Invoice__c inv = new invoice__c();
        inv.Name = 'Test Invoice';
        insert inv;
        
        Invoice_Line_Up__c invlnup = new Invoice_Line_Up__c();
        invlnup.Name = 'Part 1';
        invlnup.Price__c = 500;
        invlnup.Invoice_Name__c = inv.Id;
        insert invlnup;
        
        Invoice_Line_Up__c invlnup2 = new Invoice_Line_Up__c();
        invlnup2.Name = 'Part 2';
        invlnup2.Price__c = 5000;
        invlnup2.Invoice_Name__c = inv.Id;
        insert invlnup2;
        
        Invoice__c verify = [select Total_Amount__c From Invoice__c where id =:inv.Id];
        
        System.debug('List======>'+verify);
        system.assertEqual(5500,verify.Total_Amount__c);
    }
    
}


 
Hi,

I have 2 scenarios in custom object

1. If it's old user system should get update 

2. If it's a new user system get insert with list of users.

i have done with single record and getting confused for bulk records.

Can you please refer my coding and advise me how can i create for bulk records for update existing records.

If you are suggesting with MAP it's really appriciate.

Apex Controller
/*Upadte Existing Record*/
            set<id> ExUser = new set<id>();
            set<id> newUser = new set<id>();
            string newRole;
            string newAccess;
            List<GD_Quote_Team__c> ExMembers = [select ID,GD_User__c,GD_User__r.Name from GD_Quote_Team__c where GD_Quotes__c =: quoteId];
            
            for(GD_Quote_Team__c ex_mem : ExMembers){
               GD_Quote_Team__c qtm = new GD_Quote_Team__c();
                qtm.Id = ex_mem.Id;
                qtm.GD_User__c = ex_mem.GD_User__c;
                ExUser.add(qtm.GD_User__c);
               
            }
            
            for(GD_Quote_Team__c new_mem : qtTeamList){
                newUser.add(new_mem.GD_User__c);
                newRole = new_mem.GD_Team_Role__c;
                newAccess = new_mem.GD_Quote_Access__c;
                
            }
            List<GD_Quote_Team__c> updtMembers = new List<GD_Quote_Team__c>();
            if(ExUser == newUser){
                GD_Quote_Team__c ExMembers1 = [select ID,GD_User__c,GD_User__r.Name,GD_Team_Role__c,GD_Quote_Access__c from GD_Quote_Team__c where GD_Quotes__c =: quoteId and GD_User__c =: ExUser];
                GD_Quote_Team__c NwMembers1 = [select ID,GD_User__c,GD_User__r.Name,GD_Team_Role__c,GD_Quote_Access__c from GD_Quote_Team__c where GD_Quotes__c =: quoteId and GD_User__c =: newUser]; 
                GD_Quote_Team__c qtm1 = new GD_Quote_Team__c();
                qtm1.Id = ExMembers1.Id;
                qtm1.GD_User__c = NwMembers1.GD_User__c;
                qtm1.GD_Team_Role__c = newRole;
                qtm1.GD_Quote_Access__c = newAccess;
                updtMembers.add(qtm1);  
                update updtMembers;
            } else if(ExUser != newUser){
                if(qtTeamList.size()>0){upsert qtTeamList;}
            }

Thanks In Advance,
Soundar.
Hello,
I have this Requirement
Make Call-out to SmartyStreets API –

SmartyStreets API is used to verify the address. In this milestone you need to consume https://smartystreets.com/products/apis/us-street-api

Requirement – The business ask is to verify the address of the event. Use the above API to verify the address & update “Location Verified” field on Event.

Must Have – Use of Error Handling and code re-usability

I tried with following code< but it showing 404 Error.
Could you please help how to come out from this Error And How i Upadate Field.
 
public class ApexHourIntigration {
    public static void verifyAddress(String Address){
        
        Http Http = new Http();
        HttpRequest Request = new HttpRequest();
        Request.setEndpoint('https://us-street.api.smartystreets.com/street-address?auth-id=6baff965-c2ed-eb53-7f43-e615db469a24&auth-token=pq7dRFqRoxtHiXKtCsOt'+ Address);
        Request.setMethod('GET');
        //Request.setHeader('contentType', 'application-json;charset=UTF-8');
        //Request.setBody('[{"candidates":10,"match":"invalid","street":"3901 SW 154th Ave","street2":"","city":"Davie","state":"FL","zipcode":"33331"}]');
        HttpResponse Response = Http.send(Request);
        
        if(Response.getStatusCode()!=200){
            system.debug(Response.getBody());
        }
        
        if(Response.getStatusCode()==200){
            Map<string,object> Results = (Map<string,object>) JSON.deserializeUntyped(Response.getBody());
            
            List<object> items = (List<object>) Results.get('items');
            for(object item :items){
                Map<string,object> components = (Map<string,object>)item;
                system.debug(components.get('components'));
           }
            try{
            	Event e = new Event();
                e.Location = 'Verified';
                update e;
           }
            catch(Exception e){
                system.debug('Error is :'+e.getMessage());
           }
        }
    }
}



 
How to write an apex program when Bill amount and Discount given as follows

    Bill amount value           Discount(%)
     
      1000 - 5000                     5%   
      5001 - 10000                    10%

 print the net amount to pay(After Discount)
Hi,
I'd like to set up the email notification for email update in contact field. once existing email field has been update, Account owner of this related contact recieve email notification.
when the "Type" on Account is updated to Customer - Direct, it should create a case record with below details
Hi Folks,
Please help me out below schenario and what is the best way to do this one

Thanks!!


Account "AB Corp" with "Type" = Prospect
It has say 4 Contacts under it with below details:
C1 --> Mailing Country = India
C2 --> Mailing Country = US
C3 --> Mailing Country = India
C4 --> Mailing Country = Aus

Now, when the "Type" on Account is updated to Customer - Direct, it should create a case record with below details:
Case Name = 'Contact case creation'
Case Account = 'AB Corp'
Case Description = 
India: C1, C3
US: C2
Aus: C4record with below details
Hi Folfs,
Please help me out below schenario and what is the best way to do this one

Thanks!!


Account "AB Corp" with "Type" = Prospect
It has say 4 Contacts under it with below details:
C1 --> Mailing Country = India
C2 --> Mailing Country = US
C3 --> Mailing Country = India
C4 --> Mailing Country = Aus

Now, when the "Type" on Account is updated to Customer - Direct, it should create a case record with below details:
Case Name = 'Contact case creation'
Case Account = 'AB Corp'
Case Description = 
India: C1, C3
US: C2
Aus: C4
I am creating a Trigger on the Knowledge Object. It checks if today's date is less than a custom date. If true, then it should not allow article deletion.
 
trigger KAVTrigger on Knowledge__kav (before delete) {
    
    
    if(Trigger.isDelete){
        for (Knowledge__kav kav : Trigger.old) {
        
            if(date.today() < kav.customDate__c){
                kav.addError('You cannot delete this article');
            }
            
    	} 

    }
    
}

 
I've been told by Salesforce that I need to use Apex coding to do this (permission sets, sharing rules/sets, and validation won't work), but I'm am looking for some direction on how to do it.

I have a Custom Object called Properties that is a child to Accounts. My properties are shopping centers in South Florida in Palm Beach, Broward, and Miami-Dade Counties. The counties are values in a picklist field.

I'd like the community users to have visibility access to all the Properties located in each county that is selected in a Picklist (Multi-Select) field that is in the Contacts Object. Currently, without this structure, community users can see all Properties in all 3 counties.

Thanks in advance for any help you can offer.