• Prajyot Kerkar
  • NEWBIE
  • 74 Points
  • Member since 2016
  • Salesforce Developer

  • Chatter
    Feed
  • 2
    Best Answers
  • 0
    Likes Received
  • 2
    Likes Given
  • 2
    Questions
  • 10
    Replies
component:
<aura:component implements="force:appHostable" controller="FetchRegistrations" >
    <aura:attribute name="reg" type="Registration__c[]"/>
    <ui:button label="Get Registrations" press="{!c.myAction}"/>
    <aura:iteration var="r" items="{!v.reg}" >
    <p>{!r.name}</p>
    </aura:iteration>
</aura:component>


Controller:
({
   myAction : function(component, event, helper) {
        var action = component.get("c.getAllregistrations");
        action.setCallback(this, function(response){
            var name = response.getState();
            if (name === "SUCCESS") {
                component.set("v.reg", response.getReturnValue());
            }
        });
     $A.enqueueAction(action);
    }
})

Apex:
global with sharing class FetchRegistrations {
@auraEnabled
    public static List<Registration__c> getAllregistrations()
    {
     List<Registration__c> reg=new LIST<Registration__c>();  
        reg=[select id,name,Email__c from Registration__c];
        return reg;
    } 
    public Registration__c getSelectedregistrations(Id id)
    {    
      Registration__c  reg=[select id,name,Email__c from Registration__c where id=:id];
        return reg;
    } 
   
}
Im not able to select a tag in Jquery becoz it is rendered aynchronously after the records are fetched from server. Can anybody help me with this ?

I would like to to execute a Jquery selector on the button which are in the table of records which are rendered asynchrously 
User-added image
I want to create a component like the above to create merge field
Im not able to select a tag in Jquery becoz it is rendered aynchronously after the records are fetched from server. Can anybody help me with this ?

I would like to to execute a Jquery selector on the button which are in the table of records which are rendered asynchrously 
How Many records can a trigger hold at a time?
Hi, I am trying to do the second module on the CRM basics "Understanding account and contacts" and my account teams is not showing up in order for me to complete the challenge. Can you help? Why is it not saving? I am sure that I activated it.
Hi,

How to I create/edit leads list view in the salesforce lighting experience? Please look into the below image,

User-added image

Thanks
public class CreateInvoice{
    
    public CreateInvoice(){
        
        List<Training__c> trainingList = new List<Training__c>();
        List<Facturatie__c> facturatieList = new List<Facturatie__c>();
        
        try {
        trainingList = [SELECT id , NAME, Startdatum__c,factuur_bedrijf__c,
                          (SELECT Cursist_Prijs__c, Training__c, Cursist__c,CreatedDate,Prijs_training__c,
                           korting__c,Id 
                           FROM Trainingen_Volgen__r ) 
                       FROM  Training__c 
                       WHERE id NOT IN (SELECT  Training__c FROM Facturatie__c)];
        }catch (Exception e) {
            System.debug('The following exception has occurred' + e.getMessage() +
                         'At line number :' + e.getLineNumber() + 'Error' +
                         e.getStackTraceString());
        }              
        if(!trainingList.IsEmpty()){
            
            for(Training__c trainingRecord : trainingList){
                
                if(!trainingRecord.Trainingen_Volgen__r.IsEmpty()){
                    
                    for(Cursist__c cursistRecord : trainingRecord.Trainingen_Volgen__r){
                        
                        Facturatie__c facturatieRecord = checkDate(cursistRecord,trainingRecord);
                        facturatieList.add(facturatieRecord);
                    }
                }   
            }

            if(!facturatieList.IsEmpty()){  
               try {
                   insert facturatieList;
                }catch (Exception e) {
                    System.debug('The following exception has occurred' + e.getMessage() +
                                 'At line number :' + e.getLineNumber() + 'Error' +
                                 e.getStackTraceString());
                }   
               
            }
        }   
    }
    
