• Ashu sharma 38
  • NEWBIE
  • 100 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 78
    Questions
  • 72
    Replies

Hi,

How to captute user last login date in custom object .

Hi,

This is below my JSON,as I need the value of "Result",but i am getting null value on it.

Please have a loook:

 public static void testSynchMethod(){
       string strEmail='{\"Code\":201,\"Meassge\":\"Created\",\"Details\":\" Request: { email: bob@example.com first_name: Bob last_name: Smith }, Result: { id: 15361872, created_at: 2020-02-05T09:29:50.47Z, first_name: Bob, last_name: Smith, full_name: Bob Smith, company: null, email: bob@test.com, roles: [], avatar_url: null, bio: null, headline: null, affiliate_code: null, external_source: null, affiliate_commission: null, affiliate_commission_type: %, affiliate_payout_email: null, administered_course_ids: null, custom_profile_fields: [ { id: null, value: null, label: sso_id, custom_profile_field_definition_id: 16009 } ] } \"}';
           map<string,object> cObjMap=(map<string,object>) JSON.deserializeUntyped(strEmail);
       
        string objJSON=JSON.serialize(cObjMap.get('Details'));
        Map<String, Object> ResultParam = (Map<String, Object>)cObjMap.get('Result');
        system.debug('>>>>>>>>>>>>'+ResultParam);
        
        

JOSN---
{ "Code": 201, "Meassge": "Created", "Details": " Request: { email: bob@example.com first_name: Bob last_name: Smith }, Result: { id: 15361872, created_at: 2020-02-05T09:29:50.47Z, first_name: Bob, last_name: Smith, full_name: Bob Smith, company: null, email: bob@test.com, roles: [], avatar_url: null, bio: null, headline: null, affiliate_code: null, external_source: null, affiliate_commission: null, affiliate_commission_type: %, affiliate_payout_email: null, administered_course_ids: null, custom_profile_fields: [ { id: null, value: null, label: sso_id, custom_profile_field_definition_id: 16009 } ] } " }

Hello,


As per documentation by Five9Adaptor I followed in my org.

But not getting working properly.

Anybody have worked on five9-Salesforce SSO.


Thanks

Hi,

As I am unable to complete the code coverage in batch apex.
global class countContactRecordsBatch implements Database.Batchable<sObject> {
    global Database.QueryLocator start(Database.BatchableContext bc) {
        string query='select id,Census_Date__c from hed__Term__c where Census_Date__c=LAST_N_DAYS:1';
        system.debug('query' +query) ;
        return Database.getQueryLocator(query); 
    }
    
    global void execute(Database.BatchableContext bc, List<hed__Term__c> scope){
        
        list<hed__Term__c> termList=[select id from hed__Term__c where Census_Date__c=LAST_N_DAYS:1];
        list<hed__Course_Offering__c> moduleOfferingList=[select hed__Term__r.id,(select hed__Contact__r.id,hed__Program_Enrollment__r.Program__r.id  from hed__Course_Enrollment__r) from hed__Course_Offering__c where hed__Term__r.id IN:termList];
        Map<string,set<string>> termProgramContacts=new Map<string,set<string>>();
        for(hed__Course_Offering__c co:moduleOfferingList) {
            system.debug('Term Id-'+co.hed__Term__r.id);   
            
            for(hed__Course_Enrollment__c ce:co.hed__Course_Enrollment__r){
                string mapKey = co.hed__Term__r.id+'-'+ce.hed__Program_Enrollment__r.Program__r.id;
                if(ce.hed__Program_Enrollment__r.Program__r.id!=null){
                    if(termProgramContacts.containsKey(mapKey)){
                        set<string> existingValue = termProgramContacts.get(mapKey);
                        existingValue.add(ce.hed__Contact__r.id);
                        termProgramContacts.put(mapKey, existingValue);
                    }                       
                    else{
                        set<string> newValue = new set<string>();   
                        newValue.add(ce.hed__Contact__r.id);
                        termProgramContacts.put(mapKey,newValue);
                    }
                }
            }
        }
            
            system.debug('Program Contact- '+termProgramContacts);
            list<hed__Term__c> termProgramList=new list<hed__Term__c>();
            list <Program_Session__c> programSessionList = new list <Program_Session__c>();
            termProgramList=[select id,(select id,Program__r.id from Program_Sessions__r) from hed__Term__c where id IN:termList];
            Map<string,integer> updateCount = new Map<string,integer>();
            for(hed__Term__c termProgram:termProgramList){
                for(Program_Session__c ps:termProgram.Program_Sessions__r){
                    string tpKey = termProgram.id+'-'+ps.Program__r.id;
                    if(termProgramContacts.containsKey(tpKey)){
                        integer contactCount = termProgramContacts.get(tpKey).size();
                        integer existingCount = 0;
                        if(updateCount.containsKey(ps.id)){
                            existingCount = updateCount.get(ps.id);                         
                        }
                        updateCount.put(ps.id,contactCount+existingCount);//progran term id and count
                        system.debug('updateCount'+updateCount.values().size());
                    }
                    ps.Total_enrolments_actual__c=updateCount.get(ps.Id);
                    programSessionList.add(ps);
                    system.debug('Total_enrolments_actual__c' +ps.Total_enrolments_actual__c);                    
                    system.debug('termProgramList ' +termProgramList);            
                }
            }
            if(programSessionList!=null && !programSessionList.isEmpty()){
                update programSessionList;
                
                
            }
        
    }
            global void finish(Database.BatchableContext BC){
                
            }

       
    //code end
    
   
}
===
Test class
=====

@isTest
public class countContactRecordsBatchTest {
    
    static testMethod void contactRecords(){
        
        list<Program_Session__c> psList=new list<Program_Session__c>();
        list<Account> acc=new list<Account>();
        list<hed__Term__c> termList=new list<hed__Term__c>();//term 
        list<Program__c> programList=new list<Program__c>();
        list<hed__Course_Offering__c> mcList=new list<hed__Course_Offering__c>();
        list<hed__Course__c> courseList=new list<hed__Course__c>();
        list<hed__Program_Enrollment__c> prEnrollmentList=new list<hed__Program_Enrollment__c>();
        list<Contact> consList=new list<contact>();
        
        
        Account a=new account();
        a.Name='Test Account';
        acc.add(a);
        
        insert acc;
        
        hed__Term__c te=new hed__Term__c();
        te.Name='test term';
        te.hed__Account__c=acc[0].id;
        te.Census_Date__c=date.today();
        termList.add(te);
        insert termList;//Term
        
        Program__c pc=new Program__c();
        pc.Name='test program ';
        programList.add(pc);//Program ..
        
        
        //insert module offering
        hed__Course_Offering__c mc=new hed__Course_Offering__c();
        hed__Course__c cou=new hed__Course__c();
        cou.name='test course';
        cou.hed__Account__c=acc[0].Id;
        courseList.add(cou);
        insert courseList;
        
        mc.Name='Test Module Offering';
        mc.hed__Course__c=courseList[0].id;
        mc.hed__Term__c=termList[0].id;
        mcList.add(mc);
        
        
        //Insert contact
        contact con=new contact();
        con.lastName='test contact Name';
        consList.add(con);    
        
        
        //program Enrollment
        hed__Program_Enrollment__c pe=new hed__Program_Enrollment__c();
        pe.Program__c=programList[0].id;
        pe.hed__Contact__c=consList[0].id;
        prEnrollmentList.add(pe);
        
        
        Program_Session__c ps=new Program_Session__c();
        ps.Term__c=termList[0].id;
        //     ps.Program__c=programList[0].id;
        ps.Program__c=programList[0].id;
        //ps.Total_enrolments_actual__c=1;
        psList.add(ps);
        database.insert (psList,false);
        
        list<Program_Session__c> prs=[select id ,Term__r.id,Program__r.id,Total_enrolments_actual__c from Program_Session__c];
        for(Program_Session__c pccc:prs){
            pccc.Total_enrolments_actual__c=10;
        }
        
        test.startTest();
        
        database.SaveResult []sr=database.update(prs,false);
        countContactRecordsBatch obj=new countContactRecordsBatch();
        database.executeBatch(obj);
        test.stopTest();
    }
    
}

As I am getting 44% code coverage on it.
Any suggestions.

Thanks
Hi,

I am creating a test class for updating a field ,but there is one issue am getting an error System.NullPointerException: Attempt to de-reference a null object

@isTest
public class countContactRecordsBatchTest {
    
    static testMethod void contactRecords(){
        list<Program_Session__c> ps=new list<Program_Session__c>();
        
                    Account a=new account();
                    a.Name='Test Account';
                    insert a;
            hed__Term__c  t=new hed__Term__c();//insert Program term
            t.Name='Test Term';

            t.hed__Account__r.id=a.Id;
            t.Census_Date__c=date.today();
            insert t;
            
            Program__c pr=new Program__c();//insert Program
            pr.Name='Test Program ';
            insert pr;
            
            Program_Session__c psR=new Program_Session__c();
            psR.Program__r.name=pr.Name;
            psR.Term__r.name=t.Name;
            
            ps.add(psR);
            
            
        }
        
        test.startTest();
        Database.SaveResult []str = Database.insert(ps,false);
        countContactRecordsBatch obj=new countContactRecordsBatch();
        database.executeBatch(obj);
        
    }
}
Hello,

