• Pavan Sonare
  • NEWBIE
  • 10 Points
  • Member since 2023

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 3
    Replies
Group_or_Party_Payout__c objGroupPayout = new Group_or_Party_Payout__c(
                        Rebate_Program__c = strPGID,
                        Rebate_Program_Payout_Period__c = strPeriodID,
                        Account__c = strAccountId,
                        Calculation_Date__c = date.today(),
                        Gross_Dollar_Rebates__c = (Decimal)mapDetail.get(GROSS_DOLLAR) == null ? 0 : (Decimal)mapDetail.get(GROSS_DOLLAR),
                        Gross_Per_Pound_Rebates__c = (Decimal)mapDetail.get(GROSS_PER_POUND) == null ? 0 : (Decimal)mapDetail.get(GROSS_PER_POUND),
                        Calculated_Rebate_Amount__c = ((Decimal)mapDetail.get(GROSS_DOLLAR) == null ? 0 : (Decimal)mapDetail.get(GROSS_DOLLAR)) + ((Decimal)mapDetail.get(GROSS_PER_POUND) == null ? 0 : (Decimal)mapDetail.get(GROSS_PER_POUND)),
                        Rebate_23100__c = decRebate23100,
                        Commission_23190_Tax__c = decCommission23100,
                        Advertising_23120__c = decAdvertising,
                        Total_Approved_Adjustment_Amount__c = (Decimal)mapDetail.get(ADJUSTMENT) == null ? 0 : (Decimal)mapDetail.get(ADJUSTMENT),
                        Name = strPGName + '-' + strPeriodName,
                        Due_Date__c = date.today(),
                        External_ID__c = strPGID + '-' + strPeriodID + '-' + strAccountId,
                        Delinquent_Accounts__c = (String)mapDetail.get(DELINQUENT),
                        Org_ID2__c = (String)mapDetail.get(ORG_ID),
                        Invoice_Description__c = strInvoiceDesc,
                        Cash_Discount2__c = decCashDisc,
                        Fuel_Surcharge__c = decFuelSur,
                        Status__c = 'Draft'
                    ); 
                    lstGroupPayout.add(objGroupPayout);
                }
            }
            
            system.debug('List of group or part payouts =>' + lstGroupPayout); // List of group or party payout.

            Integer intSuccessCount = 0;
            Integer intFailureCount = 0;
            String strFailureInfo = '';
            Schema.SObjectField externalId = Group_or_Party_Payout__c.Fields.External_ID__c;
            Database.UpsertResult[] srList = Database.upsert(lstGroupPayout, externalId, false);

I just want the due date to be set at as when the record is created and not update everyday

(This is a batch class that runs everynight)

I am getting an unknown method error for the below integration code. 

Below is the class.
public class NumverifyApi {
    public integer phone {get;set;}
    public string code {get;set;}
    public boolean numvalid {get;set;}
    public string countryCode {get;set;}
    public string countryName {get;set;}
    
    public static void verifyNumber(integer phone, string code){
        
       
        http http = new http();
        
        HttpRequest request = new httpRequest();
        request.setEndpoint('callout:Numverify?access_key=40e138077f26690623d13e0c5b6ad384&number='+code+Phone);
        request.setMethod('GET');
        
        httpResponse response = http.send(request); 
        system.debug(response.getStatusCode());
        if(response.getStatusCode()==200){
            map<string, Object> responseinReturn=(map<string,Object>)Json.deserializeUntyped(response.getBody());
            
            boolean numvalid = (boolean)responseinReturn.get('valid');
            string countryCode = (string)responseinReturn.get('country_code');
            string countryName = (string)responseinReturn.get('country_name');
            system.debug(numvalid);
            system.debug(countryCode);
            system.debug(countryName);
            
        }       
    }
}

here is vfpage code
<apex:page controller="NumverifyApi">
    <apex:form id="rs">
        <apex:pageBlock title="Input Phone Details">
            <apex:pageBlockButtons location="Bottom">
                <apex:commandButton value="Get Details" reRender="rs" action="{!verifyNumber}"/>
            </apex:pageBlockButtons>
            
            Phone        : <apex:inputText required="true" value="{!phone}"/> <br/><br/>
            Coutnry Code : <apex:inputText required="true" value="{!code}"/> <br/><br/>
            
        </apex:pageBlock>
        <apex:pageblock title="Phone Number Details">
            Is Phone number Valid? = {!numvalid}<br/><br/>
            Country code of the phone number = {!countryCode}<br/><br/>
            country of the Phone number = {!countryName} 
        </apex:pageblock>
    </apex:form>
</apex:page>

​​​​​​​
I am trying to write a trigger for an account object which will copy phone to its related contact phone. While the code is clear in syntax but I am getting an error while execution of null point exeption
public class UpdatePhoneOnContacts { // this is helper class and logic
    
    public static void methodForThisClass(list<account> accList, map<id, account> oldMap){
        list<contact> conList = new list<contact>();
        map<id, account> mapOfAcc = new map<id, account>();
        for(account acc : accList){
            if((acc.Phone != null && acc.Phone!=oldMap.get(acc.Id).phone)&& oldMap!=null){
                mapOfAcc.put(acc.Id, acc);
            }
        }
        for(contact con:[select id, name, homePhone, accountId from contact where accountId =: mapOfAcc.keySet()]){
            if(mapOfAcc.containsKey(con.accountId)){
                con.homePhone = mapOfAcc.get(con.Id).phone;
                conList.add(con);
            }
            if(!conlist.isEmpty()){
                update conList;
            }
        }
    }

}
 
trigger RealtedRecords on Account (after update) {// this is its trigger
    
    if(trigger.isAfter){
        if(trigger.isUpdate){
            UpdatePhoneOnContacts.methodForThisClass(trigger.new, trigger.oldMap);
        }
    }
}

Error Screenshot
Group_or_Party_Payout__c objGroupPayout = new Group_or_Party_Payout__c(
                        Rebate_Program__c = strPGID,
                        Rebate_Program_Payout_Period__c = strPeriodID,
                        Account__c = strAccountId,
                        Calculation_Date__c = date.today(),
                        Gross_Dollar_Rebates__c = (Decimal)mapDetail.get(GROSS_DOLLAR) == null ? 0 : (Decimal)mapDetail.get(GROSS_DOLLAR),
                        Gross_Per_Pound_Rebates__c = (Decimal)mapDetail.get(GROSS_PER_POUND) == null ? 0 : (Decimal)mapDetail.get(GROSS_PER_POUND),
                        Calculated_Rebate_Amount__c = ((Decimal)mapDetail.get(GROSS_DOLLAR) == null ? 0 : (Decimal)mapDetail.get(GROSS_DOLLAR)) + ((Decimal)mapDetail.get(GROSS_PER_POUND) == null ? 0 : (Decimal)mapDetail.get(GROSS_PER_POUND)),
                        Rebate_23100__c = decRebate23100,
                        Commission_23190_Tax__c = decCommission23100,
                        Advertising_23120__c = decAdvertising,
                        Total_Approved_Adjustment_Amount__c = (Decimal)mapDetail.get(ADJUSTMENT) == null ? 0 : (Decimal)mapDetail.get(ADJUSTMENT),
                        Name = strPGName + '-' + strPeriodName,
                        Due_Date__c = date.today(),
                        External_ID__c = strPGID + '-' + strPeriodID + '-' + strAccountId,
                        Delinquent_Accounts__c = (String)mapDetail.get(DELINQUENT),
                        Org_ID2__c = (String)mapDetail.get(ORG_ID),
                        Invoice_Description__c = strInvoiceDesc,
                        Cash_Discount2__c = decCashDisc,
                        Fuel_Surcharge__c = decFuelSur,
                        Status__c = 'Draft'
                    ); 
                    lstGroupPayout.add(objGroupPayout);
                }
            }
            
            system.debug('List of group or part payouts =>' + lstGroupPayout); // List of group or party payout.

            Integer intSuccessCount = 0;
            Integer intFailureCount = 0;
            String strFailureInfo = '';
            Schema.SObjectField externalId = Group_or_Party_Payout__c.Fields.External_ID__c;
            Database.UpsertResult[] srList = Database.upsert(lstGroupPayout, externalId, false);

