Highlight in Blue color 'Caller' field

Bijay Kumar Sha
Giga Guru

I'm implementing below requirement but it's not happening. 

In the user table, for every user records, we've an attribute called Business Unit which is a dropdown variable as per below screenshot -

BijayKumarSha_0-1713360863437.png

So, if I'll create an incident or a service request, and if I put the caller name, then in backend it should validate, if the caller's Business Unit is Technology or Marketing, then the name should be appear in Blue color instead of regular black color. For others, it should be as it is like black color.

How I can implement this?

 

1 ACCEPTED SOLUTION

I've updated the below code in Client script and it's working fine. Thanks for providing the required details. It's really helpful

BijayKumarSha_1-1713521916797.png

 

View solution in original post

8 REPLIES 8

Hi @Bijay Kumar Sha 

 

Please modify your client script as below 

 

var element = g_form.getElement('caller_id');
var ga = new GlideAjax('<script_include_name>');
ga.addParam('sysparm_name', 'validateBusinessUnit');
ga.addParam('sysparm_caller', newValue);
ga.getXml(callback);

function callback(response) {
var ans = response.responseXML.documentElement.getAttribute('answer');
if (ans == 'YES') {
element.style.backgroundColor = "blue";
} else {
element.style.backgroundColor = "black";
}
}
 

This will definitely helps you to resolved your issue. Let me know in case you need to understand the flow or you can DM on LinkedIn.

 

If this solution resolves your query, kindly mark it as the accepted solution and give it a thumbs up.

 

Best Regards,
Krushna Birla

 
 

Hi @Krushna R Birla , I tried to use the script as you've provided and still not getting the result. I'm sharing the code as below -

BijayKumarSha_0-1713520727677.png

Here, I've add a g_form.addInfoMessgae funtion to see if it entering to this if loop, so I'm getting the Info message on my  form. But color of caller field is not getting changed to Blue. 

Also, I've observed, 1st I'm putting the user name who is a part of the Business Unit mentioned in the script include, then it's entering in the If loop and InfoMassage is being shown on the form. And then if I'm providing another user name (who is not part of the mentioned Business Unit) in caller field of the INC form, the Info message is not getting removed, it's still there.

Can you please look into it

I've updated the below code in Client script and it's working fine. Thanks for providing the required details. It's really helpful

BijayKumarSha_1-1713521916797.png

 

Hi @Krushna R Birla , I'm seeing one problem here. While creating an INC, If I choose a user having above mentioned Business Unit, then text color of the caller field is getting changed from Black to Blue. But when I submit that INC, I'm seeing only black color. No change in color. 

How, I can achieve this?