i am trying to ctreate new map,in which key from Map1 and value from Map2

Map 1
  list<hed__Course_Offering__c> moduleOfferingList=new list<hed__Course_Offering__c>();
        moduleOfferingList=[select id,hed__Term__r.id,(select id,hed__Contact__r.id,hed__Program_Enrollment__r.id from hed__Course_Enrollment__r) from hed__Course_Offering__c];
        for(hed__Course_Offering__c mo:moduleOfferingList){
            set<id> contactId=new set<id>();
            set<id> enRollmentId=new set<id>();
            for(hed__Course_Enrollment__c mc:mo.hed__Course_Enrollment__r){
                contactId.add(mc.hed__Contact__r.id);
                enRollmentId.add(mc.hed__Program_Enrollment__r.id);
                
                contactsAndEnrollmentMap.put(mc.hed__Contact__r.id,enRollmentId);//enrollment id and contacts
            } 
              system.debug('contactId' +contactId);
        system.debug('enRollmentId' +enRollmentId);
            
        }

Map 2
 list<hed__Program_Enrollment__c> programEnrollmentList=new list<hed__Program_Enrollment__c>();
        programEnrollmentList=  [select id,Program__r.Program_Code__c from hed__Program_Enrollment__c ];
        map<id,set<string>> programEnrollmentAndProgramCodeMap=new map<id,set<string>>();
        if(!programEnrollmentList.isEmpty()){
            for(hed__Program_Enrollment__c pe:programEnrollmentList){
                set<id> enrollmentIDs=new set<id>();
                set<string> programCode=new set<string>();
                programCode.add(pe.Program__r.Program_Code__c);
                
                enrollmentIDs.add(pe.id);
               
                programEnrollmentAndProgramCodeMap.put(pe.id,programCode);//enrollment id and Program code
             system.debug('Program code' +programCode);
             system.debug('enrollmentIDs' +enrollmentIDs);
            }
           
        }
