• Harshal Katole 7
  • NEWBIE
  • 10 Points
  • Member since 2021

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 8
    Questions
  • 9
    Replies
getting error : This page has an error. You might just need to refresh it. Action failed: c:LightningHotelManCompo$controller$doSave [component is not defined] Failing descriptor: {c:LightningHotelManCompo$controller$doSave}

application :


<aura:application extends="force:slds" >
    <c:LightningHotelManCompo/>
</aura:application>
================================
component

<aura:component controller="LightningHotelManApex"
                implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" 
                access="global" >
    
    <aura:attribute name="Guesthotel" type="Guest_Master__c" default="{'sObjectType':'Guest_Master__c',
                                                                   'Guest_First_Name__c':'',
                                                                   'Guest_Last_Name__c':'',
                                                                   'Guest_Phone__c':'',
                                                                   'Guest_Email__c':'',
                                                                   'Number_of_Adults_12_yrs__c':'',
                                                                   'Number_of_Children_0_12_yrs__c':'',
                                                                   'Check_in_Date__c':'',
                                                                   'Check_Out_Date__c':'',
                                                                   'City_of_Hotel__c':'',
                                                                   'Preferred_Hotel_Type__c':''}"/>
    
    <div>
      <div class="slds-card">
          <div class="slds-p-around_medium">Please Enter Details</div>
      </div>

   </div>
    
    <div class="Container-fluid">
        <div class="form-group">
            <label> First Name </label>
            <ui:inputText Class="form-control" value="{!v.Guesthotel.Guest_First_Name__c}"/>
        </div>
         <div class="form-group">
            <label> Last Name </label>
            <ui:inputText Class="form-control" value="{!v.Guesthotel.Guest_Last_Name__c}"/>
        </div>
         <div class="form-group">
            <label> Phone </label>
            <ui:inputText Class="form-control" value="{!v.Guesthotel.Guest_Phone__c}"/>
        </div>
         <div class="form-group">
            <label> Email </label>
            <ui:inputText Class="form-control" value="{!v.Guesthotel.Guest_Email__c}"/>
        </div>
         <div class="form-group">
            <label> Number of Adults(12+ yrs) </label>
            <ui:inputText Class="form-control" value="{!v.Guesthotel.Number_of_Adults_12_yrs__c}"/>
        </div>
         <div class="form-group">
            <label> Number of Adults(0-12 yrs) </label>
            <ui:inputText Class="form-control" value="{!v.Guesthotel.Number_of_Children_0_12_yrs__c}"/>
        </div>
         <div class="form-group">
            <label> Check in Date </label>
            <ui:inputText Class="form-control" value="{!v.Guesthotel.Check_in_Date__c}"/>
        </div>
         <div class="form-group">
            <label> Check out Date </label>
            <ui:inputText Class="form-control" value="{!v.Guesthotel.Check_Out_Date__c}"/>
        </div>
         <div class="form-group">
            <label> City of Hotel </label>
            <ui:inputText Class="form-control" value="{!v.Guesthotel.City_of_Hotel__c}"/>
        </div>
         <div class="form-group">
            <label> Prferred Hotel Type </label>
            <ui:inputText Class="form-control" value="{!v.Guesthotel.Preferred_Hotel_Type__c}"/>
        </div>
    </div>
    
    <div class="col-md-4 text-center">
        <ui:button class="btn btn-default" press="{!c.doSave}"> Save </ui:button>
    </div>
</aura:component>
=============================================

controller

({
    doSave : function(component, event, helper) {
        console.log('create records');
        
       helper.helperMethodGuest(component);
        
    }
})
==========================================
helper

