Create a record on custom Object to insert record Id of lookup field value with passing parameters to apex class using custom controller in Lightning Component Salesforce | how to insert lookup field in salesforce using apex

2,256 views

Hey guys, today in this post we are going to learn about how to Create a record on custom Object to insert record Id of lookup field value with passing parameters to apex class using custom controller in Lightning Component Salesforce .

We used the files in this example

feesCmp.cmp Lightning Component It is used for display the Input filed of Student Name, Course, Date Of Deposit, Paid Amount and Save button on the Table.
feesCmpController.js JavaScript Controller File It is used for insert lookup field value, Date Of Deposit, Paid Amount value to server side apex method.
feesCmp.css Component Style CSS It is used for alignment the lookup popup section and spinner loading image on component.
newStudentCtr.apxc Apex Class Controller It is used for submit the lookup field value, Date Of Deposit, Paid Amount value to server through Save button

Custom Object:- Fees__c

Custom Object Fields:-

StudentName__c

CourseName__c

&DateOfDeposit__c

PaidAmount__c

Lookup Object:- NewStudent__c :- Get the Student name from lookup object field Lookup Object:- Course__c :- Get the Course name from lookup object field

Note:-Static resource zip file

You need to create $Resource.SLDS2016 SLDS zip file (static resource zip file)

Final Output

display picklist and radio values in lightning component -- w3web.net

 

You can download file directly from github by Click Here.

 

 

Other related post that would you like to learn in Salesforce

 

Create Lightning Component

Step 1:- Create Lightning Component : feesCmp.cmp

From Developer Console >> File >> New >> Lightning Component

