You need to sign in to do that
Don't have an account?
sen19
Unable to set attribute/var in helper.js
I am calling apex class from helper.js and want to store the return string in a var or attribute. But the return string from apex is not getting stored in any of these. Its always coming as undefined. Could anyone help me in this:
({
helpermethd1:function(component, event, helper)
{
var locale = $A.get("$Locale.language");
var returl = component.get("v.backUrl");
console.log('returl>>>'+returl);
if($A.util.isEmpty(returl) && $A.get("$Label.c.a1")===locale){
debugger;
var tokendecoded=helper.getURLParamWithoutDecode('token');
var action=component.get("c.returl");
action.setParams({"tokenSF":tokendecoded});
action.setCallback(this, function(response){
var state = response.getState();
if (state === "SUCCESS"){
alert('success');
var retrnvalue=response.getReturnValue();
if(retrnvalue!=null){
returl=retrnvalue;
}
else{
returl=$A.get("$Label.c.abc");
}
}
else
{
returl=$A.get("$Label.c.abc");
}
});
debugger;
}
else if($A.util.isEmpty(returl)){
returl = $A.get("$Label.c.xyz");
console.log('returl UK'+returl);
debugger;
}
$A.enqueueAction(action);
window.open(returl,'_top');
},
getURLParamWithoutDecode : function(identifier)
{
.......
.....
}
})
Apex:
public without sharing virtual class sample {
@AuraEnabled public static String redirectURL(String tokenSF){ return abc;
({
helpermethd1:function(component, event, helper)
{
var locale = $A.get("$Locale.language");
var returl = component.get("v.backUrl");
console.log('returl>>>'+returl);
if($A.util.isEmpty(returl) && $A.get("$Label.c.a1")===locale){
debugger;
var tokendecoded=helper.getURLParamWithoutDecode('token');
var action=component.get("c.returl");
action.setParams({"tokenSF":tokendecoded});
action.setCallback(this, function(response){
var state = response.getState();
if (state === "SUCCESS"){
alert('success');
var retrnvalue=response.getReturnValue();
if(retrnvalue!=null){
returl=retrnvalue;
}
else{
returl=$A.get("$Label.c.abc");
}
}
else
{
returl=$A.get("$Label.c.abc");
}
});
debugger;
}
else if($A.util.isEmpty(returl)){
returl = $A.get("$Label.c.xyz");
console.log('returl UK'+returl);
debugger;
}
$A.enqueueAction(action);
window.open(returl,'_top');
},
getURLParamWithoutDecode : function(identifier)
{
.......
.....
}
})
Apex:
public without sharing virtual class sample {
@AuraEnabled public static String redirectURL(String tokenSF){ return abc;
Hi Ananga
In your helper, in var action=component.get("c.returl"); you have mentioned the method name as "returl".
But in Apex, you have named the function as : redirectURL(String tokenSF).
Try var action=component.get("c.redirectURL"); to see if that resolves the issue.