GlideAjax in Client Script

Tomas Linde
Tera Expert

Hi everyone,
I'm Junior Developer and I'm stuck with this story and I need some help:

 

- As a Process User (itil) I want that when an incident is submitted, the system checks if the caller is "Joe Employee". If that is the case, an alert must inform that "You cannot submit an incident for Joe Employee" and prohibit incident submission. This should work for new and existing incident SO THAT Joe Employee is cannot submit incidents.

 

I know this is complete when I cannot have an incident with Joe Employee as the caller. 

Portal is not in scope. 

 

CLIENT SCRIPT:

Captura de pantalla 2023-04-13 a las 17.53.11.png

 SCRIPT INCLUDE:

Captura de pantalla 2023-04-13 a las 17.53.38.png

Thank you very much in advance.

2 ACCEPTED SOLUTIONS

Prince Arora
Tera Sage
Tera Sage

@Tomas Linde ,

 

Can you try below code:

 

if(g_form.getValue("caller") == "SYS_ID_OF_USER"){

   alert("You cannot submit an incident for Joe Employee");

   return false;

}

 

Please avoid using Async calls (GlideAjax) in on submit client scripts because they will take time to execute the logic until the form gets submitted. 

 

If my answer solved your issue, please mark my answer as Correct & 👍Helpful based on the Impact. 

View solution in original post

Ian Mildon
Tera Guru

Don't use Script Includes with an onSubmit because you cannot guarantee that you'll get a response back before the submit is performed.

 

This would be much better as an onChange Client Script. That way you will always have the response back in time

View solution in original post

2 REPLIES 2

Prince Arora
Tera Sage
Tera Sage

@Tomas Linde ,

 

Can you try below code:

 

if(g_form.getValue("caller") == "SYS_ID_OF_USER"){

   alert("You cannot submit an incident for Joe Employee");

   return false;

}

 

Please avoid using Async calls (GlideAjax) in on submit client scripts because they will take time to execute the logic until the form gets submitted. 

 

If my answer solved your issue, please mark my answer as Correct & 👍Helpful based on the Impact. 

Ian Mildon
Tera Guru

Don't use Script Includes with an onSubmit because you cannot guarantee that you'll get a response back before the submit is performed.

 

This would be much better as an onChange Client Script. That way you will always have the response back in time