Notifications
Clear all
Apr 18, 2022 11:07 am
<aura:component implements="flexipage:availableForRecordHome,force:hasRecordId"
access="global"
controller="RequirementsUX">
<aura:attribute name="LeadRecord" type="object"/>
<!-- aura attributes to store data/values -->
<aura:attribute name="ListCivilWork" type="List"/>
<aura:attribute name="ListSiteServiceNeededfor" type="List"/>
<aura:attribute name="CivilWork" type="String"/>
<aura:attribute name="SiteServiceNeededfor" type="String"/>
<div> Site Services / Civil Work </div>
<lightning:layout multipleRows="true">
<lightning:layoutItem size="12" mediumDeviceSize="12" padding="around-small">
<aura:iteration items="{!v.ListCivilWork}" var="CiWrk">
<lightning:button variant="{!if(CiWrk.isSelected == true,'brand','brand-outline')}" label="{!CiWrk.value}" name="{!CiWrk.value}" title="Neutral action" onclick="{!c.cwButton }" disabled="{!v.disablepicklistvalues}"/>
</aura:iteration>
</lightning:layoutItem>
</lightning:layout>
<aura:if isTrue="{!v.ListCivilWork == 'true'}">
<div> Site Service Needed for? </div>
<lightning:layout multipleRows="true">
<lightning:layoutItem size="12" mediumDeviceSize="12" padding="around-small">
<aura:iteration items="{!v.ListSiteServiceNeededfor}" var="SSNF">
<lightning:button variant="{!if(SSNF.isSelected == true,'brand','brand-outline')}" label="{!SSNF.value}" name="{!SSNF.value}" title="Neutral action" onclick="{!c.ListSSNFButtons}" disabled="{!v.disablepicklistvalues}"/>
</aura:iteration>
</lightning:layoutItem>
</lightning:layout>
</aura:if>
CivilWork is a check box, but its displayed in the component as buttons. Button names are true and false.
When true is clicked, Site Service Needed for section below should show and when false is clicked that section should hide.
1 Reply
Apr 18, 2022 11:14 am
Figured it out. You can't use
<aura:if isTrue="{! !empty(v.ListCivilWork)}">
As you can only check if the list is empty or not empty. You cannot check for a string in a list like for true or false. See the complete working code below:
<aura:component implements="flexipage:availableForRecordHome,force:hasRecordId" access="global" controller="RequirementsUX"> <aura:attribute name="LeadRecord" type="object"/> <!-- aura attributes to store data/values --> <aura:attribute name="ListHomeType" type="List"/> <aura:attribute name="ListScopeOfWork" type="List"/> <aura:attribute name="ListInteriorworkneededfor" type="List"/> <aura:attribute name="ListEat" type="List"/> <aura:attribute name="ListPropertyUsage" type="List"/> <aura:attribute name="ListRequirementDetails" type="List"/> <aura:attribute name="ListCivilWork" type="Boolean"/> <aura:attribute name="ListSiteServiceNeededfor" type="List"/> <aura:attribute name="ListFloorArea" type="String"/> <aura:attribute name="ListOthersforLive" type="String"/> <aura:attribute name="ListOthersforPlay" type="String"/> <aura:attribute name="ListHowmanykidsdoyouhave" type="String"/> <aura:attribute name="ListAgeofFirstkid" type="String"/> <aura:attribute name="ListGenderofFirstkid" type="String"/> <aura:attribute name="ListAgeofSecondkid" type="String"/> <aura:attribute name="ListGenderofSecondkid" type="String"/> <aura:attribute name="ListAgeofThirdkid" type="String"/> <aura:attribute name="ListGenderofThirdkid" type="String"/> <aura:attribute name="ListAgeofFourthkid" type="String"/> <aura:attribute name="ListGenderofFourthkid" type="String"/> <aura:attribute name="ListDoyouhavepets" type="String"/> <aura:attribute name="ListWhowillbestayinginthehouse" type="List"/> <aura:attribute name="ListLive" type="List"/> <aura:attribute name="ListPlay" type="List"/> <aura:attribute name="ListWhereareyoucurrentlylocated" type="String"/> <aura:attribute name="ListWhichlanguageareyoumostcomfortable" type="String"/> <aura:attribute name="ListIfotherlanguagespleasespecify" type="String"/> <aura:attribute name="ListWhenwouldyouliketohavethehomeMap" type="Map"/> <aura:attribute name="ListWorkMap" type="Map"/> <aura:attribute name="disablepicklistvalues" type="Boolean" default ="true"/> <aura:attribute name="HomeType" type="String"/> <aura:attribute name="ScopeOfWork" type="String"/> <aura:attribute name="Interiorworkneededfor" type="String"/> <aura:attribute name="Eat" type="String"/> <aura:attribute name="PropertyUsage" type="String"/> <aura:attribute name="RequirementDetails" type="String"/> <aura:attribute name="CivilWork" type="Boolean"/> <aura:attribute name="SiteServiceNeededfor" type="String"/> <aura:attribute name="FloorArea" type="String"/> <aura:attribute name="OthersforLive" type="String"/> <aura:attribute name="OthersforPlay" type="String"/> <aura:attribute name="Howmanykidsdoyouhave" type="String"/> <aura:attribute name="AgeofFirstkid" type="String"/> <aura:attribute name="GenderofFirstkid" type="String"/> <aura:attribute name="AgeofSecondkid" type="String"/> <aura:attribute name="GenderofSecondkid" type="String"/> <aura:attribute name="AgeofThirdkid" type="String"/> <aura:attribute name="GenderofThirdkid" type="String"/> <aura:attribute name="AgeofFourthkid" type="String"/> <aura:attribute name="GenderofFourthkid" type="String"/> <aura:attribute name="Doyouhavepets" type="String"/> <aura:attribute name="Whowillbestayinginthehouse" type="String"/> <aura:attribute name="Live" type="String"/> <aura:attribute name="Play" type="String"/> <aura:attribute name="Whereareyoucurrentlylocated" type="String"/> <aura:attribute name="Whichlanguageareyoumostcomfortable" type="String"/> <aura:attribute name="Ifotherlanguagespleasespecify" type="String"/> <aura:attribute name="MoveIn" type="Date"/> <aura:attribute name="PropertyPossessionDate" type="Date"/> <aura:attribute name="WhenwouldyouliketohavethehomeMap" type="Map"/> <aura:attribute name="WorkMap" type="Map"/> <aura:attribute name="ld" type="Lead" default="{'sobjectType':'Lead', 'Home_Type__c': '', 'Scope_Of_Work__c': '', 'Interior_work_needed_for__c': '', 'Eat' : '', 'Property_Usage__c': '', 'Requirement_Details__c': '', 'Civil_Work__c': '', 'Work__c': '', 'Live__c': '', 'Play__c': '', 'Area__c': '', 'Others_for_Live__c': '', 'Others_for_Play__c': '', 'How_many_kids_do_you_have__c': '', 'Age_of_First_kid__c': '', 'Gender_of_First_kid__c': '', 'Age_of_Second_kid__c': '', 'Gender_of_Second_kid__c': '', 'Age_of_Third_kid__c': '', 'Gender_of_Third_kid__c': '', 'Age_of_Fourth_kid__c': '', 'Gender_of_Fourth_kid__c': '', 'Do_you_have_pets__c': '', 'Who_will_be_staying_in_the_house__c' : '', 'Where_are_you_currently_located__c' : '', 'Which_language_are_you_most_comfortable__c' : '', 'If_other_languages_please_specify__c' : '', 'Move_in__c': '', 'Site_Service_Needed_for__c': '', 'When_would_you_like_to_have_the_home__c': '', 'Property_Possession_Date__c': ''}"/> <!--Declare Handler--> <aura:handler name="init" value="{!this}" action="{!c.doInit}"/> <div class="slds-align_absolute-center" style="height:5rem"> <lightning:button label="Edit" title="Edit" onclick="{! c.handleEdit }"/> </div> <div> Property Type </div> <lightning:layout multipleRows="true"> <lightning:layoutItem size="12" mediumDeviceSize="12" padding="around-small"> <aura:iteration items="{!v.ListHomeType}" var="HoTy"> <lightning:button variant="{!if(HoTy.isSelected == true,'brand','brand-outline')}" label="{!HoTy.value}" name="{!HoTy.value}" title="Neutral action" onclick="{! c.homeTypeButtons }" disabled="{!v.disablepicklistvalues}"/> </aura:iteration> </lightning:layoutItem> </lightning:layout> <div> Floor Area(sqft) </div> <lightning:layoutItem size="3" padding="around-small"> <div class="form-group"> <lightning:input name="accName" onChange="{!c.onChangeFA}" type="text" maxlength="50" value="{!v.FloorArea}" disabled="{!v.disablepicklistvalues}"/> </div> </lightning:layoutItem> <br/> <div> Scope Of Work </div> <lightning:layout multipleRows="true"> <lightning:layoutItem size="12" mediumDeviceSize="12" padding="around-small"> <aura:iteration items="{!v.ListScopeOfWork}" var="ScofWrk"> <lightning:button variant="{!if(ScofWrk.isSelected == true,'brand','brand-outline')}" label="{!ScofWrk.value}" name="{!ScofWrk.value}" title="Neutral action" onclick="{! c.ListScopeOfWorkButtons }" disabled="{!v.disablepicklistvalues}"/> </aura:iteration> </lightning:layoutItem> </lightning:layout> <div> Site Services / Civil Work </div> <lightning:layout multipleRows="true"> <lightning:layoutItem size="12" mediumDeviceSize="12" padding="around-small"> <!-- <aura:iteration items="{!v.ListCivilWork}" var="CiWrk"> <lightning:button variant="{!if(CiWrk.isSelected == true,'brand','brand-outline')}" label="{!CiWrk.value}" name="{!CiWrk.value}" title="Neutral action" onclick="{!c.cwButton }" disabled="{!v.disablepicklistvalues}"/> </aura:iteration> --> <lightning:input type="toggle" name="toggleButton" aura:id="tglbtn" label="Yes/No" messageToggleActive="Yes" messageToggleInactive="No" checked="{!v.CivilWork}" onchange="{!c.getToggleButtonValue}" disabled="{!v.disablepicklistvalues}" /> </lightning:layoutItem> </lightning:layout> <aura:if isTrue="{! v.CivilWork == true}"> <div> Site Service Needed </div> <lightning:layout multipleRows="true"> <lightning:layoutItem size="12" mediumDeviceSize="12" padding="around-small"> <aura:iteration items="{!v.ListSiteServiceNeededfor}" var="SSNF"> <lightning:button variant="{!if(SSNF.isSelected == true,'brand','brand-outline')}" label="{!SSNF.value}" name="{!SSNF.value}" title="Neutral action" onclick="{!c.ListSSNFButtons}" disabled="{!v.disablepicklistvalues}"/> </aura:iteration> </lightning:layoutItem> </lightning:layout> </aura:if> <div> Interior work needed for </div> <lightning:layout multipleRows="true"> <lightning:layoutItem size="12" mediumDeviceSize="12" padding="around-small"> <aura:iteration items="{!v.ListInteriorworkneededfor}" var="IntWrknedfor"> <lightning:button variant="{!if(IntWrknedfor.isSelected == true,'brand','brand-outline')}" label="{!IntWrknedfor.value}" name="{!IntWrknedfor.value}" title="Neutral action" onclick="{! c.ListInteriorworkneededforButtons}" disabled="{!v.disablepicklistvalues}"/> </aura:iteration> </lightning:layoutItem> </lightning:layout> <div> Property Usage </div> <lightning:layout multipleRows="true"> <lightning:layoutItem size="12" mediumDeviceSize="12" padding="around-small"> <aura:iteration items="{!v.ListPropertyUsage}" var="PropUs"> <lightning:button variant="{!if(PropUs.isSelected == true,'brand','brand-outline')}" label="{!PropUs.value}" name="{!PropUs.value}" title="Neutral action" onclick="{! c.ListPropertyUsageButtons }" disabled="{!v.disablepicklistvalues}"/> </aura:iteration> </lightning:layoutItem> </lightning:layout> <lightning:layoutItem size="3" padding="around-small"> <div class="slds-grid slds-gutters"> <div class="slds-col"> <lightning:input name="accName" onChange="{!c.onChangeMI}" type="date" label="Move-In" maxlength="50" value="{!v.MoveIn}" disabled="{!v.disablepicklistvalues}"/> </div> <div class="slds-col"> <lightning:input name="accName" onChange="{!c.onChangePPD}" type="date" label="Property Possession Date" maxlength="50" value="{!v.PropertyPossessionDate}" disabled="{!v.disablepicklistvalues}"/> </div> </div> </lightning:layoutItem> <div> Requirement Details </div> <lightning:layout multipleRows="true"> <lightning:layoutItem size="12" mediumDeviceSize="12" padding="around-small"> <aura:iteration items="{!v.ListRequirementDetails}" var="ReqDetail"> <lightning:button variant="{!if(ReqDetail.isSelected == true,'brand','brand-outline')}" label="{!ReqDetail.value}" name="{!ReqDetail.value}" title="Neutral action" onclick="{! c.ListRequirementDetailsButtons }" disabled="{!v.disablepicklistvalues}"/> </aura:iteration> </lightning:layoutItem> </lightning:layout> <div> Eat </div> <lightning:layout multipleRows="true"> <lightning:layoutItem size="12" mediumDeviceSize="12" padding="around-small"> <aura:iteration items="{!v.ListEat}" var="Eat"> <lightning:button variant="{!if(Eat.isSelected == true,'brand','brand-outline')}" label="{!Eat.value}" name="{!Eat.value}" title="Neutral action" onclick="{! c.ListEatButtons}" disabled="{!v.disablepicklistvalues}"/> </aura:iteration> </lightning:layoutItem> </lightning:layout> <div class="form-group"> <lightning:select aura:id="WorkPicklist" value="{!v.ld.Work}" onchange="{!c.OnChangeWork}" name="WorkPicklist" label="Work" disabled="{!v.disablepicklistvalues}"> <option value="">--None--</option> <aura:iteration items="{!v.WorkMap}" var="i" indexVar="key"> <option text="{!i.value}" value="{!i.key}" selected="{!i.key==v.ld.Work}" /> </aura:iteration> </lightning:select> </div> <div> Live </div> <lightning:layout multipleRows="true"> <lightning:layoutItem size="12" mediumDeviceSize="12" padding="around-small"> <aura:iteration items="{!v.ListLive}" var="Live"> <lightning:button variant="{!if(Live.isSelected == true,'brand','brand-outline')}" label="{!Live.value}" name="{!Live.value}" title="Neutral action" onclick="{! c.ListLiveButtons}" disabled="{!v.disablepicklistvalues}"/> </aura:iteration> </lightning:layoutItem> </lightning:layout> <div> Others for Live </div> <lightning:layoutItem size="3" padding="around-small"> <div class="form-group"> <lightning:input name="accName" onChange="{!c.onChangeOFL}" type="text" maxlength="50" value="{!v.OthersforLive}" disabled="{!v.disablepicklistvalues}"/> </div> </lightning:layoutItem> <br/> <div> Play </div> <lightning:layout multipleRows="true"> <lightning:layoutItem size="12" mediumDeviceSize="12" padding="around-small"> <aura:iteration items="{!v.ListPlay}" var="Play"> <lightning:button variant="{!if(Play.isSelected == true,'brand','brand-outline')}" label="{!Play.value}" name="{!Play.value}" title="Neutral action" onclick="{! c.ListPlayButtons}" disabled="{!v.disablepicklistvalues}"/> </aura:iteration> </lightning:layoutItem> </lightning:layout> <div> Others for Play </div> <lightning:layoutItem size="3" padding="around-small"> <div class="form-group"> <lightning:input name="accName" onChange="{!c.onChangeOFP}" type="text" maxlength="50" value="{!v.OthersforPlay}" disabled="{!v.disablepicklistvalues}"/> </div> </lightning:layoutItem> <br/> <div> How many kids do you have? </div> <lightning:layoutItem size="3" padding="around-small"> <div class="form-group"> <lightning:input name="accName" onChange="{!c.onChangeHMKDYH}" type="text" maxlength="50" value="{!v.Howmanykidsdoyouhave}" disabled="{!v.disablepicklistvalues}"/> </div> </lightning:layoutItem> <br/> <div> Age of First kid </div> <lightning:layoutItem size="3" padding="around-small"> <div class="form-group"> <lightning:input name="accName" onChange="{!c.onChangeAOFK}" type="text" maxlength="50" value="{!v.AgeofFirstkid}" disabled="{!v.disablepicklistvalues}"/> </div> </lightning:layoutItem> <br/> <div> Gender of First kid </div> <lightning:layoutItem size="3" padding="around-small"> <div class="form-group"> <lightning:input name="accName" onChange="{!c.onChangeGOFK}" type="text" maxlength="50" value="{!v.GenderofFirstkid}" disabled="{!v.disablepicklistvalues}"/> </div> </lightning:layoutItem> <br/> <div> Age of Second kid </div> <lightning:layoutItem size="3" padding="around-small"> <div class="form-group"> <lightning:input name="accName" onChange="{!c.onChangeAOSK}" type="text" maxlength="50" value="{!v.AgeofSecondkid}" disabled="{!v.disablepicklistvalues}"/> </div> </lightning:layoutItem> <br/> <div> Gender of Second kid </div> <lightning:layoutItem size="3" padding="around-small"> <div class="form-group"> <lightning:input name="accName" onChange="{!c.onChangeGOSK}" type="text" maxlength="50" value="{!v.GenderofSecondkid}" disabled="{!v.disablepicklistvalues}"/> </div> </lightning:layoutItem> <br/> <div> Age of Third kid </div> <lightning:layoutItem size="3" padding="around-small"> <div class="form-group"> <lightning:input name="accName" onChange="{!c.onChangeAOTK}" type="text" maxlength="50" value="{!v.AgeofThirdkid}" disabled="{!v.disablepicklistvalues}"/> </div> </lightning:layoutItem> <br/> <div> Gender of Third kid </div> <lightning:layoutItem size="3" padding="around-small"> <div class="form-group"> <lightning:input name="accName" onChange="{!c.onChangeGOTK}" type="text" maxlength="50" value="{!v.GenderofThirdkid}" disabled="{!v.disablepicklistvalues}"/> </div> </lightning:layoutItem> <br/> <div> Age of Fourth kid </div> <lightning:layoutItem size="3" padding="around-small"> <div class="form-group"> <lightning:input name="accName" onChange="{!c.onChangeAOFK}" type="text" maxlength="50" value="{!v.AgeofFourthkid}" disabled="{!v.disablepicklistvalues}"/> </div> </lightning:layoutItem> <br/> <div> Gender of Fourth kid </div> <lightning:layoutItem size="3" padding="around-small"> <div class="form-group"> <lightning:input name="accName" onChange="{!c.onChangeGOFK}" type="text" maxlength="50" value="{!v.GenderofFourthkid}" disabled="{!v.disablepicklistvalues}"/> </div> </lightning:layoutItem> <br/> <div> Do you have pets? </div> <lightning:layoutItem size="3" padding="around-small"> <div class="form-group"> <lightning:input name="accName" onChange="{!c.onChangeDYHP}" type="text" maxlength="50" value="{!v.Doyouhavepets}" disabled="{!v.disablepicklistvalues}"/> </div> </lightning:layoutItem> <br/> <div> Who will be staying in the house? </div> <lightning:layout multipleRows="true"> <lightning:layoutItem size="12" mediumDeviceSize="12" padding="around-small"> <aura:iteration items="{!v.ListWhowillbestayinginthehouse}" var="Wwbsith"> <lightning:button variant="{!if(Wwbsith.isSelected == true,'brand','brand-outline')}" label="{!Wwbsith.value}" name="{!Wwbsith.value}" title="Neutral action" onclick="{! c.ListWhowillbestayinginthehouseButtons}" disabled="{!v.disablepicklistvalues}"/> </aura:iteration> </lightning:layoutItem> </lightning:layout> <div class="form-group"> <lightning:select aura:id="WhenwouldyouliketohavethehomePicklist" value="{!v.ld.Whenwouldyouliketohavethehome}" onchange="{!c.OnChangeWWYLTHH}" name="WhenwouldyouliketohavethehomePicklist" label="When would you like to have the home" disabled="{!v.disablepicklistvalues}"> <option value="">--None--</option> <aura:iteration items="{!v.WhenwouldyouliketohavethehomeMap}" var="i" indexVar="key"> <option text="{!i.value}" value="{!i.key}" selected="{!i.key==v.ld.Whenwouldyouliketohavethehome}" /> </aura:iteration> </lightning:select> </div> <div> Where are you currently located? </div> <lightning:layoutItem size="3" padding="around-small"> <div class="form-group"> <lightning:input name="accName" onChange="{!c.onChangeWAYCL}" type="text" maxlength="50" value="{!v.Whereareyoucurrentlylocated}" disabled="{!v.disablepicklistvalues}"/> </div> </lightning:layoutItem> <div> Which language are you most comfortable </div> <lightning:layoutItem size="3" padding="around-small"> <div class="form-group"> <lightning:input name="accName" onChange="{!c.onChangeWLAYMC}" type="text" maxlength="50" value="{!v.Whichlanguageareyoumostcomfortable}" disabled="{!v.disablepicklistvalues}"/> </div> </lightning:layoutItem> <div> If other languages please specify </div> <lightning:layoutItem size="3" padding="around-small"> <div class="form-group"> <lightning:input name="accName" onChange="{!c.onChangeIOLPS}" type="text" maxlength="50" value="{!v.Ifotherlanguagespleasespecify}" disabled="{!v.disablepicklistvalues}"/> </div> </lightning:layoutItem> <div class="slds-align_absolute-center" style="height:5rem"> <lightning:button variant="brand" label="Submit" title="Brand action" onclick="{!c.UpdateLead}" disabled="{!v.disablepicklistvalues}" /> </div> </aura:component>
({ //Load Lead Picklist values doInit: function(component, event, helper) { component.set("v.disablepicklistvalues",true); helper.getLeadPicklist(component, event); //helper.getPicklistValues(component, event); }, homeTypeButtons : function(cmp, event, helper) { var whichOne = event.getSource().get("v.name"); var HomeTypevalues = cmp.get('v.ListHomeType'); for (var i = 0; i < HomeTypevalues.length; i++) { if(HomeTypevalues[i].value == whichOne){ HomeTypevalues[i].isSelected = HomeTypevalues[i].isSelected ? false: true; } } cmp.set("v.ListHomeType", HomeTypevalues); }, ListScopeOfWorkButtons : function(cmp, event, helper) { var whichOne = event.getSource().get("v.name"); var HomeTypevalues = cmp.get('v.ListScopeOfWork'); for (var i = 0; i < HomeTypevalues.length; i++) { if(HomeTypevalues[i].value == whichOne){ HomeTypevalues[i].isSelected = HomeTypevalues[i].isSelected ? false: true; } } cmp.set("v.ListScopeOfWork", HomeTypevalues); }, ListInteriorworkneededforButtons : function(cmp, event, helper) { var whichOne = event.getSource().get("v.name"); var HomeTypevalues = cmp.get('v.ListInteriorworkneededfor'); for (var i = 0; i < HomeTypevalues.length; i++) { if(HomeTypevalues[i].value == whichOne){ HomeTypevalues[i].isSelected = HomeTypevalues[i].isSelected ? false: true; } } cmp.set("v.ListInteriorworkneededfor", HomeTypevalues); }, ListEatButtons : function(cmp, event, helper) { var whichOne = event.getSource().get("v.name"); var HomeTypevalues = cmp.get('v.ListEat'); for (var i = 0; i < HomeTypevalues.length; i++) { if(HomeTypevalues[i].value == whichOne){ HomeTypevalues[i].isSelected = HomeTypevalues[i].isSelected ? false: true; } } cmp.set("v.ListEat", HomeTypevalues); }, ListWhowillbestayinginthehouseButtons : function(cmp, event, helper) { var whichOne = event.getSource().get("v.name"); var HomeTypevalues = cmp.get('v.ListWhowillbestayinginthehouse'); for (var i = 0; i < HomeTypevalues.length; i++) { if(HomeTypevalues[i].value == whichOne){ HomeTypevalues[i].isSelected = HomeTypevalues[i].isSelected ? false: true; } } cmp.set("v.ListWhowillbestayinginthehouse", HomeTypevalues); }, ListLiveButtons : function(cmp, event, helper) { var whichOne = event.getSource().get("v.name"); var HomeTypevalues = cmp.get('v.ListLive'); for (var i = 0; i < HomeTypevalues.length; i++) { if(HomeTypevalues[i].value == whichOne){ HomeTypevalues[i].isSelected = HomeTypevalues[i].isSelected ? false: true; } } cmp.set("v.ListLive", HomeTypevalues); }, ListPlayButtons : function(cmp, event, helper) { var whichOne = event.getSource().get("v.name"); var HomeTypevalues = cmp.get('v.ListPlay'); for (var i = 0; i < HomeTypevalues.length; i++) { if(HomeTypevalues[i].value == whichOne){ HomeTypevalues[i].isSelected = HomeTypevalues[i].isSelected ? false: true; } } cmp.set("v.ListPlay", HomeTypevalues); }, ListPropertyUsageButtons : function(cmp, event, helper) { var whichOne = event.getSource().get("v.name"); var HomeTypevalues = cmp.get('v.ListPropertyUsage'); for (var i = 0; i < HomeTypevalues.length; i++) { if(HomeTypevalues[i].value == whichOne){ HomeTypevalues[i].isSelected = HomeTypevalues[i].isSelected ? false: true; } } cmp.set("v.ListPropertyUsage", HomeTypevalues); }, ListRequirementDetailsButtons : function(cmp, event, helper) { var whichOne = event.getSource().get("v.name"); var HomeTypevalues = cmp.get('v.ListRequirementDetails'); for (var i = 0; i < HomeTypevalues.length; i++) { if(HomeTypevalues[i].value == whichOne){ HomeTypevalues[i].isSelected = HomeTypevalues[i].isSelected ? false: true; } } cmp.set("v.ListRequirementDetails", HomeTypevalues); }, onChangeFA : function(cmp, event, helper) { var FA = event.getSource().get("v.value"); cmp.set('v.FloorArea', FA); }, onChangeOFL : function(cmp, event, helper) { var OFL = event.getSource().get("v.value"); cmp.set('v.OthersforLive', OFL); }, onChangeOFP : function(cmp, event, helper) { var OFP = event.getSource().get("v.value"); cmp.set('v.OthersforPlay', OFP); }, onChangeWAYCL : function(cmp, event, helper) { var WAYCL = event.getSource().get("v.value"); cmp.set('v.Whereareyoucurrentlylocated', WAYCL); }, onChangeWLAYMC : function(cmp, event, helper) { var WLAYMC = event.getSource().get("v.value"); cmp.set('v.Whichlanguageareyoumostcomfortable', WLAYMC); }, onChangeIOLPS : function(cmp, event, helper) { var IOLPS = event.getSource().get("v.value"); cmp.set('v.Ifotherlanguagespleasespecify', IOLPS); }, onChangeHMKDYH : function(cmp, event, helper) { var HMKDYH = event.getSource().get("v.value"); cmp.set('v.Howmanykidsdoyouhave', HMKDYH); }, onChangeAOFK : function(cmp, event, helper) { var AOFK = event.getSource().get("v.value"); cmp.set('v.AgeofFirstkid', AOFK); }, onChangeGOFK : function(cmp, event, helper) { var GOFK = event.getSource().get("v.value"); cmp.set('v.GenderofFirstkid', GOFK); }, onChangeAOSK : function(cmp, event, helper) { var AOSK = event.getSource().get("v.value"); cmp.set('v.AgeofSecondkid', AOSK); }, onChangeGOSK : function(cmp, event, helper) { var GOSK = event.getSource().get("v.value"); cmp.set('v.GenderofSecondkid', GOSK); }, onChangeAOTK : function(cmp, event, helper) { var GOSK = event.getSource().get("v.value"); cmp.set('v.AgeofThirdkid', AOTK); }, onChangeGOTK : function(cmp, event, helper) { var GOTK = event.getSource().get("v.value"); cmp.set('v.GenderofThirdkid', GOTK); }, onChangeAOFK : function(cmp, event, helper) { var AOFK = event.getSource().get("v.value"); cmp.set('v.AgeofFourthkid', AOFK); }, onChangeGOFK : function(cmp, event, helper) { var GOFK = event.getSource().get("v.value"); cmp.set('v.GenderofFourthkid', GOFK); }, onChangeDYHP : function(cmp, event, helper) { var DYHP = event.getSource().get("v.value"); cmp.set('v.Doyouhavepets', DYHP); }, OnChangeWWYLTHH : function(cmp, event, helper) { // var Whenwouldyouliketohavethehome = event.getSource().get("v.value"); var Whenwouldyouliketohavethehome = cmp.get("v.ld.Whenwouldyouliketohavethehome"); // alert(Whenwouldyouliketohavethehome); cmp.set('v.ld.Whenwouldyouliketohavethehome', Whenwouldyouliketohavethehome); }, OnChangeWork : function(cmp, event, helper) { var Work = cmp.get("v.ld.Work"); // alert(Work); cmp.set('v.ld.Work', Work); }, onChangeMI : function(cmp, event, helper) { var MI = event.getSource().get("v.value"); cmp.set('v.MoveIn', MI); }, onChangePPD : function(cmp, event, helper) { var PPD = event.getSource().get("v.value"); cmp.set('v.PropertyPossessionDate', PPD); }, getToggleButtonValue:function(cmp, event, helper){ var checkCmp = cmp.find("tglbtn").get("v.checked"); cmp.set("v.ListCivilWork",checkCmp); }, cwButton : function(cmp, event, helper) { var whichOne = event.getSource().get("v.name"); var HomeTypevalues = cmp.get('v.ListCivilWork'); for (var i = 0; i < HomeTypevalues.length; i++) { if(HomeTypevalues[i].value == whichOne){ HomeTypevalues[i].isSelected = true; }else{ HomeTypevalues[i].isSelected = false; } } cmp.set("v.ListCivilWork", HomeTypevalues); }, ListSSNFButtons : function(cmp, event, helper) { var whichOne = event.getSource().get("v.name"); var HomeTypevalues = cmp.get('v.ListSiteServiceNeededfor'); for (var i = 0; i < HomeTypevalues.length; i++) { if(HomeTypevalues[i].value == whichOne){ HomeTypevalues[i].isSelected = HomeTypevalues[i].isSelected ? false: true; } } cmp.set("v.ListSiteServiceNeededfor", HomeTypevalues); }, //--- For Edit Option handleEdit :function(component, event, helper){ component.set("v.disablepicklistvalues",false); }, // Update All required fields using Submit Button UpdateLead : function(component, event, helper){ helper.Saveupdatedleadvalues(component, event,helper); } })
({ // Picklist data shown as buttons getLeadPicklist: function(component, event) { var action = component.get("c.picklistvalues"); action.setParams({"recordId" : component.get('v.recordId')}); action.setCallback(this, function(response) { var state = response.getState(); if (state === "SUCCESS") { var result = JSON.parse(response.getReturnValue()); var hometypeFinalValues = []; var leadRec = JSON.parse(result['LeadRecord']); component.set('v.LeadRecord',leadRec); component.set("v.HomeType",leadRec['Home_Type__c']); component.set("v.ScopeOfWork",leadRec['Scope_Of_Work__c']); component.set("v.Interiorworkneededfor",leadRec['Interior_work_needed_for__c']); component.set("v.Eat",leadRec['Eat__c']); component.set("v.SiteServiceNeededfor",leadRec['Site_Service_Needed_for__c']); component.set("v.PropertyUsage",leadRec['Property_Usage__c']); component.set("v.RequirementDetails",leadRec['Requirement_Details__c']); component.set("v.CivilWork",leadRec['Civil_Work__c']); component.set("v.ld.Work",leadRec['Work__c']); component.set("v.Live",leadRec['Live__c']); component.set("v.Play",leadRec['Play__c']); component.set("v.FloorArea",leadRec['Area__c']); component.set("v.OthersforLive",leadRec['Others_for_Live__c']); component.set("v.OthersforPlay",leadRec['Others_for_Play__c']); component.set("v.Howmanykidsdoyouhave",leadRec['How_many_kids_do_you_have__c']); component.set("v.AgeofFirstkid",leadRec['Age_of_First_kid__c']); component.set("v.GenderofFirstkid",leadRec['Gender_of_First_kid__c']); component.set("v.AgeofSecondkid",leadRec['Age_of_Second_kid__c']); component.set("v.GenderofSecondkid",leadRec['Gender_of_Second_kid__c']); component.set("v.AgeofThirdkid",leadRec['Age_of_Third_kid__c']); component.set("v.GenderofThirdkid",leadRec['Gender_of_Third_kid__c']); component.set("v.AgeofFourthkid",leadRec['Age_of_Fourth_kid__c']); component.set("v.GenderofFourthkid",leadRec['Gender_of_Fourth_kid__c']); component.set("v.Doyouhavepets",leadRec['Do_you_have_pets__c']); component.set("v.Whowillbestayinginthehouse",leadRec['Who_will_be_staying_in_the_house__c']); component.set("v.Whereareyoucurrentlylocated",leadRec['Where_are_you_currently_located__c']); component.set("v.Whichlanguageareyoumostcomfortable",leadRec['Which_language_are_you_most_comfortable__c']); component.set("v.Ifotherlanguagespleasespecify",leadRec['If_other_languages_please_specify__c']); component.set("v.MoveIn",leadRec['Move_in__c']); component.set("v.PropertyPossessionDate",leadRec['Property_Possession_Date__c']); component.set("v.ld.Whenwouldyouliketohavethehome",leadRec['When_would_you_like_to_have_the_home__c']); var HomeTypevalues = result['Home_Type__c']; var finalHometypeValues = []; for (var i = 0; i < HomeTypevalues.length; i++) { var valueObj={ 'value':HomeTypevalues[i] }; if(leadRec['Home_Type__c'] != undefined && leadRec['Home_Type__c'].includes(HomeTypevalues[i])){ valueObj.isSelected = true; }else{ valueObj.isSelected = false; } finalHometypeValues.push(valueObj); } var Propertyvalues = result['Property_Usage__c']; var finalPropertyvalues = []; for (var i = 0; i < Propertyvalues.length; i++) { var valueObj={ 'value':Propertyvalues[i] }; if(!!leadRec['Property_Usage__c'] && leadRec['Property_Usage__c'].includes(Propertyvalues[i])){ valueObj.isSelected = true; }else{ valueObj.isSelected = false; } finalPropertyvalues.push(valueObj); } var interiorValues = result['Interior_work_needed_for__c']; var finalinteriorValues = []; for (var i = 0; i < interiorValues.length; i++) { var valueObj={ 'value':interiorValues[i] }; if(!!leadRec['Interior_work_needed_for__c'] && leadRec['Interior_work_needed_for__c'].includes(interiorValues[i])){ valueObj.isSelected = true; }else{ valueObj.isSelected = false; } finalinteriorValues.push(valueObj); } var EatValues = result['Eat__c']; var finalEatValues = []; for (var i = 0; i < EatValues.length; i++) { var valueObj={ 'value':EatValues[i] }; if(!!leadRec['Eat__c'] && leadRec['Eat__c'].includes(EatValues[i])){ valueObj.isSelected = true; }else{ valueObj.isSelected = false; } finalEatValues.push(valueObj); } var SiteServiceNeededforValues = result['Site_Service_Needed_for__c']; var finalSiteServiceNeededforValues = []; for (var i = 0; i < SiteServiceNeededforValues.length; i++) { var valueObj={ 'value':SiteServiceNeededforValues[i] }; if(!!leadRec['Site_Service_Needed_for__c'] && leadRec['Site_Service_Needed_for__c'].includes(SiteServiceNeededforValues[i])){ valueObj.isSelected = true; }else{ valueObj.isSelected = false; } finalSiteServiceNeededforValues.push(valueObj); } var action = component.get("c.getWhenwouldyouliketohavethehomeValue"); action.setCallback(this, function(response) { var state = response.getState(); if (state === "SUCCESS") { var result = response.getReturnValue(); var WhenwouldyouliketohavethehomeMap = []; for(var key in result){ WhenwouldyouliketohavethehomeMap.push({key: key, value: result[key]}); } component.set("v.WhenwouldyouliketohavethehomeMap", WhenwouldyouliketohavethehomeMap); } }); $A.enqueueAction(action); var action = component.get("c.getWorkValue"); action.setCallback(this, function(response) { var state = response.getState(); if (state === "SUCCESS") { var result = response.getReturnValue(); var WorkMap = []; for(var key in result){ WorkMap.push({key: key, value: result[key]}); } component.set("v.WorkMap", WorkMap); } }); $A.enqueueAction(action); var WhowillbestayinginthehouseValues = result['Who_will_be_staying_in_the_house__c']; var finalWhowillbestayinginthehouseValues = []; for (var i = 0; i < WhowillbestayinginthehouseValues.length; i++) { var valueObj={ 'value':WhowillbestayinginthehouseValues[i] }; if(!!leadRec['Who_will_be_staying_in_the_house__c'] && leadRec['Who_will_be_staying_in_the_house__c'].includes(WhowillbestayinginthehouseValues[i])){ valueObj.isSelected = true; }else{ valueObj.isSelected = false; } finalWhowillbestayinginthehouseValues.push(valueObj); } var LiveValues = result['Live__c']; var finalLiveValues = []; for (var i = 0; i < LiveValues.length; i++) { var valueObj={ 'value':LiveValues[i] }; if(!!leadRec['Live__c'] && leadRec['Live__c'].includes(LiveValues[i])){ valueObj.isSelected = true; }else{ valueObj.isSelected = false; } finalLiveValues.push(valueObj); } var PlayValues = result['Play__c']; var finalPlayValues = []; for (var i = 0; i < PlayValues.length; i++) { var valueObj={ 'value':PlayValues[i] }; if(!!leadRec['Play__c'] && leadRec['Play__c'].includes(PlayValues[i])){ valueObj.isSelected = true; }else{ valueObj.isSelected = false; } finalPlayValues.push(valueObj); } var Scopevalues = result['Scope_Of_Work__c']; var finalScopevalues = []; for (var i = 0; i < Scopevalues.length; i++) { var valueObj={ 'value':Scopevalues[i] }; if(!!leadRec['Scope_Of_Work__c'] && leadRec['Scope_Of_Work__c'].includes(Scopevalues[i])){ valueObj.isSelected = true; }else{ valueObj.isSelected = false; } finalScopevalues.push(valueObj); } var ReqDetailsvalues = result['Requirement_Details__c']; var finalReqDetailsvalues = []; for (var i = 0; i < ReqDetailsvalues.length; i++) { var valueObj={ 'value':ReqDetailsvalues[i] }; if(!!leadRec['Requirement_Details__c'] && leadRec['Requirement_Details__c'].includes(ReqDetailsvalues[i])){ valueObj.isSelected = true; }else{ valueObj.isSelected = false; } finalReqDetailsvalues.push(valueObj); } var CWScopevalues = []; if(!!leadRec['Civil_Work__c'] && leadRec['Civil_Work__c']){ var valueObj={ 'value':'true', 'isSelected':true }; var valueObj2={ 'value':'false', 'isSelected':false }; CWScopevalues.push(valueObj); CWScopevalues.push(valueObj2); }else{ var valueObj={ 'value':'false', 'isSelected':true }; var valueObj2={ 'value':'true', 'isSelected':false }; CWScopevalues.push(valueObj); CWScopevalues.push(valueObj2); } component.set("v.ListHomeType",finalHometypeValues); component.set("v.ListScopeOfWork",finalScopevalues); component.set("v.ListInteriorworkneededfor",finalinteriorValues); component.set("v.ListEat",finalEatValues); component.set("v.ListSiteServiceNeededfor",finalSiteServiceNeededforValues); component.set("v.ListPropertyUsage",finalPropertyvalues); component.set("v.ListRequirementDetails",finalReqDetailsvalues); component.set("v.ListCivilWork",CWScopevalues); component.set("v.ListLive",finalLiveValues); component.set("v.ListPlay",finalPlayValues); component.set("v.FloorArea",leadRec['Area__c']); component.set("v.OthersforLive",leadRec['Others_for_Live__c']); component.set("v.OthersforPlay",leadRec['Others_for_Play__c']); component.set("v.Howmanykidsdoyouhave",leadRec['How_many_kids_do_you_have__c']); component.set("v.AgeofFirstkid",leadRec['Age_of_First_kid__c']); component.set("v.GenderofFirstkid",leadRec['Gender_of_First_kid__c']); component.set("v.AgeofSecondkid",leadRec['Age_of_Second_kid__c']); component.set("v.GenderofSecondkid",leadRec['Gender_of_Second_kid__c']); component.set("v.AgeofThirdkid",leadRec['Age_of_Third_kid__c']); component.set("v.GenderofThirdkid",leadRec['Gender_of_Third_kid__c']); component.set("v.AgeofFourthkid",leadRec['Age_of_Fourth_kid__c']); component.set("v.GenderofFourthkid",leadRec['Gender_of_Fourth_kid__c']); component.set("v.Doyouhavepets",leadRec['Do_you_have_pets__c']); component.set("v.ListWhowillbestayinginthehouse",finalWhowillbestayinginthehouseValues); component.set("v.MoveIn",leadRec['Move_in__c']); component.set("v.Whereareyoucurrentlylocated",leadRec['Where_are_you_currently_located__c']); component.set("v.Whichlanguageareyoumostcomfortable",leadRec['Which_language_are_you_most_comfortable__c']); component.set("v.Ifotherlanguagespleasespecify",leadRec['If_other_languages_please_specify__c']); component.set("v.PropertyPossessionDate",leadRec['Property_Possession_Date__c']); component.set("v.ld.Whenwouldyouliketohavethehome",leadRec['When_would_you_like_to_have_the_home__c']); component.set("v.ld.Work",leadRec['Work__c']); } }); $A.enqueueAction(action); }, // Submit to save the updated values in leads Saveupdatedleadvalues: function(component,event,helper){ var leadRec = component.get("v.LeadRecord"); var hometypeArray = component.get("v.ListHomeType"); var scopeOfWorkArray = component.get("v.ListScopeOfWork"); var interiorArray = component.get("v.ListInteriorworkneededfor"); var EatArray = component.get("v.ListEat"); var SiteServiceNeededforArray = component.get("v.ListSiteServiceNeededfor"); var propertyArray = component.get("v.ListPropertyUsage"); var RequirementArray = component.get("v.ListRequirementDetails"); var civilWorkArray = component.get("v.ListCivilWork"); var LiveArray = component.get("v.ListLive"); var PlayArray = component.get("v.ListPlay"); var WhowillbestayinginthehouseArray = component.get("v.ListWhowillbestayinginthehouse"); var hometype = null; var WhenwouldyouliketohavethehomeArray = component.get("v.ld.Whenwouldyouliketohavethehome"); var WorkArray = component.get("v.ld.Work"); for(var i=0;i<hometypeArray.length;i++){ if(hometypeArray[i].isSelected){ if(!!hometype){ hometype = hometype+';'+hometypeArray[i].value; }else{ hometype = hometypeArray[i].value; } } } var scopeOfWork = null; for(var i=0;i<scopeOfWorkArray.length;i++){ if(scopeOfWorkArray[i].isSelected){ if(!!scopeOfWork){ scopeOfWork = scopeOfWork+';'+scopeOfWorkArray[i].value; }else{ scopeOfWork = scopeOfWorkArray[i].value; } } } var interior = null; for(var i=0;i<interiorArray.length;i++){ if(interiorArray[i].isSelected){ if(!!interior){ interior = interior+';'+interiorArray[i].value; }else{ interior = interiorArray[i].value; } } } var Eat = null; for(var i=0;i<EatArray.length;i++){ if(EatArray[i].isSelected){ if(!!Eat){ Eat = Eat+';'+EatArray[i].value; }else{ Eat = EatArray[i].value; } } } var SiteServiceNeededfor = null; if(civilWorkArray === true){ for(var i=0;i<SiteServiceNeededforArray.length;i++){ if(SiteServiceNeededforArray[i].isSelected){ if(!!SiteServiceNeededfor){ SiteServiceNeededfor = SiteServiceNeededfor+';'+SiteServiceNeededforArray[i].value; }else{ SiteServiceNeededfor = SiteServiceNeededforArray[i].value; } } } } /*var SiteServiceNeededfor = null; for(var i=0;i<SiteServiceNeededforArray.length;i++){ if(SiteServiceNeededforArray[i].isSelected){ if(!!SiteServiceNeededfor){ SiteServiceNeededfor = SiteServiceNeededfor+';'+SiteServiceNeededforArray[i].value; }else{ SiteServiceNeededfor = SiteServiceNeededforArray[i].value; } } } */ var Whowillbestayinginthehouse = null; for(var i=0;i<WhowillbestayinginthehouseArray.length;i++){ if(WhowillbestayinginthehouseArray[i].isSelected){ if(!!Whowillbestayinginthehouse){ Whowillbestayinginthehouse = Whowillbestayinginthehouse+';'+WhowillbestayinginthehouseArray[i].value; }else{ Whowillbestayinginthehouse = WhowillbestayinginthehouseArray[i].value; } } } var Live = null; for(var i=0;i<LiveArray.length;i++){ if(LiveArray[i].isSelected){ if(!!Live){ Live = Live+';'+LiveArray[i].value; }else{ Live = LiveArray[i].value; } } } var Play = null; for(var i=0;i<PlayArray.length;i++){ if(PlayArray[i].isSelected){ if(!!Play){ Play = Play+';'+PlayArray[i].value; }else{ Play = PlayArray[i].value; } } } var property = null; for(var i=0;i<propertyArray.length;i++){ if(propertyArray[i].isSelected){ if(!!property){ property = property+';'+propertyArray[i].value; }else{ property = propertyArray[i].value; } } } var Requirement = null; for(var i=0;i<RequirementArray.length;i++){ if(RequirementArray[i].isSelected){ if(!!Requirement){ Requirement = Requirement+';'+RequirementArray[i].value; }else{ Requirement = RequirementArray[i].value; } } } /*var civilWork = false; for(var i=0;i<civilWorkArray.length;i++){ if(civilWorkArray[i].isSelected){ civilWork = civilWorkArray[i].value; } }*/ leadRec['Home_Type__c'] = hometype; leadRec['Scope_Of_Work__c'] = scopeOfWork; leadRec['Interior_work_needed_for__c'] = interior; leadRec['Eat__c'] = Eat; leadRec['Site_Service_Needed_for__c'] = SiteServiceNeededfor; leadRec['Property_Usage__c'] = property; leadRec['Requirement_Details__c'] = Requirement; //leadRec['Civil_Work__c'] =civilWork; leadRec['Civil_Work__c'] =component.get('v.ListCivilWork'); leadRec['Work__c'] =component.get('v.ld.Work'); leadRec['Live__c'] =Live; leadRec['Play__c'] =Play; leadRec['Area__c'] =component.get('v.FloorArea'); leadRec['Others_for_Live__c'] =component.get('v.OthersforLive'); leadRec['Others_for_Play__c'] =component.get('v.OthersforPlay'); leadRec['How_many_kids_do_you_have__c'] =component.get('v.Howmanykidsdoyouhave'); leadRec['Age_of_First_kid__c'] =component.get('v.AgeofFirstkid'); leadRec['Gender_of_First_kid__c'] =component.get('v.GenderofFirstkid'); leadRec['Age_of_Second_kid__c'] =component.get('v.AgeofSecondkid'); leadRec['Gender_of_Second_kid__c'] =component.get('v.GenderofSecondkid'); leadRec['Age_of_Third_kid__c'] =component.get('v.AgeofThirdkid'); leadRec['Gender_of_Third_kid__c'] =component.get('v.GenderofThirdkid'); leadRec['Age_of_Fourth_kid__c'] =component.get('v.AgeofFourthkid'); leadRec['Gender_of_Fourth_kid__c'] =component.get('v.GenderofFourthkid'); leadRec['Do_you_have_pets__c'] =component.get('v.Doyouhavepets'); leadRec['Who_will_be_staying_in_the_house__c'] = Whowillbestayinginthehouse; leadRec['Move_in__c'] =component.get('v.MoveIn'); leadRec['Property_Possession_Date__c'] =component.get('v.PropertyPossessionDate'); leadRec['Where_are_you_currently_located__c'] =component.get('v.Whereareyoucurrentlylocated'); leadRec['Which_language_are_you_most_comfortable__c'] =component.get('v.Whichlanguageareyoumostcomfortable'); leadRec['If_other_languages_please_specify__c'] =component.get('v.Ifotherlanguagespleasespecify'); leadRec['When_would_you_like_to_have_the_home__c'] =component.get('v.ld.Whenwouldyouliketohavethehome'); var action = component.get("c.Updatelead"); action.setParams({ "leadRec" : JSON.stringify(leadRec) }); action.setCallback(this, function(response) { var state = response.getState(); if (state === "SUCCESS") { var result = response.getReturnValue(); helper.showSuccess(component, event, helper); } }); $A.enqueueAction(action); }, showError : function(component, event, helper) { var toastEvent = $A.get("e.force:showToast"); toastEvent.setParams({ title : 'Error', message: 'Not Updated Successfully', duration:' 5000', key: 'info_alt', type: 'error', mode: 'pester' }); toastEvent.fire(); component.set("v.disablepicklistvalues",true); }, showSuccess : function(component, event, helper) { var toastEvent = $A.get("e.force:showToast"); toastEvent.setParams({ title : 'Success', message: 'Updated Successfully', duration:' 5000', key: 'info_alt', type: 'success', mode: 'pester' }); toastEvent.fire(); component.set("v.disablepicklistvalues",true); } })
public with sharing class RequirementsUX { //---- All field data in one method-----// @AuraEnabled Public static string picklistvalues(String recordId){ Map<String,List<String>> pickoptions = new Map<String,List<String>>(); pickoptions.put('Home_Type__c',getHomeType()); pickoptions.put('Scope_Of_Work__c',getScopeOfWork()); pickoptions.put('Interior_work_needed_for__c',getInteriorworkneededfor()); pickoptions.put('Property_Usage__c',getPropertyUsage()); pickoptions.put('Requirement_Details__c',getRequirementDetails()); //pickoptions.put('Civil_Work__c',new list<string>{'true','false'}); pickoptions.put('Eat__c',getEat()); pickoptions.put('Site_Service_Needed_for__c',getSiteServiceNeededfor()); pickoptions.put('Live__c',getLive()); pickoptions.put('Play__c',getPlay()); pickoptions.put('Who_will_be_staying_in_the_house__c',getWhowillbestayinginthehouse()); pickoptions.put('LeadRecord',new List<String>{JSON.serialize(Leaddata(recordId))}); return json.serialize(pickoptions); } //-- Seperate picklist values----// @AuraEnabled public static List<String> getHomeType(){ Map<String,String> options = new Map<String, String>(); Schema.DescribeFieldResult fieldResult = Lead.Home_Type__c.getDescribe(); List<Schema.PicklistEntry> pList = fieldResult.getPicklistValues(); for (Schema.PicklistEntry p: pList) { options.put(p.getValue(), p.getLabel()); } return options.values(); } @AuraEnabled public static List<String> getScopeOfWork(){ Map<String, String> options = new Map<String, String>(); Schema.DescribeFieldResult fieldResult = Lead.Scope_Of_Work__c.getDescribe(); List<Schema.PicklistEntry> pList = fieldResult.getPicklistValues(); for (Schema.PicklistEntry p: pList) { options.put(p.getValue(), p.getLabel()); } return options.values(); } @AuraEnabled public static List<String> getInteriorworkneededfor(){ Map<String, String> options = new Map<String, String>(); Schema.DescribeFieldResult fieldResult = Lead.Interior_work_needed_for__c.getDescribe(); List<Schema.PicklistEntry> pList = fieldResult.getPicklistValues(); for (Schema.PicklistEntry p: pList) { options.put(p.getValue(), p.getLabel()); } return options.values(); } @AuraEnabled public static List<String> getEat(){ Map<String, String> options = new Map<String, String>(); Schema.DescribeFieldResult fieldResult = Lead.Eat__c.getDescribe(); List<Schema.PicklistEntry> pList = fieldResult.getPicklistValues(); for (Schema.PicklistEntry p: pList) { options.put(p.getValue(), p.getLabel()); } return options.values(); } @AuraEnabled public static List<String> getSiteServiceNeededfor(){ Map<String, String> options = new Map<String, String>(); Schema.DescribeFieldResult fieldResult = Lead.Site_Service_Needed_for__c.getDescribe(); List<Schema.PicklistEntry> pList = fieldResult.getPicklistValues(); for (Schema.PicklistEntry p: pList) { options.put(p.getValue(), p.getLabel()); } return options.values(); } @AuraEnabled public static List<String> getWhowillbestayinginthehouse(){ Map<String, String> options = new Map<String, String>(); Schema.DescribeFieldResult fieldResult = Lead.Who_will_be_staying_in_the_house__c.getDescribe(); List<Schema.PicklistEntry> pList = fieldResult.getPicklistValues(); for (Schema.PicklistEntry p: pList) { options.put(p.getValue(), p.getLabel()); } return options.values(); } @AuraEnabled public static List<String> getPropertyUsage(){ Map<String, String> options = new Map<String, String>(); Schema.DescribeFieldResult fieldResult = Lead.Property_Usage__c.getDescribe(); List<Schema.PicklistEntry> pList = fieldResult.getPicklistValues(); for (Schema.PicklistEntry p: pList) { options.put(p.getValue(), p.getLabel()); } return options.values(); } @AuraEnabled public static List<String> getRequirementDetails(){ Map<String, String> options = new Map<String, String>(); Schema.DescribeFieldResult fieldResult = Lead.Requirement_Details__c.getDescribe(); List<Schema.PicklistEntry> pList = fieldResult.getPicklistValues(); for (Schema.PicklistEntry p: pList) { options.put(p.getValue(), p.getLabel()); } return options.values(); } @AuraEnabled public static List<String> getLive(){ Map<String, String> options = new Map<String, String>(); Schema.DescribeFieldResult fieldResult = Lead.Live__c.getDescribe(); List<Schema.PicklistEntry> pList = fieldResult.getPicklistValues(); for (Schema.PicklistEntry p: pList) { options.put(p.getValue(), p.getLabel()); } return options.values(); } @AuraEnabled public static List<String> getPlay(){ Map<String, String> options = new Map<String, String>(); Schema.DescribeFieldResult fieldResult = Lead.Play__c.getDescribe(); List<Schema.PicklistEntry> pList = fieldResult.getPicklistValues(); for (Schema.PicklistEntry p: pList) { options.put(p.getValue(), p.getLabel()); } return options.values(); } @AuraEnabled public static Map<String, String> getWhenwouldyouliketohavethehomeValue(){ Map<String, String> options = new Map<String, String>(); Schema.DescribeFieldResult fieldResult = Lead.When_would_you_like_to_have_the_home__c.getDescribe(); List<Schema.PicklistEntry> pList = fieldResult.getPicklistValues(); for (Schema.PicklistEntry p: pList) { options.put(p.getValue(), p.getLabel()); } return options; } @AuraEnabled public static Map<String, String> getWorkValue(){ Map<String, String> options = new Map<String, String>(); Schema.DescribeFieldResult fieldResult = Lead.Work__c.getDescribe(); List<Schema.PicklistEntry> pList = fieldResult.getPicklistValues(); for (Schema.PicklistEntry p: pList) { options.put(p.getValue(), p.getLabel()); } return options; } //---- Update Edited Field values ----// @AuraEnabled Public static String Updatelead(String leadRec){ try{ Lead ld = (Lead)JSON.deserialize(LeadRec, Lead.class); update ld; return 'success'; }catch(Exception e){ return e.getMessage(); } finally { } } //---- Displaying Existed Data -----// @AuraEnabled public static Lead Leaddata(Id recordId) { Lead ld = [Select Id,Area__c,Others_for_Live__c,Others_for_Play__c,Home_Type__c, Play__c,Scope_Of_Work__c, Civil_Work__c, Work__c,Live__c, Interior_work_needed_for__c, Eat__c,Property_Usage__c, Requirement_Details__c,Move_in__c,Property_Possession_Date__c,How_many_kids_do_you_have__c, Age_of_First_kid__c, Gender_of_First_kid__c,Age_of_Second_kid__c,Gender_of_Second_kid__c, Age_of_Third_kid__c,Gender_of_Third_kid__c, Age_of_Fourth_kid__c, Gender_of_Fourth_kid__c, Do_you_have_pets__c, Who_will_be_staying_in_the_house__c, When_would_you_like_to_have_the_home__c, Where_are_you_currently_located__c, Which_language_are_you_most_comfortable__c, If_other_languages_please_specify__c,Site_Service_Needed_for__c from Lead where Id=:recordId LIMIT 1]; return ld; } }