• Sunnyalex
  • NEWBIE
  • 0 Points
  • Member since 2019
  • Som

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 8
    Questions
  • 3
    Replies
String.isnotBlank(rr.r.Receipt_status__c) && 
                    rr.r.Receipt_status__c.equalsIgnoreCase('Processed for industry') && 
                    String.isNotBlank(rr.rCloned.Ranking__c) &&
                    rr.rCloned.Banking__c.equalsIgnoreCase('Payment') && 
                    String.isNotBlank(rr.r.Currency__c) &&
                    !(rr.r.Currency__c.equalsIgnoreCase('Indian') || rr.r.Currency__c.equalsIgnoreCase('RUPEES')) &&
                    rr.rCloned.Forex__c == null
                ) {
                    rr.style2 = 'error';
                    error = true;


if(tempList1.size() > 0)
draft.createNewId(tempList1);


i have a code in apex like this how can i use createNewId to create test class

public with sharing class adpContactUsController {

    public String personalizedMessage1 {get; set;}
    public String personalizedMessage2 {get; set;}
    public String personalizedMessage3 {get; set;}
    
    public adpContactUsController (){
        User u = [Select Id, ContactId from User where Id =: UserInfo.getUserId()];
        
        List<Contact> conlist = [Select Id, Advocacy_Staff_Partner__c,Advocacy_Staff_Partner__r.X18_ID__c from Contact where id =: u.ContactId]; 
                
        if(conlist.size() > 0){
            if(conlist[0].Advocacy_Staff_Partner__c == null) {
                personalizedMessage1 = defaultMessage();
            }
            else {
            ADP_StaffData__c adpStaffData = ADP_StaffData__c.getValues(conlist[0].Advocacy_Staff_Partner__c);
            if(adpStaffData != null) {
                personalizedMessage1 = adpStaffData.Personal_Message1__c;
                personalizedMessage2 = adpStaffData.Personal_Message2__c;
                personalizedMessage3 = adpStaffData.Personal_Message3__c;
            }
            
           }
        } else {
            personalizedMessage1 = defaultMessage();
        }
        
    }
    
    private String defaultMessage(){
        List<ADP_StaffData__c> adpStaffDatalist = ADP_StaffData__c.getAll().values();
            String defMsg = '';
            for(ADP_StaffData__c adpDefMsg : adpStaffDatalist){
                if(adpDefMsg.Default_Message__c) {
                   defMsg = adpDefMsg.Personal_Message1__c + ' ' + adpDefMsg.Personal_Message2__c + ' ' + adpDefMsg.Personal_Message3__c;
                   break;                 
                }
            }
            return defMsg.replaceAll('null', '');
    }
    
    public PageReference SeeAllAdvocates(){
        
        PageReference pageRef = new PageReference('/apex/AdvocatesListView');
        pageRef.setRedirect(true);
        return pageRef;
        
    }
    
    public PageReference EmailNewAdvocates(){
        
        PageReference pageRef = new PageReference('/apex/AdvocatesListView?type=new');
        pageRef.setRedirect(true);
        return pageRef;
        
    }
    
    public PageReference EmailAllAdvocates(){
        
        PageReference pageRef = new PageReference('/apex/AdvocatesListView?type=all');
        pageRef.setRedirect(true);
        return pageRef;
        
    }
    
    public PageReference createNewHouseholdContact(){
         Contact con = New Contact();
         Id Contact_HRTypeID = Schema.sObjectType.Contact.getRecordTypeInfosByName().get('Household Contact').getRecordTypeId();
         PageReference contactDetailsPage = new PageReference('/003/e');
         contactDetailsPage.getParameters().put('RecordType',Contact_HRTypeID);
         String returnURL = '/'+Page.adpHomeNew.getUrl().right(10);
         contactDetailsPage.getParameters().put('retURL', returnURL.escapeHtml3());
         contactDetailsPage.setRedirect(true);
         return contactDetailsPage;
    }
}
//////////////////////////////////////////
@isTest
public class adpContactUsControllerTest {
    
    @testSetup static void setup() {
        
        Profile p = [SELECT Id FROM Profile WHERE Name='System Administrator'];

        fF_Location__c defaultLocation = new fF_Location__c(Name = 'Default Location', Is_Default_Unknown_Location__c = true);
        insert defaultLocation; 
        
        User u = new User(Alias = 't3stUser', Email='testUser@testkeyimpact.com', EmailEncodingKey='UTF-8', LastName='Testing', LanguageLocaleKey='en_US', 
                          LocaleSidKey='en_US', ProfileId = p.Id, TimeZoneSidKey='America/Los_Angeles', UserName='testusertest@keyimpact.com');
        
        INSERT u;
        Id RecordTypeIdContact = Schema.SObjectType.Contact.getRecordTypeInfosByName().get('Organization Contact').getRecordTypeId();
        Id RecordTypeIdAccount = Schema.SObjectType.Account.getRecordTypeInfosByName().get('Household').getRecordTypeId();
        Account acc = new Account();
        acc.Name = 'test account';
        acc.recordtypeid = RecordTypeIdAccount;
        insert acc;
        contact con = new contact();
        con.recordtypeid = RecordTypeIdContact;
        con.AccountId = acc.id;
        con.LastName = 'test con';
        con.Email = 'test0@test.com';
        insert con;
        
        contact con1 = new contact();
        con1.Advocacy_Staff_Partner__c = con.id; 
        con1.recordtypeid = RecordTypeIdContact;
        con1.LastName = 'test con1';
        con1.Email = 'test1@test.com';
        insert con1;
    }
    static testmethod void loginTest(){ 
        adpContactUsController adpCon =  new adpContactUsController();
        adpCon.SeeAllAdvocates();
        adpCon.EmailNewAdvocates();
        adpCon.createNewHouseholdContact();
        PageReference pageRef = adpCon.EmailAllAdvocates();
        System.assertNotEquals (null,pageRef);
    }
}
public class AllocationListController {

    @AuraEnabled
    public static Allocation__c getAllocation(Id Allocation) {
        System.debug('Allocationid'+Allocation);
        
        List<Allocation__c> AllocationList = [SELECT id,Name,Amount_Allocated__c,Amount_Pending_Allocation__c     FROM Allocation__c where Id=:Allocation];
        System.debug('AllocationList'+AllocationList);
        return AllocationList [0];
    }
       @AuraEnabled
    public static List<npsp__General_Accounting_Unit__c> getGau() {
        List<npsp__General_Accounting_Unit__c> GauList = [SELECT Id,Name FROM npsp__General_Accounting_Unit__c];
        System.debug('General Accounting Units'+GauList);
        return GauList;
    }
   
    @AuraEnabled
    public static string doAllocate(List<npsp__Allocation__c> lstSelectedRecords, Allocation__c allocationrecord){
        //list<npsp__Allocation__c>= new list<npsp__Allocation__c>();
       // List<npsp__Allocation__c> npspList = new List<npsp__Allocation__c>();
        system.debug('lstSelectedRecords ' +lstSelectedRecords + 'allocationrecord ' +allocationrecord);
        decimal total=0;
        list<Fund_Allocation__c> lstFundAllocation= new list<Fund_Allocation__c>();
        for(npsp__Allocation__c var: lstselectedrecords ){
            lstFundAllocation.add(new Fund_Allocation__c(
                Amount_Donated__c = var.Amount_Pending_Allocation__c,
                GAU_Allocation__c = var.id,
                Patient_Id__c = allocationrecord.id, 
                Name = allocationrecord.Name
            ) );
            var.Amount_Allocated__c+=var.Amount_Pending_Allocation__c;
            total+= var.Amount_Pending_Allocation__c;
        }
        if(!lstselectedrecords.isempty()){
            update lstselectedrecords;
            insert lstFundAllocation;
            system.debug('total'+total);
            if (total <> null){
                 allocationrecord.Amount_Allocated__c += total;
            }
           // allocationrecord.Amount_Allocated__c+=total;
          //update allocationrecord;
         try{
                update allocationrecord;
            }
            catch (Exception e){
           // throw new AuraHandledException('Amount Pending Allocation Should not be greater than Amount'+e.getMessage());  
           //throw new AuraHandledException( ' Amount Pending Allocation Should not be greater than Amount ==>');    
           throw new AuraHandledException(e.getMessage().substringBetween('FIELD_CUSTOM_VALIDATION_EXCEPTION, ',': ') );  
             
                
            }
        }
        
        return null;
    }
    
    @AuraEnabled
    public static Fund_Allocation__c getfunding (Id funding) {
        System.debug('fundingid'+funding);
  
        List<Fund_Allocation__c> fundingList = [SELECT Id,Name,Amount_Required__c FROM Fund_Allocation__c where Id=:funding];
        System.debug('fundingList'+fundingList);
        return fundingList[0];
    }
    
    
    
    
    @AuraEnabled
    public static List<npsp__Allocation__c> getgauallocations(String Gau) {
        system.debug(Gau);
       Gau= Gau.remove('.');
         system.debug(Gau);
        List<npsp__Allocation__c> allList = [SELECT Id,npsp__General_Accounting_Unit__c,Amount_Allocated__c,Donor_Name__c,
                                             Name,Amount_Pending_Allocation__c,npsp__Amount__c 
                                             FROM npsp__Allocation__c 
                                             where Amount_Pending_Allocation__c>0  
                                             and npsp__General_Accounting_Unit__c =:Gau 
                                             ORDER BY
                                             Amount_Pending_Allocation__c ASC];
       system.debug(allList);
        return allList;
    } 
}
One will need to create an event in the activity section in recieved response stage  to log a meeting date before moving to meeting Schedule. How can I restrict that user to go to another stage from moving to another stage.
I have to force that user to fill the form which is present in the new event part. Without filling he cannot move to another stage.
I have restricted the fields but still not working
Hello everyone,
i have got one requirement please help me in solving this requirement.
When an Account’s BillingPostalCode (Zip Code), is changed,
Change the Account Owner to the sales representative assigned to the new zip code
Change the Owner field of all the Account’s Contacts to the same sales rep 
Change the Owner field of all the Account’s Open Opportunities to the same sales rep.

1:The logic should run only when the Account’s zip code is changed or populated for the first time
2:If no matching Territories are found, do nothing



Thanks and Regards
Raj Sourav 
Hello everyone,
i have got one requirement please help me in solving this requirement.
When an Account’s BillingPostalCode (Zip Code), is changed,
Change the Account Owner to the sales representative assigned to the new zip code
Change the Owner field of all the Account’s Contacts to the same sales rep 
Change the Owner field of all the Account’s Open Opportunities to the same sales rep.

1:The logic should run only when the Account’s zip code is changed or populated for the first time
2:If no matching Territories are found, do nothing



Thanks and Regards
public class AllocationListController {

    @AuraEnabled
    public static Allocation__c getAllocation(Id Allocation) {
        System.debug('Allocationid'+Allocation);
        
        List<Allocation__c> AllocationList = [SELECT id,Name,Amount_Allocated__c,Amount_Pending_Allocation__c     FROM Allocation__c where Id=:Allocation];
        System.debug('AllocationList'+AllocationList);
        return AllocationList [0];
    }
       @AuraEnabled
    public static List<npsp__General_Accounting_Unit__c> getGau() {
        List<npsp__General_Accounting_Unit__c> GauList = [SELECT Id,Name FROM npsp__General_Accounting_Unit__c];
        System.debug('General Accounting Units'+GauList);
        return GauList;
    }
   
    @AuraEnabled
    public static string doAllocate(List<npsp__Allocation__c> lstSelectedRecords, Allocation__c allocationrecord){
        //list<npsp__Allocation__c>= new list<npsp__Allocation__c>();
       // List<npsp__Allocation__c> npspList = new List<npsp__Allocation__c>();
        system.debug('lstSelectedRecords ' +lstSelectedRecords + 'allocationrecord ' +allocationrecord);
        decimal total=0;
        list<Fund_Allocation__c> lstFundAllocation= new list<Fund_Allocation__c>();
        for(npsp__Allocation__c var: lstselectedrecords ){
            lstFundAllocation.add(new Fund_Allocation__c(
                Amount_Donated__c = var.Amount_Pending_Allocation__c,
                GAU_Allocation__c = var.id,
                Patient_Id__c = allocationrecord.id, 
                Name = allocationrecord.Name
            ) );
            var.Amount_Allocated__c+=var.Amount_Pending_Allocation__c;
            total+= var.Amount_Pending_Allocation__c;
        }
        if(!lstselectedrecords.isempty()){
            update lstselectedrecords;
            insert lstFundAllocation;
            system.debug('total'+total);
            if (total <> null){
                 allocationrecord.Amount_Allocated__c += total;
            }
           // allocationrecord.Amount_Allocated__c+=total;
          //update allocationrecord;
         try{
                update allocationrecord;
            }
            catch (Exception e){
           // throw new AuraHandledException('Amount Pending Allocation Should not be greater than Amount'+e.getMessage());  
           //throw new AuraHandledException( ' Amount Pending Allocation Should not be greater than Amount ==>');    
           throw new AuraHandledException(e.getMessage().substringBetween('FIELD_CUSTOM_VALIDATION_EXCEPTION, ',': ') );  
             
                
            }
        }
        
        return null;
    }
    
    @AuraEnabled
    public static Fund_Allocation__c getfunding (Id funding) {
        System.debug('fundingid'+funding);
  
        List<Fund_Allocation__c> fundingList = [SELECT Id,Name,Amount_Required__c FROM Fund_Allocation__c where Id=:funding];
        System.debug('fundingList'+fundingList);
        return fundingList[0];
    }
    
    
    
    
    @AuraEnabled
    public static List<npsp__Allocation__c> getgauallocations(String Gau) {
        system.debug(Gau);
       Gau= Gau.remove('.');
         system.debug(Gau);
        List<npsp__Allocation__c> allList = [SELECT Id,npsp__General_Accounting_Unit__c,Amount_Allocated__c,Donor_Name__c,
                                             Name,Amount_Pending_Allocation__c,npsp__Amount__c 
                                             FROM npsp__Allocation__c 
                                             where Amount_Pending_Allocation__c>0  
                                             and npsp__General_Accounting_Unit__c =:Gau 
                                             ORDER BY
                                             Amount_Pending_Allocation__c ASC];
       system.debug(allList);
        return allList;
    } 
}
Hello I want to make trigger for If a Territory__c record’s sales representative is changed (and only when it is changed), repeat Requirement #2’s logic for all Accounts associated with the Territory.
Here is requirement 2:
Requirement #2: When an Account’s BillingPostalCode (aka Zip Code), is changed,           
1. Change the Account Owner to the sales representative assigned to the new zip code          
2. Change the Owner field of all the Account’s Contacts to the same sales rep           
3. Change the Owner field of all the Account’s Open Opportunities to the same sales rep    
Hi I want to perform this scenario Multiple sales representatives can be assigned to the same zip code territory. If this is the case, use a random function to select one of the assigned sales representatives  Object is Territory__c
Inside this object : 
Records  
Zip CodeSales Representative
91000Blake
91001Blake
91002Blake
91002Jacqueline
91010Jacqueline
91020Jacqueline
92010Denise
92020Aaron
           Can anyone please help me out??