Hi,

I am stuck in map.
Map-1 contactsAndEnrollmentMap  
     which contain           contactsAndEnrollmentMap.put(mc.hed__Contact__r.id,enRollmentId);

Map --2 programEnrollmentAndProgramCodeMap
which contain
 programEnrollmentAndProgramCodeMap.put(pe.id,programCode);

Now I want to create new map which contain programCode(Key ) and hed__Contact__r(Value);


Thanks
Hi I am getting CUMULATIVE_LIMIT_USAGE_END in debug logs.
 
Hi,

As I have two maps 
Map 1---Program code and ContactId
Map 2---Program Code and Program term.


Now how to get the count of uniques program code from these two map.

Any idea.
Hi,
I am getting error...below code:

     map<string,set<id>> contactIdAndProgramCode=new map<string,set<id>>();
        for(string c:programEnrollmentAndProgramMap.values()){
            for(id i:termModuleofferingModuleConnectionMap.keySet()){
            contactIdAndProgramCode.put(c,termModuleofferingModuleConnectionMap.get(i));// Program code and ContactIds
             }
        }
        
    Error---Invalid loop variable type expected Set<String> was String
Hi,

As I am creating two maps now  I want to create the third map in which i have to put the values from 1st and 2nd Map.

Thanks

Hi,

