0

So i have one function which makes an apex call

     doInit: function(component, event, helper) {
                 
                       var Opptype =  component.get("v.simpleRecord.Type_Of_Opportunity__c");
     var action = component.get("c.getRecordTypeName");
                        action.setParams({
                    "OpportunityType" : Opptype
                });
                action.setCallback(this, function(response) {
                      var quoteRecordId = response.getReturnValue();
                      component.set("v.quoteRecordValue", quoteRecordId);
console.log(component.get("v.quoteRecordValue");
console.log(component.get("v.quoteRecordId "); <--- both console logs return values
                    
               });
                     $A.enqueueAction(action);
        helper.showCreateRecordModal(component);
        }

now how exactly am i supposed to pass the value of quoteRecordId unto a helper function? Because on the helper when i use component.get("v.quoteRecordId"); i get undefined. Hell if i try to component.get that value afer the enqueueAction it's still undefined...

showCreateRecordModal : function(component) {

    component.get("v.quoteRecordValue");  <---undefined.

This is when i run console log

Edit: missed a copy paste

3
  • you have not defined the action. Define action with apex method name. and make sure you are getting value in quoteRecordId, by putting debug log. – Amol May 6 at 9:19
  • looks like you have not used proper syntax for calling apex method from JS controller. Use var action = component.get("c.apexMethodName"); Please try to post your complete code including markup and apex controller – Manu Tej May 6 at 9:30
  • yeah i missed that part when adding copying the code over into the post, updated. – ensir May 6 at 15:47
0

You have not defined the action. you need to define action with apex method name.

Ex. let action = component.get("c.getExpenses");

Where getExpenses is the Name of Apex method.

You can refer this trailhead

Put the debug log and check you are getting value in quoteRecordId variable.

If you have to use quoteRecordId value in other function then you can save that value using component.set() method. else you can directly pass value to other function.

Controller
doInit: function(component, event, helper) {
   var=quoteRecordId;
   helper.showCreateRecordModal(component,quoteRecordId);
}

Helper
showCreateRecordModal: function(component,quoteRecordId){
     console.log(quoteRecordId);
}
1
  • i missed that when copy --> pasting my code in. it's now defined. – ensir May 6 at 15:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.