Get a first look at what's coming. The Developer Passport Australia Release Preview kicks off March 12. Dive in! 

how to update variable inside callback function

Akki1
Tera Contributor

HI, I have defined variable outside and i want to update the value inside callback . How can i do it.

I have tried to explain my scenario using an example.

var name='abc';

if(user!=' '){

var x = g_form.getReference('user', callFunction);

function callFunction(x){

var managerName=x.manager;

name=name+"_" + managerName;

}

}

alert(name);     // I'm not getting the updated name it still shows abc 

//The goal I want to achieve is the variable to update the value and use it outside callFunction

 

22 REPLIES 22

It is not working

Check if this link will help you.

 

Regards,
Sumanth

I have done same I hv declared outside and updating inside function . but it is not working maybe something different in callBackfunction

Ankur Bawiskar
Tera Patron

Hi,

why not declare the variable inside callback itself?

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 10x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

This is just a sample the variable is getting values updated with  scripts which are running in the lines before this