    public Facturatie__c checkDate(Cursist__c cursistRecord,Training__c trainingRecord){
        
        if(cursistRecord != null && trainingRecord != null){
            Date todaysDate = system.today();
            
            if( todaysDate.addDays(-21) >= trainingRecord.Startdatum__c 
                && todaysDate >= cursistRecord.CreatedDate 
                && todaysDate.addDays(-1) >= trainingRecord.Startdatum__c){
                
                Facturatie__c facturatieRecord = new Facturatie__c();
                
                facturatieRecord.Training__c = trainingRecord.Id;   
                facturatieRecord.Factuur_Datum__c = todaysDate;  
                facturatieRecord.Verval_datum__c = todaysDate.addDays(30);
                
                if(cursistRecord.Prijs_training__c != null &&  cursistRecord.korting__c != null){
                    facturatieRecord.Factuur_Bedrag__c = cursistRecord.Prijs_training__c - cursistRecord.korting__c;
                }else if(cursistRecord.Prijs_training__c != null && cursistRecord.korting__c == null){
                    facturatieRecord.Factuur_Bedrag__c = cursistRecord.Prijs_training__c;
                }else if(cursistRecord.Prijs_training__c == null && cursistRecord.korting__c != null){
                    facturatieRecord.Factuur_Bedrag__c = cursistRecord.korting__c ;
                }
                
                facturatieRecord.Korting__c =  cursistRecord.korting__c;
                facturatieRecord.cursist_prijs__c= cursistRecord.Cursist_Prijs__c ;
                facturatieRecord.Contactpersoon__c = cursistRecord.Cursist__c;
                facturatieRecord.Account__c = trainingRecord.factuur_bedrijf__c; 
                
                return facturatieRecord;
            }
        }
        
        return null;
    }
}
 
@isTest
public class CreateInvoiceTestClass{
    
    // Creating Test Data
   @isTest public static void testData(){
    
        Account account = new Account(Name = 'TestAccount1');  
        insert account;
        
        List<Training__c> trainingList = new List<Training__c>();
        for(integer counter=0;counter<200;counter++){
            
            Training__c trainingRecord = new Training__c();
            trainingRecord.name = 'TestRecord'+counter;
            trainingRecord.Startdatum__c = System.today().addDays(+2);
            trainingRecord.factuur_bedrijf__c = account.Id;
            trainingList.add(trainingRecord);
        }
        insert trainingList;
        
         List<Facturatie__c> facturatieList = new List<Facturatie__c>();
        for(integer counter=0;counter<200;counter++){
            
            Facturatie__c facturatieRecord = new Facturatie__c();
            facturatieRecord.name = 'TestRecord'+counter;
            facturatieRecord.Factuur_Bedrag__c = 1000;
            facturatieRecord.Training__c = trainingList[counter].Id;
            facturatieList.add(facturatieRecord);
        }
        insert facturatieList;

       
        List<Cursist__c> cursistList = new List<Cursist__c>();
        for(integer counter=0;counter<200;counter++){
            
            Cursist__c cursistRecord = new Cursist__c();           
            cursistRecord.Training__c = trainingList[counter].Id;
            cursistRecord.Prijs_training__c = 10;
            cursistRecord.korting__c = 10;
            cursistRecord.CreatedDate = System.today();
            cursistList.add(cursistRecord);
        }
        insert cursistList;
       
       system.debug(facturatieList[0].Account__c);
       Test.StartTEst();
	   CreateInvoice createInv = new CreateInvoice();
	   Test.stopTest();
      
       System.assertEquals(facturatieList[0].Account__c,null);
       
    }
   
}
User-added image
 
Hi, I am new to SFDC and i am trying to write a test class .
I am getting system.NullpointerException:Attempt to de-reference a null object. But the Apex class executes successfully.
PFB the details
VF Page:
<apex:page sidebar="false" standardController="CandidateDetails__c" extensions="Thankspageclass" cache="false" expires="0">
<script>
history.pushState(null, null, document.URL);
window.addEventListener('popstate', function () {
    history.pushState(null, null, document.URL);
});
</script>
<apex:pageblock >      
<div align="center" style="background-color:orange;height:500px;padding-top:200px;font-size:large">
<b>
Dear {!lst[0].Name__c}, Thanks for your participation.
</b>
<br></br>
<br></br>
<b>You will be assessed and contacted shortly.</b>
</div>
</apex:pageblock>
</apex:page>
Apex Class:
public class Thankspageclass {
  public String candidateEmail=ApexPages.currentPage().getCookies().get('candidateMail').getValue();
  public List<CandidateDetails__c> lst{get;set;}
  public Thankspageclass(ApexPages.StandardController controller) {
    lst=[SELECT Name__c FROM CandidateDetails__c where Email__c=: candidateEmail];
    }
}
Test Class:
@isTest
public class ThankspageclassTest {
public static testmethod void test1(){
CandidateDetails__c cand = new CandidateDetails__c();
cand.Areas_of_Assessments__c ='sales';
cand.Email__c= 'Banu@gmail.com';
cand.Name__c='Banu';
cand.Number_Of_Questions__c= 5;
cand.Participant_Id__c='INF0009';
cand.Phone__c='9876543210';
insert cand;
PageReference myVfPage = Page.ThanksPage;
 Test.setCurrentPageReference(myVfPage);
 Thankspageclass TP = new Thankspageclass(new ApexPages.StandardController (cand));
 TP.candidateEmail = cand.Email__c;
 }
}
Please let me know where i am going wrong.
component:
<aura:component implements="force:appHostable" controller="FetchRegistrations" >
    <aura:attribute name="reg" type="Registration__c[]"/>
    <ui:button label="Get Registrations" press="{!c.myAction}"/>
    <aura:iteration var="r" items="{!v.reg}" >
    <p>{!r.name}</p>
    </aura:iteration>
