how to update variable inside callback function
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-02-2022 06:28 AM
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
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-02-2022 11:41 PM
It is not working

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-02-2022 11:46 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-02-2022 11:50 PM
I have done same I hv declared outside and updating inside function . but it is not working maybe something different in callBackfunction
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-02-2022 11:38 PM
Hi,
why not declare the variable inside callback itself?
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-02-2022 11:40 PM
This is just a sample the variable is getting values updated with scripts which are running in the lines before this