- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-29-2023 03:17 AM
Hi Community,
Need your help with the Ajax code (Script include) and client script.
This code is created to call the record from the leave bucket and populate the respective fields in the new leave request form. variables are correct, but some how the code is not working (unable to pull the record and populate)
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-29-2023 11:55 AM
@MG_Azam I asked you to make changes in the Client script only. Your script include script should remain same.
In a nutshell, your ImsAjax should look like the following
And your Populate leave data should have the following code.
Hope this clears out all the confusion and resolves your issue.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-29-2023 12:23 PM
Since the script is running a GlideRecord on a custom table, you'll have to investigate to see why it's not finding the record. It sounds like you have confirmed the Script Include is running, which is a good start. You also need to confirm with info messages/logs the value passed in from the client for sysparm_user and sysparm_leavetype. You can then use these values in a manual filtering of a list view on your custom table to confirm that the intended record is displayed for the employee and leave_type. Your GlideRecord in your Script Include should retrieve the same record as the manual filtering of the list view, or else filter the list view to show the record you want, then change your GlideRecord to match. Once you confirm you are inside the if(gr.next()){ then you can confirm that the values of accrued, balance, and taken are pushed to the object then returned to the client. If you're still stuck, post the most recent version of your scripts, and a list view of the custom table filtered to the intended record, also copying the query from the last breadcrumb.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-29-2023 10:21 AM - edited 10-29-2023 10:23 AM
@MG_Azam Found a couple of issues in your client script.
Here is the summary.
Replace line number 17,18 and 19 with the following lines and your client script will work.
g_form.setValue('accrued',result.accrued);
g_form.setValue('balance',result.balance);
g_form.setValue('taken',result.taken);
Please mark the answer correct and helpful if it manages to solve your issue.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-29-2023 11:21 AM
Hi @Sandeep Rajput ,
Thanks for helping it is not working still this is how the scripts are looking currently.
1st. Ajax. 2nd. Client Script

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-29-2023 11:55 AM
@MG_Azam I asked you to make changes in the Client script only. Your script include script should remain same.
In a nutshell, your ImsAjax should look like the following
And your Populate leave data should have the following code.
Hope this clears out all the confusion and resolves your issue.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-30-2023 02:42 AM