getReference usage in Client Scripts

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
I want a field message saying "This user is VIP" when the caller in the incident form is a VIP user
SO THAT I know when I am working with a VIP user

 

Acceptance criteria: 

I know this is complete when a field message is shown to process user if the caller is VIP Please use g_form.getReference

3 ACCEPTED SOLUTIONS

Upsilon
Giga Guru

Hi,

You can do it like that:

 var caller = g_form.getReference('your_user_field', isVipDo);
 function isVipDo(user){
   if (user.vip==true) ;// Do something
      }

 

Nota: For this kind of uses it's recommanded to use ajax . More details in this article:

https://www.servicenow.com/community/itom-forum/what-is-difference-between-glide-ajax-call-and-getre...

 

Regards

View solution in original post

Prince Arora
Tera Sage
Tera Sage

@Tomas Linde 

 

Write a onchange client script on caller field and mention the script as below:

 

var data = g_form.getReference("caller",myData); //myData is the callback function, caller is the backend name of field

function myData(data){

if(data.vip == "true"){

g_form.showFieldMsg("field_backend_name", "This User is VIP")

}

}

 

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

View solution in original post

@Tomas Linde 

 

Var grUser = g_form.getReference("caller_id",checkVipUser);

 

Rest looks good 🙂

 

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

View solution in original post

9 REPLIES 9

My Script

@Tomas Linde ,

 

Please update the line 13 as:

 

g_form.showFieldMsg("caller","This is VIP user");

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

 

This is my script

@Tomas Linde 

 

Var grUser = g_form.getReference("caller_id",checkVipUser);

 

Rest looks good 🙂

 

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

Thank you very much for all the help 😊