Can't call helper function from helper inside list forEachui:inputDate rendering issue in visualforceunable to fetch the value of dynamically generated component in client side controller of Lightning ComponentLightning component: Child rows in data tableCould not update lightning components: Cannot read property 'Id' of undefinedAre Address fields are restricted to save in LDS?Show checkbox while loading componentHow to pass Date to Datatime lightning inputfieldHow to apply event listener (keypress) only in current component?Create and Navigate to an Account record Detail PageComponent call another lightning component
What is the AI assistant for the Iron Man Rescue armor?
How to create quantum circuits from scratch
How to pass array of values in lualatex?
How to check if all my faces on mesh are all quads using a script
Has Iron Man made any suit for underwater combat?
Is it better to merge "often" or only after completion do a big merge of feature branches?
Why Lie algebras if what we care about in physics are groups?
Why does airflow separate from the wing during stall?
Trivial non-dark twist in dark fantasy
Monday's Blocking Donimoes Problem
Why are Oscar, India, and X-Ray (O, I, and X) not used as taxiway identifiers?
Can a warlock shoot multiple beams from the Eldritch Blast cantrip with only a single free hand?
What do Unicorns want?
Considerations when providing money to only one child out of two
Host telling me to cancel my booking in exchange for a discount?
Found old paper shares of Motorola Inc that has since been broken up
What would be the effects of (relatively) widespread precognition on the stock market?
Why is there an extra "t" in Lemmatization?
Book in which the "mountain" in the distance was a hole in the flat world
How did pilots avoid thunderstorms and related weather before “reliable” airborne weather radar was introduced on airliners?
How do you structure large embedded projects?
Is it ethical to tell my teaching assistant that I like him?
How old is the Italian word "malandrino"?
Can the caster of Time Stop still use their bonus action or reaction?
Can't call helper function from helper inside list forEach
ui:inputDate rendering issue in visualforceunable to fetch the value of dynamically generated component in client side controller of Lightning ComponentLightning component: Child rows in data tableCould not update lightning components: Cannot read property 'Id' of undefinedAre Address fields are restricted to save in LDS?Show checkbox while loading componentHow to pass Date to Datatime lightning inputfieldHow to apply event listener (keypress) only in current component?Create and Navigate to an Account record Detail PageComponent call another lightning component
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I have the following code:
setDataTG : function(component)
var data = [], tgdata = [], current, row, picklistMAP = component.get("v.picklistMAP"), dataComplex = component.get("v.dataComplex");
dataComplex.forEach(function(d)
row = ;
//Parse data
if(d.hasOwnProperty('neOrderItem'))
current = d.neOrderItem;
Object.keys(current).forEach(function(k)
if(k === 'NE__ProdName__c')
row['NE__ProdName__c'] = current['Name'] + ' - ' + current['NE__ProdName__c'];
else if(k === 'NE__Status__c')
row['NE__Status__c'] = picklistMAP[current['NE__Status__c']];
else
row[k] = current[k];
);
//Check children
if(d.hasOwnProperty('children'))
data["_children"] = this.setDataTGChildrenHelper(component, d.children);
data.push(row)
tgdata.push(row);
);
console.log('****complex: ' + JSON.stringify(data));
component.set("v.data", data);
component.set("v.tgdata", tgdata);
component.set("v.isLoading", false);
,
And it's not letting me call setDataTGChildrenHelper giving me the following error:
[Cannot read property 'setDataTGChildrenHelper' of undefined]
How can I fix this?
lightning-aura-components lightning event
add a comment |
I have the following code:
setDataTG : function(component)
var data = [], tgdata = [], current, row, picklistMAP = component.get("v.picklistMAP"), dataComplex = component.get("v.dataComplex");
dataComplex.forEach(function(d)
row = ;
//Parse data
if(d.hasOwnProperty('neOrderItem'))
current = d.neOrderItem;
Object.keys(current).forEach(function(k)
if(k === 'NE__ProdName__c')
row['NE__ProdName__c'] = current['Name'] + ' - ' + current['NE__ProdName__c'];
else if(k === 'NE__Status__c')
row['NE__Status__c'] = picklistMAP[current['NE__Status__c']];
else
row[k] = current[k];
);
//Check children
if(d.hasOwnProperty('children'))
data["_children"] = this.setDataTGChildrenHelper(component, d.children);
data.push(row)
tgdata.push(row);
);
console.log('****complex: ' + JSON.stringify(data));
component.set("v.data", data);
component.set("v.tgdata", tgdata);
component.set("v.isLoading", false);
,
And it's not letting me call setDataTGChildrenHelper giving me the following error:
[Cannot read property 'setDataTGChildrenHelper' of undefined]
How can I fix this?
lightning-aura-components lightning event
add a comment |
I have the following code:
setDataTG : function(component)
var data = [], tgdata = [], current, row, picklistMAP = component.get("v.picklistMAP"), dataComplex = component.get("v.dataComplex");
dataComplex.forEach(function(d)
row = ;
//Parse data
if(d.hasOwnProperty('neOrderItem'))
current = d.neOrderItem;
Object.keys(current).forEach(function(k)
if(k === 'NE__ProdName__c')
row['NE__ProdName__c'] = current['Name'] + ' - ' + current['NE__ProdName__c'];
else if(k === 'NE__Status__c')
row['NE__Status__c'] = picklistMAP[current['NE__Status__c']];
else
row[k] = current[k];
);
//Check children
if(d.hasOwnProperty('children'))
data["_children"] = this.setDataTGChildrenHelper(component, d.children);
data.push(row)
tgdata.push(row);
);
console.log('****complex: ' + JSON.stringify(data));
component.set("v.data", data);
component.set("v.tgdata", tgdata);
component.set("v.isLoading", false);
,
And it's not letting me call setDataTGChildrenHelper giving me the following error:
[Cannot read property 'setDataTGChildrenHelper' of undefined]
How can I fix this?
lightning-aura-components lightning event
I have the following code:
setDataTG : function(component)
var data = [], tgdata = [], current, row, picklistMAP = component.get("v.picklistMAP"), dataComplex = component.get("v.dataComplex");
dataComplex.forEach(function(d)
row = ;
//Parse data
if(d.hasOwnProperty('neOrderItem'))
current = d.neOrderItem;
Object.keys(current).forEach(function(k)
if(k === 'NE__ProdName__c')
row['NE__ProdName__c'] = current['Name'] + ' - ' + current['NE__ProdName__c'];
else if(k === 'NE__Status__c')
row['NE__Status__c'] = picklistMAP[current['NE__Status__c']];
else
row[k] = current[k];
);
//Check children
if(d.hasOwnProperty('children'))
data["_children"] = this.setDataTGChildrenHelper(component, d.children);
data.push(row)
tgdata.push(row);
);
console.log('****complex: ' + JSON.stringify(data));
component.set("v.data", data);
component.set("v.tgdata", tgdata);
component.set("v.isLoading", false);
,
And it's not letting me call setDataTGChildrenHelper giving me the following error:
[Cannot read property 'setDataTGChildrenHelper' of undefined]
How can I fix this?
lightning-aura-components lightning event
lightning-aura-components lightning event
asked 9 hours ago
molinetmolinet
927 bronze badges
927 bronze badges
add a comment |
add a comment |
4 Answers
4
active
oldest
votes
This is the case of lexical scoping. You limiting the scope of callback function by using function(). Instead change it to below:
dataComplex.forEach((d) => {
Arrow function does'nt has its own scope and so will get the scope of parent object.
New contributor
salesforcesas is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
Or you can use .bind(this);
dataComplex.forEach(function(d)
row = ;
//Parse data
if(d.hasOwnProperty('neOrderItem'))
current = d.neOrderItem;
Object.keys(current).forEach(function(k)
if(k === 'NE__ProdName__c')
row['NE__ProdName__c'] = current['Name'] + ' - ' + current['NE__ProdName__c'];
else if(k === 'NE__Status__c')
row['NE__Status__c'] = picklistMAP[current['NE__Status__c']];
else
row[k] = current[k];
).bind(this);
//Check children
if(d.hasOwnProperty('children'))
data["_children"] = this.setDataTGChildrenHelper(component, d.children);
data.push(row)
tgdata.push(row);
).bind(this);
add a comment |
You can pass helper parameter into each helper function and thus you can call one helper function from another.
Example: helper1: function(component, event, helper)
this.helper2();
,
helper2:function(component, event, helper)
//helper 2 logic here
New contributor
Manjunatha V P is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
A simple and fairly easy to understand approach is to just alias this. The upshot is this approach still works if you have to support IE11.
const that = this;
someCollection.forEach(function (element)
that.otherHelper();
)
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "459"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsalesforce.stackexchange.com%2fquestions%2f270372%2fcant-call-helper-function-from-helper-inside-list-foreach%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
4 Answers
4
active
oldest
votes
4 Answers
4
active
oldest
votes
active
oldest
votes
active
oldest
votes
This is the case of lexical scoping. You limiting the scope of callback function by using function(). Instead change it to below:
dataComplex.forEach((d) => {
Arrow function does'nt has its own scope and so will get the scope of parent object.
New contributor
salesforcesas is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
This is the case of lexical scoping. You limiting the scope of callback function by using function(). Instead change it to below:
dataComplex.forEach((d) => {
Arrow function does'nt has its own scope and so will get the scope of parent object.
New contributor
salesforcesas is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
This is the case of lexical scoping. You limiting the scope of callback function by using function(). Instead change it to below:
dataComplex.forEach((d) => {
Arrow function does'nt has its own scope and so will get the scope of parent object.
New contributor
salesforcesas is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
This is the case of lexical scoping. You limiting the scope of callback function by using function(). Instead change it to below:
dataComplex.forEach((d) => {
Arrow function does'nt has its own scope and so will get the scope of parent object.
New contributor
salesforcesas is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
salesforcesas is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
answered 9 hours ago
salesforcesassalesforcesas
59211 bronze badges
59211 bronze badges
New contributor
salesforcesas is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
salesforcesas is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
add a comment |
Or you can use .bind(this);
dataComplex.forEach(function(d)
row = ;
//Parse data
if(d.hasOwnProperty('neOrderItem'))
current = d.neOrderItem;
Object.keys(current).forEach(function(k)
if(k === 'NE__ProdName__c')
row['NE__ProdName__c'] = current['Name'] + ' - ' + current['NE__ProdName__c'];
else if(k === 'NE__Status__c')
row['NE__Status__c'] = picklistMAP[current['NE__Status__c']];
else
row[k] = current[k];
).bind(this);
//Check children
if(d.hasOwnProperty('children'))
data["_children"] = this.setDataTGChildrenHelper(component, d.children);
data.push(row)
tgdata.push(row);
).bind(this);
add a comment |
Or you can use .bind(this);
dataComplex.forEach(function(d)
row = ;
//Parse data
if(d.hasOwnProperty('neOrderItem'))
current = d.neOrderItem;
Object.keys(current).forEach(function(k)
if(k === 'NE__ProdName__c')
row['NE__ProdName__c'] = current['Name'] + ' - ' + current['NE__ProdName__c'];
else if(k === 'NE__Status__c')
row['NE__Status__c'] = picklistMAP[current['NE__Status__c']];
else
row[k] = current[k];
).bind(this);
//Check children
if(d.hasOwnProperty('children'))
data["_children"] = this.setDataTGChildrenHelper(component, d.children);
data.push(row)
tgdata.push(row);
).bind(this);
add a comment |
Or you can use .bind(this);
dataComplex.forEach(function(d)
row = ;
//Parse data
if(d.hasOwnProperty('neOrderItem'))
current = d.neOrderItem;
Object.keys(current).forEach(function(k)
if(k === 'NE__ProdName__c')
row['NE__ProdName__c'] = current['Name'] + ' - ' + current['NE__ProdName__c'];
else if(k === 'NE__Status__c')
row['NE__Status__c'] = picklistMAP[current['NE__Status__c']];
else
row[k] = current[k];
).bind(this);
//Check children
if(d.hasOwnProperty('children'))
data["_children"] = this.setDataTGChildrenHelper(component, d.children);
data.push(row)
tgdata.push(row);
).bind(this);
Or you can use .bind(this);
dataComplex.forEach(function(d)
row = ;
//Parse data
if(d.hasOwnProperty('neOrderItem'))
current = d.neOrderItem;
Object.keys(current).forEach(function(k)
if(k === 'NE__ProdName__c')
row['NE__ProdName__c'] = current['Name'] + ' - ' + current['NE__ProdName__c'];
else if(k === 'NE__Status__c')
row['NE__Status__c'] = picklistMAP[current['NE__Status__c']];
else
row[k] = current[k];
).bind(this);
//Check children
if(d.hasOwnProperty('children'))
data["_children"] = this.setDataTGChildrenHelper(component, d.children);
data.push(row)
tgdata.push(row);
).bind(this);
answered 8 hours ago
Pranay JaiswalPranay Jaiswal
22.6k5 gold badges33 silver badges73 bronze badges
22.6k5 gold badges33 silver badges73 bronze badges
add a comment |
add a comment |
You can pass helper parameter into each helper function and thus you can call one helper function from another.
Example: helper1: function(component, event, helper)
this.helper2();
,
helper2:function(component, event, helper)
//helper 2 logic here
New contributor
Manjunatha V P is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
You can pass helper parameter into each helper function and thus you can call one helper function from another.
Example: helper1: function(component, event, helper)
this.helper2();
,
helper2:function(component, event, helper)
//helper 2 logic here
New contributor
Manjunatha V P is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
You can pass helper parameter into each helper function and thus you can call one helper function from another.
Example: helper1: function(component, event, helper)
this.helper2();
,
helper2:function(component, event, helper)
//helper 2 logic here
New contributor
Manjunatha V P is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
You can pass helper parameter into each helper function and thus you can call one helper function from another.
Example: helper1: function(component, event, helper)
this.helper2();
,
helper2:function(component, event, helper)
//helper 2 logic here
New contributor
Manjunatha V P is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
Manjunatha V P is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
answered 7 hours ago
Manjunatha V PManjunatha V P
7
7
New contributor
Manjunatha V P is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
Manjunatha V P is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
add a comment |
A simple and fairly easy to understand approach is to just alias this. The upshot is this approach still works if you have to support IE11.
const that = this;
someCollection.forEach(function (element)
that.otherHelper();
)
add a comment |
A simple and fairly easy to understand approach is to just alias this. The upshot is this approach still works if you have to support IE11.
const that = this;
someCollection.forEach(function (element)
that.otherHelper();
)
add a comment |
A simple and fairly easy to understand approach is to just alias this. The upshot is this approach still works if you have to support IE11.
const that = this;
someCollection.forEach(function (element)
that.otherHelper();
)
A simple and fairly easy to understand approach is to just alias this. The upshot is this approach still works if you have to support IE11.
const that = this;
someCollection.forEach(function (element)
that.otherHelper();
)
answered 7 hours ago
Adrian Larson♦Adrian Larson
114k19 gold badges132 silver badges271 bronze badges
114k19 gold badges132 silver badges271 bronze badges
add a comment |
add a comment |
Thanks for contributing an answer to Salesforce Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsalesforce.stackexchange.com%2fquestions%2f270372%2fcant-call-helper-function-from-helper-inside-list-foreach%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown