You need to sign in to do that
Don't have an account?
Achyuth
How to assign the field value to a variable in salesforce lightning controller and assign to a variable?
Hi All,
Can anyone help me on the below requirement please!!
I have an apex controller(with an argument passed), lightning component, lightning controller where as I can able to fetch the records by passing the value from the ui using lightning component...and is working fine
I need is : i want to assign the field value to a variable in salesforce lightning controller and assign to a variable ABC.
Please find the code:-
@auraEnabled
public static List<Account> getAccount(Id searchKey ){
List <Account> acclist = new List <Account>();
if(searchKey!= Null){
acclist = [SELECT Id, Name, Description from Account WHERE ID =: searchKey];
}
return acclist;
======================================================
getAccountList : function(component, event, helper) {
var action = component.get("c.getAccount");
var search = component.get("v.searchKey");
action.setParams({
"searchKey": search
});
action.setCallback(this, function(response){
var state = response.getState();
if(state == 'SUCCESS') {
var acclist = response.getReturnValue();
component.set("v.Accountlist",acclist);
var fieldValue = component.get("v.Accountlist");
======================================================
the entire query result is in fieldValue now... I want to assign only the name to another value...
Can anyone Help me on this !!
Thanks in Adv.!!
Chinna.
Can anyone help me on the below requirement please!!
I have an apex controller(with an argument passed), lightning component, lightning controller where as I can able to fetch the records by passing the value from the ui using lightning component...and is working fine
I need is : i want to assign the field value to a variable in salesforce lightning controller and assign to a variable ABC.
Please find the code:-
@auraEnabled
public static List<Account> getAccount(Id searchKey ){
List <Account> acclist = new List <Account>();
if(searchKey!= Null){
acclist = [SELECT Id, Name, Description from Account WHERE ID =: searchKey];
}
return acclist;
======================================================
getAccountList : function(component, event, helper) {
var action = component.get("c.getAccount");
var search = component.get("v.searchKey");
action.setParams({
"searchKey": search
});
action.setCallback(this, function(response){
var state = response.getState();
if(state == 'SUCCESS') {
var acclist = response.getReturnValue();
component.set("v.Accountlist",acclist);
var fieldValue = component.get("v.Accountlist");
console.log(JSON.stringify(fieldValue )); // i am getting all the values based on the query.
console.log('Value ::::::: '+fieldValue );
console.log('Value ::::::: '+fieldValue );
======================================================
the entire query result is in fieldValue now... I want to assign only the name to another value...
Can anyone Help me on this !!
Thanks in Adv.!!
Chinna.
Actually i done the same thing.In the abve code "v.Accountlist "is an attribute where i set the result from acclist. by using " console.log(JSON.stringify(fieldValue )); " i can able to see the result .But i want to assign the only "name" field from the result to another variable from controller to do one if else logic..
If name='raj' then it should call the flow
else.... it should call another flow..
Can u help me on this !!
Thanks,
Chinna
If this helps you, please close the thread by marking this as the best answer. Thanks.