You need to sign in to do that
Don't have an account?

How to call a function inside other function?
Hello, everyone.
I have 2 different functions in my lookup component. The first loads the records (doinit) and another fires an event to pass to the parent component the chosen record Id and label.
1) loadValues : function (component, event) {
var record = component.get("v.record");
var subheading = '';
for(var i=0; i<component.get("v.subHeadingFieldsAPI").length ;i++ ){
if(record[component.get("v.subHeadingFieldsAPI")[i]]){
subheading = subheading + record[component.get("v.subHeadingFieldsAPI")[i]] + ' • ';
}
}
subheading = subheading.substring(0,subheading.lastIndexOf('•'));
component.set("v.subHeadingFieldValues", subheading);
console.log('check')
},
2) choose : function (component,event) {
var chooseEvent = component.getEvent("lookupChoose");
chooseEvent.setParams({
"recordId" : component.get("v.record").Id,
"recordLabel":component.get("v.record").Name
});
chooseEvent.fire();
console.log('event fired');
}
the problem is: I have to make those things happen at the same time. I've tried to fire the event in the first function but it didn't work, so I thought in calling the function "choose" inside the "load Values". Can anyone help me with that?
I have 2 different functions in my lookup component. The first loads the records (doinit) and another fires an event to pass to the parent component the chosen record Id and label.
1) loadValues : function (component, event) {
var record = component.get("v.record");
var subheading = '';
for(var i=0; i<component.get("v.subHeadingFieldsAPI").length ;i++ ){
if(record[component.get("v.subHeadingFieldsAPI")[i]]){
subheading = subheading + record[component.get("v.subHeadingFieldsAPI")[i]] + ' • ';
}
}
subheading = subheading.substring(0,subheading.lastIndexOf('•'));
component.set("v.subHeadingFieldValues", subheading);
console.log('check')
},
2) choose : function (component,event) {
var chooseEvent = component.getEvent("lookupChoose");
chooseEvent.setParams({
"recordId" : component.get("v.record").Id,
"recordLabel":component.get("v.record").Name
});
chooseEvent.fire();
console.log('event fired');
}
the problem is: I have to make those things happen at the same time. I've tried to fire the event in the first function but it didn't work, so I thought in calling the function "choose" inside the "load Values". Can anyone help me with that?
Try this way.
If this doesn't work write your choose method in helper and call that helper method from loadvalues method like this.
Hope this helps you
Let me know if this helps you. Kindly mark it as solved so that it may help others in future.
Thanks and Regards