- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-04-2024 01:44 PM
On thee Incident form I want to display a message under the "Caller" field that says the user is Elite if the grades of service field on the user tables shows the elite option. (picture attached)
I'm working on a client script and need help with how to structure the code. new to coding
any help would be appreciated.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-04-2024 02:09 PM
Hello Joyea,
The reason it is not working in your current implementation is because on the Client side you cannot "dot-walk" into the GlideRecord it is referencing. You would need to call the Server to get the relevant data.
There are a few ways to handle this.
- You could use GlideAjax which would require you to also write a corresponding Script include to return the data you needed.
- Use the GlideForm getReference method followed by a callback function to process the results.
Taking your example, I would rewrite it as such:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
g_form.getReference('caller_id', function (userGR) {
var userGradesOfService = userGR.u_grade_of_service;
if (userGradesOfService == "elite") {
g_form.showFieldMsg('caller_id', 'This user is Elite', 'info');
}
});
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-04-2024 02:09 PM
Hello Joyea,
The reason it is not working in your current implementation is because on the Client side you cannot "dot-walk" into the GlideRecord it is referencing. You would need to call the Server to get the relevant data.
There are a few ways to handle this.
- You could use GlideAjax which would require you to also write a corresponding Script include to return the data you needed.
- Use the GlideForm getReference method followed by a callback function to process the results.
Taking your example, I would rewrite it as such:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
g_form.getReference('caller_id', function (userGR) {
var userGradesOfService = userGR.u_grade_of_service;
if (userGradesOfService == "elite") {
g_form.showFieldMsg('caller_id', 'This user is Elite', 'info');
}
});
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-04-2024 02:53 PM
I was ablet to crate a script include and this worked perfectly!