({
    helperMethodGuest : function() {
        
        console.log('create records in helper ');
        var varGuest = component.get("v.Guesthotel");
        var action = component.get("c.saveRecord");
        action.setParams({
            "guest" : varGuest
        });
            action.setCallback(this,function(response){
             var state = response.getState();
            
            if(state =="SUCCESSS"){
            
            var newEmptyGuest = {'sObjectType':'Guest_Master__c',
                                     'Guest_First_Name__c':'',
                                     'Guest_Last_Name__c':'',
                                     'Guest_Phone__c':'',
                                     'Guest_Email__c':'',
                                     'Number_of_Adults_12_yrs__c':'',
                                     'Number_of_Children_0_12_yrs__c':'',
                                     'Check_in_Date__c':'',
                                     'Check_Out_Date__c':'',
                                     'City_of_Hotel__c':'',
                                     'Preferred_Hotel_Type__c':''};
                         component.set("v.Guesthotel",newEmptyGuest);
                         alert('Record is create succesfully');
        
        
    }else if(state=="ERROR"){
    alert('Error is clling server side action');
    
    var ErrorDetails =response.getError();
    alert('Reason of error ='+ErrorDetails[0].message);
}
        });
        $A.enqueueAction(action);
        
    }
})
===================================
apex class

public class LightningHotelManApex {
    @AuraEnabled
    public static void saveRecord(Guest_Master__c guest){
        
        try{
            system.debug(' guest record ::'+guest);
            if(guest != null){
                insert guest;
            }
        }catch(Exception ex){
            
        }
    }

}
getting error : 
Error is in expression '{!fetchData}' in component <apex:commandButton> in page searchcoursevf: Class.SearchCourse.fetchData: line 8, column 1
An unexpected error has occurred. Your development organization has been notified
.


public class SearchCourse {
    public string SearchText {set;get;}
     public string query {set;get;}
     public List<Training_Deal__c> traindeal {set;get;}
    public void fetchData(){
       
        string query = 'SELECT id, Name, Course__c,Discount__c,Student__c,Email_of_Student__c,Trainer_Appointed__c FROM Training_Deal__c WHERE Course__c =\''+SearchText+'\' ';
        traindeal=Database.query(query);
        system.debug(traindeal);
    }

}
==============================
<apex:page controller="SearchCourse" >
    <apex:form id="fm">
        <apex:inputText value="{!SearchText}"/>
        <apex:commandButton value="Search" action="{!fetchData}" reRender="fm"/><br/><br/>
        <apex:dataTable value="{!traindeal}" var="a" cellpadding="5"  rules="Rows" width="20" border="frame">
            <apex:column value="{!a.Name}" headerValue="Deal code"/>
            <apex:column value="{!a.Course__c}" headerValue="Course"/>
            <apex:column value="{!a.Discount__c}" headerValue="Discount"/>
            <apex:column value="{!a.Student__c}" headerValue="Student"/>
            <apex:column value="{!a.Email_of_Student__c}" headerValue="Student Email"/>
            <apex:column value="{!a.Trainer_Appointed__c}" headerValue="Trainer"/>
  
                         
        </apex:dataTable>
    </apex:form>
</apex:page>
here is 3 button ===1. send email  2. reset  3. generte PDF

I want generate pdf when we click on 'generte PDF' button. renderAs doesnt worked here. alo i want reset my form when we click on 'reset' button.


<apex:page controller="VendorForm" renderAs="pdf" >
    <apex:form>
       <apex:pageBlock title="Vendor Registration From">
           Vendor company name <apex:inputText value="{!VendorComName}"/><br/><br/>
          Vendor contact person <apex:inputText value="{!VendorConPer}"/><br/><br/>
          Amount per Event <apex:inputText value="{!AmmtPerEve}"/><br/><br/>
          City <apex:inputText value="{!VendorCity}"/><br/><br/>
          Country <apex:inputText value="{!VendorCountry}"/><br/><br/>
           <apex:pageBlockButtons >
               <apex:commandButton value="Send Email" action="sendEmail"/>
               <apex:commandButton value="Reset" action="{!resetForm}"/>
               <apex:commandButton value="Generate PDF" action="{!generatePDF}" />
           </apex:pageBlockButtons>
        </apex:pageBlock>
    </apex:form>
