Can not access Script Include through onSubmit client script created in a scoped app produced by studio

Dush
Tera Contributor

Hi Team I kindly need your advice
I am developing a scoped application via Studio say "Data Center".

There I have created few tables and an onSubmit client script that has been developed on a particular table form ,from where a GLideAjax pointing to a script include has been called. (both are defined in the same scope that the application is belonged to )

scoped client script

find_real_file.png

find_real_file.png

Much logic not inserted to the call back function as I need to find out if the communication is established between CS and SI thus it sends server responses. I have tested for the server response ( though the code does not reflect it ) as I have passed some dummy string from the server expecting to receive it from  client side

find_real_file.png

configuration of the script include in the scoped app is as beneath

find_real_file.png

Issue:

When the form is submitted ( not from the Studio) client side code gets executed and the alert  check points are reached.
(It  goes inside the callback function as well). But the gs.log message of the Script include at line 6 is not  executed and can not see any debug message in system logs files (syslog), May be the script include is not reached I guess.
More over nothing is received from server

observations

  • The script debugger didn't get triggered even though I have activated the  .

How could I bundle the script app so that onsubmit client script communicate with the serverscript in the scoped app?
Even I can not execute the code on scripts-Background  as it produces an error : 
Evaluator.evaluateString() problem: com.glide.script.fencing.MethodNotAllowedException: Function log is not allowed in scope
 
Does this means the server side scripts not executed? If so how to over come the situation as I need t retrieve server (table ) value on to client side.

please kindly advice.

 

1 ACCEPTED SOLUTION

Allen Andreas
Administrator
Administrator

Hello,

gs.log is not recommended and does not work in scoped application.

Please use gs.info() for your logging needs.

Please re-run your tests again and double-check your return on your script include that it's actually returning a value.

Please mark reply as Helpful/Correct, if applicable. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

View solution in original post

4 REPLIES 4

Allen Andreas
Administrator
Administrator

Hello,

gs.log is not recommended and does not work in scoped application.

Please use gs.info() for your logging needs.

Please re-run your tests again and double-check your return on your script include that it's actually returning a value.

Please mark reply as Helpful/Correct, if applicable. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

Thanks a lot it helped me to catch the bug .

Dush
Tera Contributor

Hi 
I'm adding the second part of the question as it relates to the above code segment as well.

I have managed to get the server response and my expectation is to set the form field value (cabinet_id)  based on the server response.
find_real_file.png




The Issue I'm facing is that the field 'cabinet_id' is not set even if the beneath code segment within the callback function gets executed (please see the highlighted part of the image)

g_form.setValue('cabinet_id',cabinetIdToAdd);

what I have observed is the value gets written to the field and in the next split of second the field gets overridden.

please kindly advice if there is any foul code or concept within the code.

on submit Client script

find_real_file.png

find_real_file.png
find_real_file.png

find_real_file.png

find_real_file.png

Hello,

One of the main issues here is that you're trying to use GlideAjax within an onSubmit client script. So because it's async, the record goes to be saved and the final result isn't necessarily placed in the field, like you want, and so as the record freshes, the value isn't there (or contains what was there before).

It's recommended to review your process and see if you can adjust to an onChange client script, or...switch this to a before business rule and handle the functionality there (setting the field value onSubmit isn't really a user experience function anyway and so doing it in the client isn't really needed) or...evaluate making your GlideAjax not async (search forums for that as that question gets brought up a lot).

So there's 3 ways to do it, that I listed above.

onChange would be the ideal, if it has to happen in the client otherwise, before BR would be next best.

Please mark reply as Helpful/Correct, if applicable. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!