As I have an issue :
I have to populate the count of one object which have related as follow::

    Seesion Issue----(Child of Session Object)
                      Session ------(Parent of Session Issue and Middle Issue)
                                    Middle Issue------(Parent of Section Issue)
                                           section Issue()-------Accounts(parent of Section Issue)

Hi ,

I have an issue.

there are 4 object
A,B,C,D
on A is field to count the number of record in D object.

D is child C,C is child B,B is child of A.

Hi,

As I am trying to login using customize the communities page,but not able to get redirect.

Any suggestions>
Hi All,

As I am trying to login communities its custom login page.
I am getting error when i Click on Login.

"Your login attempt has failed. Make sure the username and password are correct."

Thanks
Hi,

I am getting an error Argument cannot be null.Any idea what may be reason for that.
Hi,

As I am not able to update the records usng batch apex and I am schdeule it.


below is code:
====
Batch apex
global class UpdateSalesTermStatusBatch implements database.Batchable<sobject> {
    
    global database.QueryLocator start(database.BatchableContext bc){
        //query all records from database.
        return Database.getQueryLocator('select id,name,Sales_Cycle_Start_Date__c,Sales_Cycle_End_Date__c,Sales_Term_Status__c from Partner_Sales_Term__c');
        
    }
    
    global void execute(Database.BatchableContext BC, List<Partner_Sales_Term__c> scope){

        for(Partner_Sales_Term__c pst:scope){
            if(system.today() > pst.Sales_Cycle_End_Date__c){
                pst.Sales_Term_Status__c='Completed';
                system.debug('====Completed=====' +pst.Sales_Term_Status__c);
            }
            else if(system.today()<pst.Sales_Cycle_Start_Date__c){
                pst.Sales_Term_Status__c='Planned';
                system.debug('===Planned===' +pst.Sales_Term_Status__c);
            }
            else if(system.today()>=pst.Sales_Cycle_Start_Date__c && system.today() <=pst.Sales_Cycle_End_Date__c){
                pst.Sales_Term_Status__c='Current';
                system.debug('===Current====' +pst.Sales_Term_Status__c);
            }
            update scope;
        }
    }
    global void finish(Database.BatchableContext BC){
    }   
}
Schedule Apex:
global class UpdateSalesTermStatusBatchSchedulable implements Schedulable {
    
    public static String sched = '0 5 * * * ?';  //Every Hours at  
    global static String scheduleMe() {
        UpdateSalesTermStatusBatchSchedulable SC = new UpdateSalesTermStatusBatchSchedulable(); 
        return System.schedule('My batch Job', sched, SC);
    }
    global void execute(SchedulableContext sc) {
        
        UpdateSalesTermStatusBatch b1 = new UpdateSalesTermStatusBatch();
        ID batchprocessid = Database.executeBatch(b1,200);           
    }
}

And in anonmyous window
UpdateSalesTermStatusBatchSchedulable.scheduleMe(); 

Thanks


 
Hi ,

I am getting a error
FIELD_CUSTOM_VALIDATION_EXCEPTION
when my trigger and Process builder both are active.

Thanks
 
Hi,

I am getting below error when I active my trigger,as I have one process builder is running in same object.

: FIELD_CUSTOM_VALIDATION_EXCEPTION: You cannot overlap dates in same Partner Code. You can look up ExceptionCode values in the SOAP API Developer Guide. Error ID: 1266895027-3923133 (1004658621) 
Hi,

