You need to sign in to do that
Don't have an account?
srikanth gubbala 1
How to get value from one function to other function in salesforce ligtening js
Controller.js
init: function(component, event, helper) {
var action = component.get('c.fetchUser');
action.setCallback(this, function(response) {
//store state of response
var state = response.getState();
if (state === "SUCCESS") {
var retData = response.getReturnValue();
component.set('v.email', retData);
console.log('success'+v.email);
}
});
$A.enqueueAction(action);
},
handleChange : function(component, event) {
var changeValue = event.getParam("value");
if(changeValue === 'option1'){
var urlEvent = $A.get("e.force:navigateToURL");
urlEvent.setParams({
"url": "......."
});
urlEvent.fire();
}else{
var UserName = $A.get("$SObjectType.CurrentUser.Email");
var address=v.email;
console.log('Accoutn Nam'+address);
//var address=UserName;
window.location.href = 'mailto:dell@mail.com?cc='+UserName+'&Subject='+address+'name';
}
},
showModel: function(component, event, helper) {
component.set("v.showModal", true);
},
hideModel: function(component, event, helper) {
component.set("v.showModal", false);
},
})
i want to pass v.email to window.location.href which is in different function.
apexcalss
public class currentUserInfoCtrl {
@AuraEnabled
public static string fetchUser(){
// User u = [select id,Name,email from User where id =: UserInfo.getUserId()];
// return u;
String Accname = [SELECT Contact.Account.Name FROM USER WHERE Id =: UserInfo.getUserId() LIMIT 1].Contact.Account.Name;
return Accname;
}
}
init: function(component, event, helper) {
var action = component.get('c.fetchUser');
action.setCallback(this, function(response) {
//store state of response
var state = response.getState();
if (state === "SUCCESS") {
var retData = response.getReturnValue();
component.set('v.email', retData);
console.log('success'+v.email);
}
});
$A.enqueueAction(action);
},
handleChange : function(component, event) {
var changeValue = event.getParam("value");
if(changeValue === 'option1'){
var urlEvent = $A.get("e.force:navigateToURL");
urlEvent.setParams({
"url": "......."
});
urlEvent.fire();
}else{
var UserName = $A.get("$SObjectType.CurrentUser.Email");
var address=v.email;
console.log('Accoutn Nam'+address);
//var address=UserName;
window.location.href = 'mailto:dell@mail.com?cc='+UserName+'&Subject='+address+'name';
}
},
showModel: function(component, event, helper) {
component.set("v.showModal", true);
},
hideModel: function(component, event, helper) {
component.set("v.showModal", false);
},
})
i want to pass v.email to window.location.href which is in different function.
apexcalss
public class currentUserInfoCtrl {
@AuraEnabled
public static string fetchUser(){
// User u = [select id,Name,email from User where id =: UserInfo.getUserId()];
// return u;
String Accname = [SELECT Contact.Account.Name FROM USER WHERE Id =: UserInfo.getUserId() LIMIT 1].Contact.Account.Name;
return Accname;
}
}
.Use this to access other methods something like below.
Thanks,