</aura:component>


Controller:
({
   myAction : function(component, event, helper) {
        var action = component.get("c.getAllregistrations");
        action.setCallback(this, function(response){
            var name = response.getState();
            if (name === "SUCCESS") {
                component.set("v.reg", response.getReturnValue());
            }
        });
     $A.enqueueAction(action);
    }
})

Apex:
global with sharing class FetchRegistrations {
@auraEnabled
    public static List<Registration__c> getAllregistrations()
    {
     List<Registration__c> reg=new LIST<Registration__c>();  
        reg=[select id,name,Email__c from Registration__c];
        return reg;
    } 
    public Registration__c getSelectedregistrations(Id id)
    {    
      Registration__c  reg=[select id,name,Email__c from Registration__c where id=:id];
        return reg;
    } 
   
}
Hi Everyone,
I passed the challenge.... but i got an error when creating record using flow.
Error is:  
An unhandled fault has occurred in this flow
An unhandled fault has occurred while processing the flow. Please contact your system administrator for more information.

How can resolve this error.    
  
User-added imageUser-added image
User-added image
User-added image

Create Record  :   Variable Name--

Create Account : AccountID
Create Contact : ContactID
Create Opportunity : OpportunityID
I'm getting this error while i'm running my test class. I have a webservice class which will send sms when i insert a new record or if i update a an existing record

Here are my webservice class, trigger which is invoking webservice call and test class for both class & trigger.

Web Service call

public class CreatingAccountsendsms { 
@Future(callout=true)
    public static void Creating_Lead(string mobile,string leadname,string Uname,string UMobilePhone) {
    
   // list<account> acc=[SELECT Id,Phone FROM Account where id=:conId];
    
                  String Username ='management@abc.com';
                  String Password = '321@admin';
                  String TempID='21341';
                  String MobileNo=mobile;
                  String SenderID = 'ABC';
                  String F1= leadname;
                  String F3= Uname;
                  String F2= UMobilePhone;
                  String F4= '';
       String postData = 'username=' +Username + '&pass=' + Password + '&dest_mobileno=' + MobileNo +'&senderid=' + SenderID + '&tempid=' + TempID+'&F1=' + F1+ '&F2=' + F2+ '&F3=' + F3+'&F4=' + F4;
       
       HttpRequest req = new HttpRequest();
    req.setEndpoint('http://123.01.01.01/blank/sms/user/urlsmstemp.php?'+postdata);
    req.setMethod('GET');
    system.debug(req);
    Http h = new Http();
    HttpResponse res = h.send(req);
    
    //system.debug(res);
    //return res;
    } 

     @Future(callout=true)
    public static void CreatingAccountsendsms1(string mobile,string leadname,string Uname,string UMobilePhone) {
   
   // list<account> acc=[SELECT Id,Phone FROM Account where id=:conId];
   
                  String Username ='management@ABC.com';
                  String Password = '321@admin';
                  String TempID='21342';
                  String MobileNo=mobile;
                  String SenderID = 'ABC';
                  String F1= leadname;
                  String F2= Uname;
                  String F3= UMobilePhone;
                  String F4= 'creatorname';
       String postData = 'username=' +Username + '&pass=' + Password + '&dest_mobileno=' + MobileNo +'&senderid=' + SenderID + '&tempid=' + TempID+'&F1=' + F1+ '&F2=' + F2+ '&F3=' + F3+'&F4=' + F4;
      
       HttpRequest req = new HttpRequest();
    req.setEndpoint('http://123.01.01.01/blank/sms/user/urlsmstemp.php?'+postdata);
    req.setMethod('GET');
    system.debug(req);
    Http h = new Http();
    HttpResponse res = h.send(req);
   
    //system.debug(res);
    //return res;
    }

}