I just want the due date to be set at as when the record is created and not update everyday

(This is a batch class that runs everynight)

I am getting an unknown method error for the below integration code. 

Below is the class.
public class NumverifyApi {
    public integer phone {get;set;}
    public string code {get;set;}
    public boolean numvalid {get;set;}
    public string countryCode {get;set;}
    public string countryName {get;set;}
    
    public static void verifyNumber(integer phone, string code){
        
       
        http http = new http();
        
        HttpRequest request = new httpRequest();
        request.setEndpoint('callout:Numverify?access_key=40e138077f26690623d13e0c5b6ad384&number='+code+Phone);
        request.setMethod('GET');
        
        httpResponse response = http.send(request); 
        system.debug(response.getStatusCode());
        if(response.getStatusCode()==200){
            map<string, Object> responseinReturn=(map<string,Object>)Json.deserializeUntyped(response.getBody());
            
            boolean numvalid = (boolean)responseinReturn.get('valid');
            string countryCode = (string)responseinReturn.get('country_code');
            string countryName = (string)responseinReturn.get('country_name');
            system.debug(numvalid);
            system.debug(countryCode);
            system.debug(countryName);
            
        }       
    }
}

here is vfpage code
<apex:page controller="NumverifyApi">
    <apex:form id="rs">
        <apex:pageBlock title="Input Phone Details">
            <apex:pageBlockButtons location="Bottom">
                <apex:commandButton value="Get Details" reRender="rs" action="{!verifyNumber}"/>
            </apex:pageBlockButtons>
            
            Phone        : <apex:inputText required="true" value="{!phone}"/> <br/><br/>
            Coutnry Code : <apex:inputText required="true" value="{!code}"/> <br/><br/>
            
        </apex:pageBlock>
        <apex:pageblock title="Phone Number Details">
            Is Phone number Valid? = {!numvalid}<br/><br/>
            Country code of the phone number = {!countryCode}<br/><br/>
            country of the Phone number = {!countryName} 
        </apex:pageblock>
    </apex:form>
</apex:page>

​​​​​​​
I am trying to write a trigger for an account object which will copy phone to its related contact phone. While the code is clear in syntax but I am getting an error while execution of null point exeption
public class UpdatePhoneOnContacts { // this is helper class and logic
    
    public static void methodForThisClass(list<account> accList, map<id, account> oldMap){
        list<contact> conList = new list<contact>();
        map<id, account> mapOfAcc = new map<id, account>();
        for(account acc : accList){
            if((acc.Phone != null && acc.Phone!=oldMap.get(acc.Id).phone)&& oldMap!=null){
                mapOfAcc.put(acc.Id, acc);
            }
        }
        for(contact con:[select id, name, homePhone, accountId from contact where accountId =: mapOfAcc.keySet()]){
            if(mapOfAcc.containsKey(con.accountId)){
                con.homePhone = mapOfAcc.get(con.Id).phone;
                conList.add(con);
            }
            if(!conlist.isEmpty()){
                update conList;
            }
        }
    }

}
 
trigger RealtedRecords on Account (after update) {// this is its trigger
    
    if(trigger.isAfter){
        if(trigger.isUpdate){
            UpdatePhoneOnContacts.methodForThisClass(trigger.new, trigger.oldMap);
        }
    }
}

Error Screenshot