I have a requirement,in a object i have to restrict for  crearting records on below case:
Suppose I have created a records and on custom field(Test_code__c) I have put value:"ABC",and start date-->29/11/2019
End date:->29/12/2019

So in next records if I tried to create the record with same value 'ABC',the Start date and End should not be overlaped.
Hi All,

I want to know the basic resons for below point:

1.can we call future method into batch apex,if not why??
2.can we call futute method into anothrt future method??

Hi,

How to captute user last login date in custom object .

Hi,

I am creating a test class for updating a field ,but there is one issue am getting an error System.NullPointerException: Attempt to de-reference a null object

@isTest
public class countContactRecordsBatchTest {
    
    static testMethod void contactRecords(){
        list<Program_Session__c> ps=new list<Program_Session__c>();
        
                    Account a=new account();
                    a.Name='Test Account';
                    insert a;
            hed__Term__c  t=new hed__Term__c();//insert Program term
            t.Name='Test Term';

            t.hed__Account__r.id=a.Id;
            t.Census_Date__c=date.today();
            insert t;
            
            Program__c pr=new Program__c();//insert Program
            pr.Name='Test Program ';
            insert pr;
            
            Program_Session__c psR=new Program_Session__c();
            psR.Program__r.name=pr.Name;
            psR.Term__r.name=t.Name;
            
            ps.add(psR);
            
            
        }
        
        test.startTest();
        Database.SaveResult []str = Database.insert(ps,false);
        countContactRecordsBatch obj=new countContactRecordsBatch();
        database.executeBatch(obj);
        
    }
}
Hi,

I am stuck in map.
Map-1 contactsAndEnrollmentMap  
     which contain           contactsAndEnrollmentMap.put(mc.hed__Contact__r.id,enRollmentId);

Map --2 programEnrollmentAndProgramCodeMap
which contain
 programEnrollmentAndProgramCodeMap.put(pe.id,programCode);

Now I want to create new map which contain programCode(Key ) and hed__Contact__r(Value);


Thanks
Hi,

As I have two maps 
Map 1---Program code and ContactId
Map 2---Program Code and Program term.


Now how to get the count of uniques program code from these two map.

Any idea.
Hi,
I am getting error...below code:

     map<string,set<id>> contactIdAndProgramCode=new map<string,set<id>>();
        for(string c:programEnrollmentAndProgramMap.values()){
            for(id i:termModuleofferingModuleConnectionMap.keySet()){
            contactIdAndProgramCode.put(c,termModuleofferingModuleConnectionMap.get(i));// Program code and ContactIds
             }
        }
        
    Error---Invalid loop variable type expected Set<String> was String
Hi,

As I am creating two maps now  I want to create the third map in which i have to put the values from 1st and 2nd Map.

Thanks

Hi ,

I have an issue.

there are 4 object
A,B,C,D
on A is field to count the number of record in D object.

D is child C,C is child B,B is child of A.

Hi ,

I am getting a error
FIELD_CUSTOM_VALIDATION_EXCEPTION
when my trigger and Process builder both are active.

Thanks
 
Hi,

I have a requirement,in a object i have to restrict for  crearting records on below case:
Suppose I have created a records and on custom field(Test_code__c) I have put value:"ABC",and start date-->29/11/2019
End date:->29/12/2019

So in next records if I tried to create the record with same value 'ABC',the Start date and End should not be overlaped.
I have to create the login page with User name and pass word in salesforce lightning (Like Naukri home page).

I have created  the fields, but i am not able to do in controller for login button.

<div class="slds Naukri">
    <ui:inputtext aura:id="User" label=" User Name " class="" value="" maxlength="30" placeholder="Enter Email Id" required="false" size="20"/> <br/>
        <ui:inputSecret aura:id="pwd" label=" Password " class="" value="" maxlength="10" placeholder="Enter upto 10 character" required="false" size="20"/> <br/>
            <div class="slds-float--right slds-button_brand">
                <div class="slds-grid buttons">   
            <lightning:button variant="brand" label="Login" onclick="{!c.handleLoginButtomClick}" />
        </div>
    </div>
 </div>
Can you please help me in this.

Regards,
Sarma