- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2020 09:03 AM
Hello guys,
I am trying to compare the values "Opened By" and "Resolved By" via a Client Script. I've tried both of the below code snippets, however they don't seem to work as expected.
var openby = g_form.getReference('opened_by');
var resolveby = g_form.getReference('resolved_by');
if(resolveby == openby)
{
g_form.setReadonly('u_firstcallresolution',true);
g_form.setValue('u_firstcallresolution',true);
}
var openby = g_form.getValue('opened_by');
var resolveby = g_form.getValue('resolved_by');
if(resolveby == openby)
{
g_form.setReadonly('u_firstcallresolution',true);
g_form.setValue('u_firstcallresolution',true);
}
Please help!!
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2020 10:54 AM
Could you please try giving an alert before the if condition and check what's the value in both the fields?
below is the script with the alert:
var openby = g_form.getValue('opened_by');
var resolveby = g_form.getValue('resolved_by');
alert("Opened By :"+openby+" Resolved By :"resolveby);
if(resolveby == openby)
{
alert("If Condition Satified");
g_form.setValue('u_firstcallresolution',true);
g_form.setReadOnly('u_firstcallresolution',true);
}
With the above script you will get 2 alert with the first alert you will get to know the value coming up in both the field and with the second you will get to know that the if loop is been executed.
Please give a try and give an update so it will be easy to debug the issue.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2020 11:35 AM
Hey Chaitanya,
So it went through the first alert showing the Sys ID of openedby and resolvedby. Both were same as a matter of fact, based on the test run I did.
The issue seems that, I am unable to go through the if(resolvedby == openedby). Any other way to troubleshoot this?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2020 11:39 AM
Nevermind, I found the reason why it didn't go through the if-loop.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2020 10:22 AM
Hi JD,
You can try for this code:
var a = g_form.getReference("resolved_by").name;
var b = g_form.getReference("opened_by").name;
if(a==b)
{
g_form.setValue('u_firstcallresolution',true);
g_form.setReadOnly('u_firstcallresolution',true);
}
Regards,
Subhojit Das
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2020 10:39 AM
Doesn't work
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2020 10:56 AM
Try
var openby = g_form.getValue('opened_by');
var resolveby = g_form.getValue('resolved_by');
if(resolveby == openby)
{
g_form.setReadOnly('u_firstcallresolution',true);
g_form.setValue('u_firstcallresolution',true);
}
Please mark my response as correct and helpful if it helped solved your question.
-Thanks