Trigger to invoke my webservice method

trigger sms on Account (after insert,after update) {


for(Account acc:trigger.new)
{
user u=[SELECT Alias,Id,MobilePhone,Name,Phone,ProfileId FROM User where Id=:acc.OwnerId];
Profile p = [SELECT id,Name FROM Profile WHERE Id = :u.profileid];
system.debug('@@@@@@@@@+++++++++++++++++++++++++++++++++++++++++++++++++++++='+p.name);


if(trigger.isafter){
 CreatingAccountsendsms.Creating_Lead(acc.PersonMobilePhone,acc.Lastname,u.name,u.phone);
}
if(trigger.isupdate)
{
user u1=[SELECT Alias,Id,MobilePhone,Name,Phone FROM User where Id=:acc.CreatedById];
if(acc.ownerid != trigger.oldmap.get(acc.id).ownerid )
{
if(p.name=='SPU - Sales Manager' || p.name=='Unishire Sales Profile' || p.name=='Channel Sales Manager')
{
system.debug('@@@@@@@@@+++++++++++++++++++++++++++++++++++++++++++++++++++++='+p.name);
 sendsms.sendsms1(u.MobilePhone,u.name,acc.Lastname,acc.PersonMobilePhone,acc.Project_Interested__c,u1.name);
 CreatingAccountsendsms.CreatingAccountsendsms1(acc.PersonMobilePhone,acc.Lastname,u.name,u.MobilePhone);
 //acc.name=u.Lastname;
//sendsms.sendsms1(acc.Phone1__c,acc.name);
}
}
}
}
}

the above class and trigeer is for Account object and I have same kind of class and trigger for Debit Note also. 

In my test class if i just insert account test method will be passed if i insert new debit note record along with account then i'm getting this callout exception

Error Message : System.CalloutException: You have uncommitted work pending. Please commit or rollback before calling out
Stack Trace  :  Class.CreatingAccountsendsms.Creating_Lead: line 50, column 1

Here is my test class

@isTest(SeeAllData=true)
public class new_test_class1{
    @isTest static void Test_lead(){
        
        Account acc= new Account(); 
        acc.name='Acc1';
        acc.Status__c='new';
        acc.Custom_AN__c=1;
        acc.Project_Interested__c='atrium';
        acc.Phone1__c='8015825819';
        acc.Email__c='samdbinu@gmail.com';
        insert acc;
        
        Debit_Note__c DN = new Debit_Note__c();
        DN.Name = 'test';
        DN.Account__c = acc.id;
        insert DN;
        
        
                
        Test.startTest();
         Test.setMock(HttpCalloutMock.class, new Stubby());
         string mobile = '12345';
         string name = 'Sharat';
         string status = 'done';
         string dateon = '1/1/2014';
         string Uname = 'New';
         string Umobile = '90086573';
         string leadname = 'Test';
         string UMobilePhone = '90087345';
        
         CreatingAccountsendsms.CreatingAccountsendsms1(mobile,leadname,Uname,UMobilePhone);
        Test.StopTest();
    }
}



component:
<aura:component implements="force:appHostable" controller="FetchRegistrations" >
    <aura:attribute name="reg" type="Registration__c[]"/>
    <ui:button label="Get Registrations" press="{!c.myAction}"/>
    <aura:iteration var="r" items="{!v.reg}" >
    <p>{!r.name}</p>
    </aura:iteration>
</aura:component>


Controller:
({
   myAction : function(component, event, helper) {
        var action = component.get("c.getAllregistrations");
        action.setCallback(this, function(response){
            var name = response.getState();
            if (name === "SUCCESS") {
                component.set("v.reg", response.getReturnValue());
            }
        });
     $A.enqueueAction(action);
    }
})

Apex:
global with sharing class FetchRegistrations {
@auraEnabled
    public static List<Registration__c> getAllregistrations()
    {
     List<Registration__c> reg=new LIST<Registration__c>();  
        reg=[select id,name,Email__c from Registration__c];
        return reg;
    } 
    public Registration__c getSelectedregistrations(Id id)
    {    
      Registration__c  reg=[select id,name,Email__c from Registration__c where id=:id];
        return reg;
    } 
   
}