feesCmp.cmp [Lightning Component File]

  1.  
  2.     <aura:component controller="newStudentCtr" implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction,lightning:actionOverride,lightning:isUrlAddressable" access="global" >
  3.     <aura:html tag="style">.forceStyle.desktop .viewport{background:#fff;}</aura:html>
  4.     <aura:attribute name="feesObj" type="Fees__c" default="{'sobjectType':'Fees__c'}"/>
  5.     <aura:attribute name="feesNameItems" type="Object[]"/>
  6.     <aura:attribute name="feeSelectId" type="string"/>    
  7.     <aura:attribute name="feeSelectedSerchName" type="string"/>
  8.     <aura:attribute name="courseFeeNameItems" type="Object[]"/>
  9.     <aura:attribute name="courseFeeId" type="string"/>    
  10.     <aura:attribute name="courseFeeSelectedSerchName" type="string"/>
  11.  
  12.     <div class="slds slds-p-horizontal--medium">
  13.         <div class="slds-grid slds-wrap">
  14.             <div class="slds-p-horizontal--medium slds-col slds-size_6-of-12 slds-m-bottom--medium">
  15.                 <div class="slds-form-element">
  16.                     <label class="slds-form-element__label">Student Name</label> 
  17.                     <div class="slds-form-element__controller" style="position:relative;">
  18.                         <div aura:id="feeStudentSpinId" class="slds-input-has-icon slds-input-has-icon--right spinnerItem">
  19.                             <ui:inputText aura:id="feeStudentNameId" placeholder="Search student..." class="slds-input" keyup="{!c.lookupSearchFeeName}" updateOn="keyup" value="{!v.feesObj.StudentName__c}"/>
  20.                             <i class="spinnerIcon" ><img src="/resource/SLDS2016/assets/images/spinners/slds_spinner_brand.gif" /></i>
  21.                             <c:svg class="slds-input__icon" xlinkHref="/resource/SLDS2016/assets/icons/utility-sprite/svg/symbols.svg#search"/>
  22.                         </div>
  23.  
  24.                         <div aura:id="feesOpenDivId" class="slds-m-top--small slds-dropdown-trigger slds-dropdown-trigger--click" > 
  25.                             <section class="slds-dropdown slds-popover slds-nubbin--top-left slds-dropdown-trigger" style="position:absolute; left:158px; top: -9px;"> 
  26.                                 <div class="slds-popover__body slds-p-vertical--xx-small slds-p-horizontal--none slds-scrollable--y" style="max-height:150px;"> 
  27.                                     <ul class="slds-dropdown__list slds-dropdown--length10">
  28.                                         <aura:iteration items="{!v.feesNameItems}" var="feeStudentVar" indexVar="goNumber">
  29.                                             <li>
  30.                                                 <span class="slds-lookup__item-action slds-media"> 
  31.                                                     <c:svg class="slds-icon slds-icon-standard-contact slds-icon--small slds-m-right--xx-small"  xlinkHref="/resource/SLDS2016/assets/icons/utility-sprite/svg/symbols.svg#user" />
  32.                                                     <a id="{!feeStudentVar.Id}" role="option" 
  33.                                                        data-id="{!feeStudentVar.Id}" onclick="{!c.feeSelectSearchItem}">                                                    
  34.                                                         {!feeStudentVar.Name}
  35.                                                     </a>
  36.                                                 </span>   
  37.  
  38.                                             </li>
  39.  
  40.                                         </aura:iteration>      
  41.                                     </ul>
  42.                                 </div> 
  43.                             </section>
  44.  
  45.                         </div>
  46.  
  47.  
  48.                         <div aura:id="feesPillListDivId" class="slds-hide">
  49.                             <ul> 
  50.                                 <li class="slds-pill slds-show slds-show slds-m-around--none" >
  51.                                     <a  id="" role="option" onclick="{!c.removeSelectedSerchItem}" data-id="">
  52.                                         <c:svg class="slds-icon slds-icon-standard-contact slds-icon--small slds-m-right--xx-small" xlinkHref="/resource/SLDS2016/assets/icons/utility-sprite/svg/symbols.svg#user" />
  53.                                         {!v.feeSelectedSerchName}
  54.                                         <button class="slds-button slds-butto--icon slds-float--right slds-pill__remove slds-m-top--xx-small" style="line-height:1.45rem;">
  55.                                             <c:svg class="slds-button__icon" xlinkHref="/resource/SLDS2016/assets/icons/utility-sprite/svg/symbols.svg#close" />
  56.                                         </button>     
  57.                                     </a>
  58.                                 </li>      
  59.                             </ul>
  60.                         </div>
  61.  
  62.  
  63.                     </div>
  64.                 </div>
  65.             </div>
  66.  
  67.  
  68.             <div class="slds-p-horizontal--medium slds-col slds-size_6-of-12 slds-m-bottom--medium">
  69.                 <div class="slds-form-element">
  70.                     <label class="slds-form-element__label">Course</label> 
  71.                     <div class="slds-form-element__controller" style="position:relative;">
  72.                         <div aura:id="courseFeeStudentSpinId" class="slds-input-has-icon slds-input-has-icon--right spinnerItem">
  73.                             <ui:inputText aura:id="courseFeeNameId" placeholder="Search course..." class="slds-input" keyup="{!c.courseLookupSearch}" updateOn="keyup" value="{!v.feesObj.CourseName__c}"/>
  74.                             <i class="spinnerIcon" ><img src="/resource/SLDS2016/assets/images/spinners/slds_spinner_brand.gif" /></i>
  75.                             <c:svg class="slds-input__icon" xlinkHref="/resource/SLDS2016/assets/icons/utility-sprite/svg/symbols.svg#search"/>
  76.                         </div>
  77.  
  78.  
  79.                         <div aura:id="courseFeeOpenDivId" class="slds-m-top--small slds-dropdown-trigger slds-dropdown-trigger--click" > 
  80.                             <section class="slds-dropdown slds-popover slds-nubbin--top-left slds-dropdown-trigger" style="position:absolute; left:163px; top: -10px;"> 
  81.                                 <div class="slds-popover__body slds-p-vertical--xx-small slds-p-horizontal--none slds-scrollable--y" style="max-height:150px;"> 
  82.                                     <ul class="slds-dropdown__list slds-dropdown--length10">
  83.                                         <aura:iteration items="{!v.courseFeeNameItems}" var="courseFeeVar" indexVar="goNumber">
  84.                                             <li>
  85.                                                 <span class="slds-lookup__item-action slds-media"> 
  86.                                                     <c:svg class="slds-icon slds-icon-standard-contact slds-icon--small slds-m-right--xx-small"  xlinkHref="/resource/SLDS2016/assets/icons/utility-sprite/svg/symbols.svg#user" />
  87.                                                     <a id="{!courseFeeVar.Id}" role="option" 
  88.                                                        data-id="{!courseFeeVar.Id}" onclick="{!c.courseFeeVarSelectSearchItem}">                                                    
  89.                                                         {!courseFeeVar.Name}
  90.                                                     </a>
  91.                                                 </span>   
  92.  
  93.                                             </li>
  94.  
  95.                                         </aura:iteration>      
  96.                                     </ul>
  97.                                 </div> 
  98.                             </section>
  99.  
  100.                         </div>
  101.  
  102.  
  103.                         <div aura:id="courseFeePillListDivId" class="slds-hide">
  104.                             <ul> 
  105.                                 <li class="slds-pill slds-show slds-show slds-m-around--none" >
  106.                                     <a  id="" role="option" onclick="{!c.courseFeeRemoveSelectedItem}" data-id="">
  107.                                         <c:svg class="slds-icon slds-icon-standard-contact slds-icon--small slds-m-right--xx-small" xlinkHref="/resource/SLDS2016/assets/icons/utility-sprite/svg/symbols.svg#user" />
  108.                                         {!v.courseFeeSelectedSerchName}
  109.                                         <button class="slds-button slds-butto--icon slds-float--right slds-pill__remove slds-m-top--xx-small" style="line-height:1.45rem;">
  110.                                             <c:svg class="slds-button__icon" xlinkHref="/resource/SLDS2016/assets/icons/utility-sprite/svg/symbols.svg#close" />
  111.                                         </button>     
  112.                                     </a>
  113.                                 </li>      
  114.                             </ul>
  115.                         </div>                         
  116.  
  117.  
  118.                     </div>
  119.                 </div>
  120.             </div>
  121.  
  122.  
  123.             <div class="slds-p-horizontal--medium slds-col slds-size_6-of-12 slds-m-bottom--medium">
  124.                 <div class="slds-form-element">
  125.                     <div class="slds-form-element__controller">
  126.                         <lightning:input type="date" autocomplete="off" name="dateOfDeposit" aura:id="dateOfDeposit" value="{!v.feesObj.DateOfDeposit__c}"  label="Date Of Deposit" labelClass="slds-form-element__label" />
  127.                     </div>
  128.                 </div>
  129.             </div>
  130.  
  131.             <div class="slds-p-horizontal--medium slds-col slds-size_6-of-12 slds-m-bottom--medium">
  132.                 <div class="slds-form-element">
  133.                     <label class="slds-form-element__label">Paid Amount</label>
  134.                     <div class="slds-form-element__controller">
  135.                         <ui:inputCurrency class="slds-input"  aura:id="paidAmount" value="{!v.feesObj.PaidAmount__c}"/>
  136.                     </div>
  137.                 </div>
  138.             </div>
  139.  
  140.         </div>
  141.  
  142.         <div class="slds-text-align--center slds-m-top--medium">
  143.             <button class="slds-button slds-button--brand" onclick="{!c.submitFeeAction}">Submit</button>
  144.         </div>
  145.  
  146.   <br/><br/>
  147.    <!--Start RelatedTopics Section-->
  148. <div style="border:1px #ddd solid; padding:10px; background:#eee; margin:40px 0;">
  149.  
  150.             <p data-aura-rendered-by="435:0"><img src="https://www.w3web.net/wp-content/uploads/2021/05/thumbsUpLike.png" width="25" height="25" style="vertical-align:top; margin-right:10px;" data-aura-rendered-by="436:0"><strong data-aura-rendered-by="437:0"><span style="font-size:16px; font-style:italic; display:inline-block; margin-right:5px;">Don't forget to check out:-</span><a href="https://www.w3web.net/" target="_blank" rel="noopener noreferrer" style="text-decoration:none;" data-aura-rendered-by="440:0">An easy way to learn step-by-step online free Salesforce tutorial, To know more Click  <span style="color:#ff8000; font-size:18px;" data-aura-rendered-by="442:0">Here..</span></a></strong></p>
  151.  
  152.             <br/><br/>
  153.             <p data-aura-rendered-by="435:0"><img src="https://www.w3web.net/wp-content/uploads/2021/07/tickMarkIcon.png" width="25" height="25" style="vertical-align:top; margin-right:10px;" data-aura-rendered-by="436:0"><strong data-aura-rendered-by="437:0"><span style="font-size:17px; font-style:italic; display:inline-block; margin-right:5px; color:rgb(255 128 0);">You May Also Like β†’</span> </strong></p>
  154.             <div style="display:block; overflow:hidden;"> 
  155.                 <div style="width: 50%; float:left; display:inline-block">
  156.                     <ul style="list-style-type: square; font-size: 16px; margin: 0 0 0 54px; padding: 0;"> 
  157.                         <li><a href="https://www.w3web.net/lwc-get-set-lightning-checkbox-value/" target="_blank" rel="noopener noreferrer">How to get selected checkbox value in lwc</a></li>
  158.                         <li><a href="https://www.w3web.net/display-account-related-contacts-in-lwc/" target="_blank" rel="noopener noreferrer">how to display account related contacts based on AccountId in lwc</a></li>
  159.                         <li><a href="https://www.w3web.net/create-lightning-datatable-row-actions-in-lwc/" target="_blank" rel="noopener noreferrer">how to create lightning datatable row actions in lwc</a></li>
  160.                         <li><a href="https://www.w3web.net/if-and-else-condition-in-lwc/" target="_blank" rel="noopener noreferrer">how to use if and else condition in lwc</a></li>
  161.                         <li><a href="https://www.w3web.net/get-selected-radio-button-value-and-checked-default-in-lwc/" target="_blank" rel="noopener noreferrer">how to display selected radio button value in lwc</a></li>
  162.                     </ul>
  163.             </div>
  164.  
  165.             <div style="width: 50%; float:left; display:inline-block">
  166.                     <ul style="list-style-type: square; font-size: 16px; margin: 0 0 0 54px; padding: 0;"> 
  167.                         <li><a href="https://www.w3web.net/display-account-related-contacts-lwc/" target="_blank" rel="noopener noreferrer">display account related contacts based on account name in lwc</a></li>
  168.                         <li><a href="https://www.w3web.net/create-lightning-datatable-row-actions-in-lwc/" target="_blank" rel="noopener noreferrer">how to insert a record of account Using apex class in LWC</a></li>
  169.                         <li><a href="https://www.w3web.net/fetch-picklist-values-dynamic-in-lwc/" target="_blank" rel="noopener noreferrer">how to get picklist values dynamically in lwc</a></li>
  170.                         <li><a href="https://www.w3web.net/edit-save-and-remove-rows-dynamically-in-lightning-component/" target="_blank" rel="noopener noreferrer">how to edit/save row dynamically in lightning component</a></li>
  171.                         <li><a href="https://www.w3web.net/update-parent-object-from-child/" target="_blank" rel="noopener noreferrer">update parent field from child using apex trigger</a></li>
  172.                     </ul>
  173.                 </div>
  174.                <div style="clear:both;"></div> 
  175.                <br/>
  176.                 <div class="youtubeIcon">
  177.                     <a href="https://www.youtube.com/channel/UCW62gTen2zniILj9xE6LmOg" target="_blank" rel="noopener noreferrer"><img src="https://www.w3web.net/wp-content/uploads/2021/11/youtubeIcon.png" width="25" height="25" style="vertical-align:top; margin-right:10px;"/> <strong>TechW3web:-</strong> To know more, Use this <span style="color: #ff8000; font-weight: bold;">Link</span> </a>
  178.                 </div>
  179.     </div>
  180.  
  181. </div>
  182.  
  183.   <!--End RelatedTopics Section-->
  184.  
  185.     </div>
  186. </aura:component>

Create Component JavaScript Controller

Step 2:- Create Lightning Component : feesCmpController.js

From Developer Console >> File >> New >> Lightning Component >> JavaScript Controller

feesCmpController.js [JavaScript Controller]

  1.   ({
  2.     lookupSearchFeeName:function(component, event, helper){
  3.         var thisObjVal = event.getSource().get('v.value');
  4.         var feeStudentSpinId = component.find('feeStudentSpinId');
  5.         var feeStudentNameId = component.find('feeStudentNameId');
  6.         var feesOpenDivId = component.find('feesOpenDivId');
  7.         var feesPillListDivId = component.find('feesPillListDivId');
  8.  
  9.  
  10.         if(!$A.util.isUndefinedOrNull(thisObjVal) && thisObjVal.length>2){
  11.  
  12.             $A.util.addClass(feeStudentSpinId,'spinner');        
  13.             var action = component.get('c.getFeeStudent');
  14.             action.setParams({'searchFeeKey':thisObjVal});
  15.             action.setCallback(this, function(response){
  16.                 var state = response.getState();
  17.                 if(state == 'SUCCESS'){
  18.                     var result = response.getReturnValue(); 
  19.                     component.set('v.feesNameItems', result);
  20.                     $A.util.removeClass(feeStudentSpinId,'spinner');
  21.                     $A.util.addClass(feesOpenDivId,'slds-is-open');
  22.                     //alert('data saved successfully');
  23.                 }
  24.             });
  25.             $A.enqueueAction(action);
  26.         } else{
  27.              component.set('v.feesNameItems', null);
  28.             $A.util.removeClass(feeStudentSpinId,'spinner');
  29.             $A.util.removeClass(feesOpenDivId,'slds-is-open');
  30.         }
  31.  
  32.  
  33.     },
  34.  
  35.     feeSelectSearchItem:function(component, event, helper){
  36.         var getObjName = event.target.innerHTML;        
  37.         var getObjId = event.target.id;
  38.  
  39.         var feeStudentSpinId = component.find('feeStudentSpinId');
  40.         var feesOpenDivId = component.find('feesOpenDivId');
  41.         var feesPillListDivId = component.find('feesPillListDivId');
  42.  
  43.         component.set('v.feeSelectId',getObjId);
  44.         component.set('v.feeSelectedSerchName',getObjName);
  45.         $A.util.addClass(feeStudentSpinId,'slds-hide');
  46.         $A.util.removeClass(feesOpenDivId,'slds-is-open');
  47.         $A.util.removeClass(feesPillListDivId,'slds-hide');
  48.  
  49.     },
  50.  
  51.  
  52.     removeSelectedSerchItem:function(component, event, helper){
  53.         var feeStudentSpinId = component.find('feeStudentSpinId');
  54.         var feesOpenDivId = component.find('feesOpenDivId');
  55.         var feesPillListDivId = component.find('feesPillListDivId');
  56.  
  57.         component.set('v.feeSelectId','');
  58.         component.set('v.feesObj.StudentName__c','');
  59.         $A.util.removeClass(feeStudentSpinId,'slds-hide');
  60.         $A.util.removeClass(feesOpenDivId,'slds-is-open');
  61.         $A.util.addClass(feesPillListDivId,'slds-hide');
  62.     },
  63.  
  64. 	submitFeeAction : function(component, event, helper) {
  65.        	var dateOfDeposit = component.get('v.feesObj.DateOfDeposit__c');	
  66.         var paidAmount = component.get('v.feesObj.PaidAmount__c');
  67.         var action = component.get('c.postFeeData');
  68.         var feeSelectId = component.get('v.feeSelectId');
  69.         var courseFeeId = component.get('v.courseFeeId');
  70.         action.setParams({
  71.             'studentName':feeSelectId,
  72.             'courseName':courseFeeId,
  73.             'dateOfDeposit':dateOfDeposit,
  74.             'paidAmount':paidAmount
  75.          });
  76.  
  77.         action.setCallback(this, function(response){
  78.            var state =  response.getState();
  79.             alert(state);
  80.             if(state == "SUCCESS"){
  81.                 var result = response.getReturnValue();
  82.                 //alert('date saved successfully');
  83.  
  84.                 var feeStudentSpinId = component.find('feeStudentSpinId');
  85.                 var feesOpenDivId = component.find('feesOpenDivId');
  86.                 var feesPillListDivId = component.find('feesPillListDivId');
  87.  
  88.                 component.set('v.feeSelectId','');
  89.                 component.set('v.feesObj.StudentName__c','');
  90.                 component.set('v.feesObj.DateOfDeposit__c','');
  91.                 component.set('v.feesObj.PaidAmount__c','');
  92.  
  93.                 $A.util.removeClass(feeStudentSpinId,'slds-hide');
  94.                 $A.util.removeClass(feesOpenDivId,'slds-is-open');
  95.                 $A.util.addClass(feesPillListDivId,'slds-hide');
  96.  
  97.                 var toastEvent = $A.get("e.force:showToast");
  98.                 toastEvent.setParams({
  99.                     'title':'Success',
  100.                     'type':'Success',
  101.                     'message':'The record has been updated successfully'
  102.                 });
  103.                 toastEvent.fire();
  104.  
  105.             }
  106.         });
  107.         $A.enqueueAction(action);
  108. 	},
  109.  
  110.  
  111.     courseLookupSearch:function(component, event, helper){
  112.        var thisObjVal =  event.getSource().get('v.value');
  113.        var courseFeeOpenDivId = component.find('courseFeeOpenDivId');
  114.        var courseFeeStudentSpinId = component.find('courseFeeStudentSpinId');
  115.  
  116.        $A.util.addClass(courseFeeStudentSpinId, 'spinner');
  117.  
  118.  
  119.         if(!$A.util.isUndefinedOrNull(thisObjVal) && thisObjVal.length>2){
  120.             var action = component.get('c.getCourseFee');            
  121.             action.setParams({'searchFeeCourse':thisObjVal});
  122.             action.setCallback(this, function(response){ 
  123.                 //alert(JSON.stringify(action));
  124.                 var state = response.getState();                 
  125.                 if(state == 'SUCCESS'){
  126.                     var result = response.getReturnValue();
  127.                     $A.util.removeClass(courseFeeStudentSpinId, 'spinner');
  128.                     //ert('RESULT ' + JSON.stringify(result));
  129.                     $A.util.addClass(courseFeeOpenDivId,'slds-is-open');
  130.                     component.set('v.courseFeeNameItems',result);
  131.                    // alert('data saved successfully');
  132.                 }
  133.             });
  134.             $A.enqueueAction(action);
  135.         }else{
  136.             component.set('v.courseFeeNameItems', null);
  137.             $A.util.removeClass(courseFeeOpenDivId,'slds-is-open');
  138.         }
  139.  
  140.     },
  141.  
  142.     courseFeeVarSelectSearchItem:function(component, event, helper){
  143.         var thisObjId = event.target.id;
  144.         var thisObjName = event.target.innerHTML;
  145.         var courseFeeStudentSpinId = component.find('courseFeeStudentSpinId');
  146.         var courseFeeOpenDivId = component.find('courseFeeOpenDivId');
  147.         var courseFeePillListDivId = component.find('courseFeePillListDivId');
  148.  
  149.         component.set('v.courseFeeId',thisObjId);
  150.         component.set('v.courseFeeSelectedSerchName',thisObjName);
  151.         $A.util.addClass(courseFeeStudentSpinId,'slds-hide');
  152.         $A.util.removeClass(courseFeeOpenDivId,'slds-is-open');
  153.         $A.util.removeClass(courseFeePillListDivId,'slds-hide');
  154.     },
  155.  
  156.     courseFeeRemoveSelectedItem:function(component, event, helper){
  157.         var courseFeeStudentSpinId = component.find('courseFeeStudentSpinId');
  158.         var courseFeeOpenDivId = component.find('courseFeeOpenDivId');
  159.         var courseFeePillListDivId = component.find('courseFeePillListDivId');
  160.  
  161.         $A.util.removeClass(courseFeeStudentSpinId,'slds-hide');
  162.         $A.util.removeClass(courseFeeOpenDivId,'slds-is-open');
  163.         $A.util.addClass(courseFeePillListDivId,'slds-hide');
  164.  
  165.         component.set('v.courseFeeId','');
  166.         component.set('v.courseFeeSelectedSerchName','');
  167.         component.set('v.feesObj.CourseName__c','');        
  168.     },
  169.  
  170. })

Create Component Style CSS

Step 3:- Create Lightning Component : feesCmp.css

From Developer Console >> File >> New >> Lightning Component >> Component Style CSS

feesCmp.css [Component Style CSS]

  1.   .THIS {
  2. }
  3. .THIS .spinnerItem .spinnerIcon{display:none;}
  4. .THIS .spinnerItem.spinner .spinnerIcon{position:absolute; position: absolute; right: 5px; top: 6px; width: 20px; height:20px;  display:block; }
  5. .THIS .spinnerItem.spinner .slds-input__icon{display:none;}
  6.  
  7. .THIS .spinnerItem.slds-hide + .slds-dropdown-trigger{display:none;}

Create Apex Class Controller

Step 4:- Create Apex Class : newStudentCtr.apxc

From Developer Console >> File >> New >> Apex Class

newStudentCtr.apxc [Apex Class Controller]

  1.    public class newStudentCtr {
  2.  
  3. @AuraEnabled
  4.     public static void postFeeData(string studentName, string courseName, DATE dateOfDeposit, INTEGER paidAmount){  
  5.       Fees__c getFeeList = NEW Fees__c();
  6.        getFeeList.StudentName__c=studentName;
  7.        getFeeList.CourseName__c=courseName;
  8.        getFeeList.DateOfDeposit__c=dateOfDeposit;
  9.        getFeeList.PaidAmount__c= paidAmount;   
  10.       INSERT  getFeeList;
  11.     }
  12.  
  13.  
  14. @AuraEnabled
  15.     public static List<NewStudent__c> getFeeStudent(string searchFeeKey){  
  16.       searchFeeKey = '%' + searchFeeKey + '%';
  17.         List<NewStudent__c> getFeeList = [SELECT Id, Name FROM NewStudent__c WHERE Name LIKE:searchFeeKey];
  18.         RETURN getFeeList;
  19.     }   
  20.  
  21.  
  22. @AuraEnabled
  23.     public static List<Course__c> getCourseFee(string searchFeeCourse){ 
  24.         searchFeeCourse = '%' + searchFeeCourse + '%';
  25.         List<Course__c> getCourseList = [SELECT id, Name FROM Course__c WHERE Name LIKE:searchFeeCourse];
  26.         RETURN getCourseList;
  27.     } 
  28.  
  29. }

insert record id of lookup field with apex controller in salesforce -- w3web.net

Further post that would you like to learn in Salesforce

 


 

FAQ (Frequently Asked Questions)

Can we create record type on custom object?

From the object management settings for a custom object, go to Record Types. Click New in the Record Types related list. Select Master from the Existing Record Type dropdown list to copy all available picklist values, or choose an existing record type to clone its picklist values.

What is a custom record in Salesforce?

A custom object record page allows your user to access custom object related data.

What is custom record type?

Custom Record Type permission: This permission is assigned to users through role assignments or global permissions. This permission grants a user up to all four access levels (view, create, edit, or full) and controls the user's access level to all custom record types.

 
  

Our Free Courses β†’

πŸ‘‰ Get Free Course β†’

πŸ“Œ Salesforce Administrators

πŸ“Œ Salesforce Lightning Flow Builder

πŸ“Œ Salesforce Record Trigger Flow Builder

πŸ‘‰ Get Free Course β†’

πŸ“Œ Aura Lightning Framework

πŸ“Œ Lightning Web Component (LWC)

πŸ“Œ Rest APIs Integration



Hi, This is Vijay Kumar behind the admin and founder of w3web.net. I am a senior software developer and working in MNC company from more than 8 years. I am great fan of technology, configuration, customization & development. Apart of this, I love to write about Blogging in spare time, Working on Mobile & Web application development, Salesforce lightning, Salesforce LWC and Salesforce Integration development in full time. [Read full bio] | | The Sitemap where you can find all published post on w3web.net

Leave a Comment