</apex:page>
==============================
public class VendorForm {
    public string VendorComName {set;get;}
    public string VendorConPer {set;get;}
    public string AmmtPerEve {set;get;}
    public string VendorCity {set;get;}
    public string VendorCountry {set;get;}
    
    public void generatePDF(){
        Vendor__c v = new Vendor__c();
        v.Name = VendorComName;
        v.Vendor_Contact_Person__c = VendorConPer;
        v.Amount_per_Event__c = AmmtPerEve;
        v.City__c = VendorCity;
        v.Country__c = VendorCountry;
    }
    public void sendEmail(){
        
    }
    public void resetForm(){
        Vendor__c v = new Vendor__c();
         v.Name = '';
        v.Vendor_Contact_Person__c = '';
        v.Amount_per_Event__c = '';
        v.City__c = '';
        v.Country__c = '';
    }
}
i have course field on Training_Deal__c
==============================
public class SearchCourse {
    public string SearchText {set;get;}
     public string query {set;get;}
     public List<Training_Deal__c> deal {set;get;}
    public void fetchData(){
       
        string query = 'SELECT id, Name, Course__c,Discount__c,Student__c,Email_of_Student__c,Trainer_Appointed__c FROM Training_Deal__c WHERE Course__c =:'+SearchText ;
        deal=Database.query(query);
        system.debug(deal);
    }

}
=======================================
<apex:page controller="SearchCourse" >
    <apex:form id="fm">
        <apex:inputText value="{!SearchText}"/>
        <apex:commandButton value="Search" action="{!fetchData}" reRender="fm"/><br/><br/>
        <apex:dataTable value="{!deal}" var="a" cellpadding="5"  rules="Rows" width="20" border="frame">
            <apex:column value="{!a.Name}" headerValue="Deal code"/>
            <apex:column value="{!a.Course__c}" headerValue="Course"/>
            <apex:column value="{!a.Discount__c}" headerValue="Discount"/>
            <apex:column value="{!a.Student__c}" headerValue="Student"/>
            <apex:column value="{!a.Email_of_Student__c}" headerValue="Student Email"/>
            <apex:column value="{!a.Trainer_Appointed__c}" headerValue="Trainer"/>
  
                         
        </apex:dataTable>
    </apex:form>
</apex:page>
object = contact
multiselect picklist 1 = abc__c => values : 1,2,3,4,5,6,7
multiselect picklist 2 = xyz__c => values : 1,2,3,4,5,6,7
 scenario : check both field value not same while creating a record. if its same then thrown error.

i want to use CONTAINS() function  insted of ContainsAll() here,.how can i achieved ??

public class checkdupcontact2{
    public static void invoke(list<contact> cc){
        for(contact a : cc){
             if( a.abc__c != null && a.xyz__c != null ){
                 
            list<string> VarList1 =a.abc__c.split(';'); 
            list<string> VarList2 =a.xyz__c.split(';'); 
            set<string> VarSetAdd1 = new set<string>();
            VarSetAdd1.addAll(VarList1);
            set<string> VarSetAdd2 = new set<string>();
            VarSetAdd2.addAll(VarList2);
            
           
                if(VarList1.contains(VarList2)){
                a.addError('error');
            }
          }     
        }
    }
}
object = contact
multiselect picklist 1 = abc__c => values : 1,2,3,4,5,6,7
multiselect picklist 2 = xyz__c => values : 1,2,3,4,5,6,7
 scenario : check both field value not same while creating a record. if its same then thrown error.
 not working ?


public class checkdupcontact{
    public static void invoke(list<contact> cc){
        for(contact a : cc){
            list<string> VarList1 = a.abc__c.split(';'); 
            list<string> VarList2 = a.xyz__c.split(';'); 
            set<string> VarSetAdd1 = VarSetAdd1.addAll(VarList1);
            set<string> VarSetAdd2 = VarSetAdd2.addAll(VarList2);
            
            if(VarSetAdd1.containsAll(VarSetAdd2)){
                a.addError('error');
                
            }
        }
    }
}    
 
