You need to sign in to do that
Don't have an account?
suji srinivasan
how to disable input calender field?
hi, how to enable input calendar field for picklist option1-Reengagement
and disable the same input calendar field for picklist option 2-Inadeqautedata in aura.
<lightning:select aura:id="industryPicklist" value="{!v.lead.Industry}" onchange="{!c.handleOnChange}" name="industryPicklist" label="Industry" required="true">
<option value="">--None--</option>
<option value="1">Re engagement</option>
<option value="2">Inadequate Data</option>
<lightning:input type="date" name="input1" label="Re engagement" />
Thanks in advance
and disable the same input calendar field for picklist option 2-Inadeqautedata in aura.
<lightning:select aura:id="industryPicklist" value="{!v.lead.Industry}" onchange="{!c.handleOnChange}" name="industryPicklist" label="Industry" required="true">
<option value="">--None--</option>
<option value="1">Re engagement</option>
<option value="2">Inadequate Data</option>
<lightning:input type="date" name="input1" label="Re engagement" />
Thanks in advance
https://developer.salesforce.com/forums/?id=9062I000000Qv1oQAC
Thank you for your support.
All Answers
Can you please make use of aura if like below.https://salesforce.stackexchange.com/questions/240059/how-to-display-hide-fields-in-lightning-component-using-javascript
Hope this is helpful..please mark this as best answer!!
Regards,
Ranjan
and disable the same input calendar field for picklist option 2-Inadeqautedata in aura.
component:
<aura:component controller="DynamicPicklist" implements="flexipage:availableForAllPageTypes,force:appHostable">
<aura:attribute name="fieldMap" type="Map"/>
<aura:attribute name="lead" type="Lead" default="{'sobjectType':'Lead',
'LastName': '',
'Company': '',
'Email': '',
'Phone': '',
'Industry': ''}"/>
<!--Declare Handler-->
<aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
<!--Component Start-->
<div class="slds-m-around--xx-large">
<div class="container-fluid">
<div class="form-group">
<lightning:input name="Name" type="text" label="Lead Name" value="{!v.lead.LastName}" />
</div>
<div class="form-group">
<lightning:input name="Company" type="text" label="Company" value="{!v.lead.Company}" />
</div>
<div class="form-group">
<lightning:input name="Email" type="email" label="Email" value="{!v.lead.Email}" />
</div>
<div class="form-group">
<lightning:input name="Phone" type="phone" label="Phone" value="{!v.lead.Phone}" />
</div>
<div class="form-group">
<lightning:select aura:id="industryPicklist" value="{!v.lead.Industry}" onchange="{!c.handleOnChange}" name="industryPicklist" label="Industry" required="true">
<option value="">--None--</option>
<option value="1">Re engagement</option>
<option value="2">Inadequate Data</option>
<!-- <aura:iteration items="{!v.fieldMap}" var="i" indexVar="key">
<option text="{!i.value}" value="{!i.key}" selected="{!i.key==v.lead.Industry}" />
</aura:iteration>-->
</lightning:select>
</div>
<div class="row">
<aura:if isTrue="{!v.lead.Industry}" ><option value="1">Re engagement</option>>
<lightning:input type="date" name="input1" label="Re engagement" />
</aura:if>
</div>
</div>
<br/>
<lightning:button variant="brand" label="Submit" onclick="{!c.LeadSave}" />
</div>
</aura:component>
controller:
({
doInit: function(component, event, helper) {
helper.getPicklistValues(component, event);
},
LeadSave : function(component, event, helper) {
helper.saveLead(component, event);
},
//handle Industry Picklist Selection
handleOnChange : function(component, event, helper) {
var industry = component.get("v.lead.Industry",true);
alert(industry);
}
})
helper:
({
getPicklistValues: function(component, event) {
var action = component.get("c.getIndustryFieldValue");
action.setCallback(this, function(response) {
var state = response.getState();
if (state === "SUCCESS") {
var result = response.getReturnValue();
var fieldMap = [];
for(var key in result){
fieldMap.push({key: key, value: result[key]});
}
component.set("v.fieldMap", fieldMap);
}
});
$A.enqueueAction(action);
},
saveLead : function(component, event) {
var lead = component.get("v.lead");
var action = component.get("c.createLead");
action.setParams({
leadobj : lead
});
action.setCallback(this,function(response){
var state = response.getState();
if(state === "SUCCESS"){
alert('Record Created Successfully!!');
} else if(state === "ERROR"){
var errors = action.getError();
if (errors) {
if (errors[0] && errors[0].message) {
alert(errors[0].message);
}
}
}
});
$A.enqueueAction(action);
}
})
Apex:
public class DynamicPicklist {
@AuraEnabled
Public static void createLead(Lead leadobj){
try{
insert leadobj;
}catch(Exception e){
System.debug(e.getMessage());
System.debug(e.getLineNumber());
}
}
@AuraEnabled
public static Map<String, String> getIndustryFieldValue(){
Map<String, String> options = new Map<String, String>();
Schema.DescribeFieldResult fieldResult = Lead.Industry.getDescribe();
List<Schema.PicklistEntry> pValues = fieldResult.getPicklistValues();
for (Schema.PicklistEntry p: pValues) {
options.put(p.getValue(), p.getLabel());
}
return options;
}
}
Thanks in advance
Vladyslav
Find me at https://www.chess.com/member/lazurchenko
Thank you for sharing.
I believe you must first comprehend it, for which you may go to (https://www.processfusion.com/en) in the hopes of resolving the problem.
Use below code:-
if you need any assistanse, Please let me know!!
Kindly mark my solution as the best answer if it helps you.
Thanks
Mukesh
component
<aura:component controller="DynamicPicklist" implements="flexipage:availableForAllPageTypes,force:appHostable">
<aura:attribute name="flag" type="boolean" default="false" />
<aura:attribute name="fieldMap" type="Map"/>
<aura:attribute name="lead" type="Lead" default="{'sobjectType':'Lead',
'LastName': '',
'Company': '',
'Email': '',
'Phone': '',
'Industry': ''}"/>
<div class="slds-m-around--xx-large">
<div class="container-fluid">
<div class="form-group">
<lightning:input name="Name" type="text" label="Lead Name" value="{!v.lead.LastName}" />
</div>
<div class="form-group">
<lightning:input name="Company" type="text" label="Company" value="{!v.lead.Company}" />
</div>
<div class="form-group">
<lightning:input name="Email" type="email" label="Email" value="{!v.lead.Email}" />
</div>
<div class="form-group">
<lightning:input name="Phone" type="phone" label="Phone" value="{!v.lead.Phone}" />
</div>
<div class="form-group">
<lightning:select aura:id="industryPicklist" value="{!v.lead.Industry}" onchange="{!c.handleOnChange}" name="Industry" label="Industry" required="true">
<option value="">--None--</option>
<option value="1">Re engagement</option>
<option value="2">Inadequate Data</option>
</lightning:select>
</div>
<aura:if isTrue="{!v.flag}">
<lightning:input type="date" name="input1" label="Enter a date" value="{! v.date }" />
</aura:if>
</div>
<br/>
<lightning:button variant="brand" label="Submit" onclick="{!c.LeadSave}" />
</div>
</aura:component>
controller:
({
doInit: function(component, event, helper) {
helper.getPicklistValues(component, event);
},
LeadSave : function(component, event, helper) {
helper.saveLead(component, event);
},
//handle Industry Picklist Selection
handleOnChange : function(component, event, helper) {
var sel = component.find("industryPicklist").get("v.value");
if (sel=="Re engagement") {
component.set("v.flag",true);
}
else if(sel=="Inadequate Data"){
component.set("v.flag",false);
}
}
})
https://developer.salesforce.com/forums/?id=9062I000000Qv1oQAC
Thank you for your support.