Why is my Ajax script and Client script not working. unable to call the records from Leave bucket

MG_Azam
Tera Contributor

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)

 

Screenshot 2023-10-29 153923.pngScreenshot 2023-10-29 153946.png

1 ACCEPTED SOLUTION

@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 

Screenshot 2023-10-29 153946.png

 

And your Populate leave data should have the following code.

Screenshot 2023-10-29 234800.png

Hope this clears out all the confusion and resolves your issue.

View solution in original post

10 REPLIES 10

Harsh_Deep
Giga Sage
Giga Sage

Hello @MG_Azam 

 

In client script in 8th line use this

g_user.userID() 

 

And in the script include

In the line 22, 23 and 24

Use this

gr.accrued.getDisplayValue();

gr.balance.getDisplayValue();

gr.taken.getDisplayValue();

 

This will work.

 

Please accept solution and mark as helpful if it helps you.

Hi @Harsh_Deep  ,

I'm getting an error at the form stating the user.userID is not a function.

And included the same for line 22,23 and 24 as you suggested, still not working, any other solutions, please let me know

Brad Bowman
Kilo Patron
Kilo Patron

Troubleshoot this by adding alerts to the Client Script to confirm that it is running, and the answer/result.  Make sure your Script Include is Client callable, and add some gs.info or gs.addInfoMessage lines to confirm it is running, the values passed in from the client, if/which record is fetched by the GR, and the value that is to be returned to the client.  If/once it's making it inside the gr.next with the correct record, if the log of the leaveDetails object is not correct, you might just need to force each field to a string like this:

leaveDetails.accrued = '' + gr.accrued.toString();
leaveDetails.balance = '' + gr.balance.toString();
leaveDetails.take = '' + gr.taken.toString();

 

Hi @Brad Bowman  ,

Thanks for helping the code is running as you mentioned to add the  gs.addInfoMessage, I'm able to find the notification, but still the script is not pulling the record, any other suggestions, please provide.