picklist field : background ====> banking , engg. ,commerce.

in process builder criteria : i want to background belong to "sales" which is not present in picklist LOV
how to enter "sales"  value in that farmula bar

pls help
picklist field : Course ===> c , cpp ,java,php
multiselecr picklist: Trainer ====> engineeing, bsc,msc,ma

validation rule : for c & cpp only bsc and msc trainer are allowed otherwise throen error.

pls help
getting error : This page has an error. You might just need to refresh it. Action failed: c:LightningHotelManCompo$controller$doSave [component is not defined] Failing descriptor: {c:LightningHotelManCompo$controller$doSave}

application :


<aura:application extends="force:slds" >
    <c:LightningHotelManCompo/>
</aura:application>
================================
component

<aura:component controller="LightningHotelManApex"
                implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" 
                access="global" >
    
    <aura:attribute name="Guesthotel" type="Guest_Master__c" default="{'sObjectType':'Guest_Master__c',
                                                                   'Guest_First_Name__c':'',
                                                                   'Guest_Last_Name__c':'',
                                                                   'Guest_Phone__c':'',
                                                                   'Guest_Email__c':'',
                                                                   'Number_of_Adults_12_yrs__c':'',
                                                                   'Number_of_Children_0_12_yrs__c':'',
                                                                   'Check_in_Date__c':'',
                                                                   'Check_Out_Date__c':'',
                                                                   'City_of_Hotel__c':'',
                                                                   'Preferred_Hotel_Type__c':''}"/>
    
    <div>
      <div class="slds-card">
          <div class="slds-p-around_medium">Please Enter Details</div>
      </div>

   </div>
    
    <div class="Container-fluid">
        <div class="form-group">
            <label> First Name </label>
            <ui:inputText Class="form-control" value="{!v.Guesthotel.Guest_First_Name__c}"/>
        </div>
         <div class="form-group">
            <label> Last Name </label>
            <ui:inputText Class="form-control" value="{!v.Guesthotel.Guest_Last_Name__c}"/>
        </div>
         <div class="form-group">
            <label> Phone </label>
            <ui:inputText Class="form-control" value="{!v.Guesthotel.Guest_Phone__c}"/>
        </div>
         <div class="form-group">
            <label> Email </label>
            <ui:inputText Class="form-control" value="{!v.Guesthotel.Guest_Email__c}"/>
        </div>
         <div class="form-group">
            <label> Number of Adults(12+ yrs) </label>
            <ui:inputText Class="form-control" value="{!v.Guesthotel.Number_of_Adults_12_yrs__c}"/>
        </div>
         <div class="form-group">
            <label> Number of Adults(0-12 yrs) </label>
            <ui:inputText Class="form-control" value="{!v.Guesthotel.Number_of_Children_0_12_yrs__c}"/>
        </div>
         <div class="form-group">
            <label> Check in Date </label>
            <ui:inputText Class="form-control" value="{!v.Guesthotel.Check_in_Date__c}"/>
        </div>
         <div class="form-group">
            <label> Check out Date </label>
            <ui:inputText Class="form-control" value="{!v.Guesthotel.Check_Out_Date__c}"/>
        </div>
         <div class="form-group">
            <label> City of Hotel </label>
            <ui:inputText Class="form-control" value="{!v.Guesthotel.City_of_Hotel__c}"/>
        </div>
         <div class="form-group">
            <label> Prferred Hotel Type </label>
            <ui:inputText Class="form-control" value="{!v.Guesthotel.Preferred_Hotel_Type__c}"/>
        </div>
    </div>
    
    <div class="col-md-4 text-center">
        <ui:button class="btn btn-default" press="{!c.doSave}"> Save </ui:button>
    </div>
</aura:component>
=============================================

