- Post History
- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
on 03-24-2021 04:10 AM
Hi everyone,
When you are new to Servicenow sometimes you get confuse with Asynchronous and Synchronous so I will explain this with an example just to understand why it is recommended to use Asynchronous instead of Synchronous so lets start with Asynchronous:
as above you can see I have created a onChange Client script on incident table and field name is caller so when getReference is executed because of callback function specified it will run asynchronously meaning (just to understand) on thread will fetch the value and another will alert if caller is vip this all will happen simultaneously below is the example where value is fetched from caller field and populated and alert is executed simultaneously
Synchronous:
In Synchronous it is said that sometimes the browser goes into halted state when you are fetching the values from database or server because the flow of code waits till the value is fetched from server or DB I have tried to demonstrate a synchronous call below is the code:
in the above code when you do not specify the callback function in getReference it behaves like a synchronously and waits till the alert box is pressed ok when clicked on ok of alert box then the value is populated in caller field otherwise it is same as the previous value and does not get changed below is the example:
above caller David Miller is my previous caller now I will change it to King Kai which is my VIP caller:
Now as I have selected King kai just observe my caller field it is not populated with king kai it is same as previous :
In above still caller field has not been populated when I will click on ok of the alert box it will then populate hence it is recommended to use asynchronous instead of synchronous.
Regards,
Abhishek Chavan
- 2,592 Views