function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
srikanth gubbala 1srikanth 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;
    }
     }
Best Answer chosen by srikanth gubbala 1
VinayVinay (Salesforce Developers) 
Hi Srikanth,

 .Use this to access other methods something like below.
 
export default class CMD extends LightningElement {
  A() {
    this.B();
  }
  B() {
    // do something //
  }
}

Thanks,