controller

({
    doSave : function(component, event, helper) {
        console.log('create records');
        
       helper.helperMethodGuest(component);
        
    }
})
==========================================
helper

({
    helperMethodGuest : function() {
        
        console.log('create records in helper ');
        var varGuest = component.get("v.Guesthotel");
        var action = component.get("c.saveRecord");
        action.setParams({
            "guest" : varGuest
        });
            action.setCallback(this,function(response){
             var state = response.getState();
            
            if(state =="SUCCESSS"){
            
            var newEmptyGuest = {'sObjectType':'Guest_Master__c',
                                     'Guest_First_Name__c':'',
                                     'Guest_Last_Name__c':'',
                                     'Guest_Phone__c':'',
                                     'Guest_Email__c':'',
                                     'Number_of_Adults_12_yrs__c':'',
                                     'Number_of_Children_0_12_yrs__c':'',
                                     'Check_in_Date__c':'',
                                     'Check_Out_Date__c':'',
                                     'City_of_Hotel__c':'',
                                     'Preferred_Hotel_Type__c':''};
                         component.set("v.Guesthotel",newEmptyGuest);
                         alert('Record is create succesfully');
        
        
    }else if(state=="ERROR"){
    alert('Error is clling server side action');
    
    var ErrorDetails =response.getError();
    alert('Reason of error ='+ErrorDetails[0].message);
}
        });
        $A.enqueueAction(action);
        
    }
})
===================================
apex class

public class LightningHotelManApex {
    @AuraEnabled
    public static void saveRecord(Guest_Master__c guest){
        
        try{
            system.debug(' guest record ::'+guest);
            if(guest != null){
                insert guest;
            }
        }catch(Exception ex){
            
        }
    }

}
object = contact
multiselect picklist 1 = abc__c => values : 1,2,3,4,5,6,7
multiselect picklist 2 = xyz__c => values : 1,2,3,4,5,6,7
 scenario : check both field value not same while creating a record. if its same then thrown error.

i want to use CONTAINS() function  insted of ContainsAll() here,.how can i achieved ??

public class checkdupcontact2{
    public static void invoke(list<contact> cc){
        for(contact a : cc){
             if( a.abc__c != null && a.xyz__c != null ){
                 
            list<string> VarList1 =a.abc__c.split(';'); 
            list<string> VarList2 =a.xyz__c.split(';'); 
            set<string> VarSetAdd1 = new set<string>();
            VarSetAdd1.addAll(VarList1);
            set<string> VarSetAdd2 = new set<string>();
            VarSetAdd2.addAll(VarList2);
            
           
                if(VarList1.contains(VarList2)){
                a.addError('error');
            }
          }     
        }
    }
}
object = contact
multiselect picklist 1 = abc__c => values : 1,2,3,4,5,6,7
multiselect picklist 2 = xyz__c => values : 1,2,3,4,5,6,7
 scenario : check both field value not same while creating a record. if its same then thrown error.
 not working ?


public class checkdupcontact{
    public static void invoke(list<contact> cc){
        for(contact a : cc){
            list<string> VarList1 = a.abc__c.split(';'); 
            list<string> VarList2 = a.xyz__c.split(';'); 
            set<string> VarSetAdd1 = VarSetAdd1.addAll(VarList1);
            set<string> VarSetAdd2 = VarSetAdd2.addAll(VarList2);
            
            if(VarSetAdd1.containsAll(VarSetAdd2)){
                a.addError('error');
                
            }
        }
    }
}    
 
picklist field : background ====> banking , engg. ,commerce.

in process builder criteria : i want to background belong to "sales" which is not present in picklist LOV
how to enter "sales"  value in that farmula bar

pls help
picklist field : Course ===> c , cpp ,java,php
multiselecr picklist: Trainer ====> engineeing, bsc,msc,ma

validation rule : for c & cpp only bsc and msc trainer are allowed otherwise throen error.

pls help