- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-12-2018 02:59 AM
Hi everyone,
We have done a Client script similar to OOTB "(BP) Set Location to User" wich sets the location of a incident same as caller.location when the caller is changed. Our script is equally to this OOTB but it sets the company.
The script seems to work perfectly, it sets the correct value for the company.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || (g_form.isLiveUpdating && g_form.isLiveUpdating()))
return;
if (newValue == '') {
g_form.setValue('company', '');
return;
}
if (!g_form.hasField('company'))
return;
var caller = g_form.getReference('caller_id', setCompany);
}
function setCompany(caller) {
if (caller){
g_form.setValue('company', caller.company, caller.company.name);
}
}
The problem is when we try to use the company value before saving the record. I explain it....
The field cmdb_ci on incident table is depending on company field.
When we set the company value using the script above in a New Record, the CI is not filtered by the company.
After saving the record, it works perfectly and the CI is filtered by company but it doesn ´t work before submit.
If after the script sets the value of company, we select company manually again, CI is filtered by company without needing to save/submit
So we are thinking that g_form.setValue() for a reference field is not the same that select the value of that field manually as we can see with our tests.
Is there any wayof do a set Value for a refefence field wich do the same of selecting it manually that can override this behavior?
Thanks and regards,
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-15-2019 01:10 AM
I discover this behavior only occurs if List v3 are activated. I opened a case in HI-Portal and support team recognized the issue but notify to me they are not going to provide a solution as List v3 are deprecated in London.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-12-2018 03:11 AM
Hope this will help.
Use the setValue() displayValue parameter for reference fields
Please Hit ✅Correct, â�ï¸�Helpful, or â�£ï¸�Like depending on the impact of the response
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-12-2018 03:17 AM
As you can see in the script, I ´m setting the display value correctly:
g_form.setValue('company', caller.company, caller.company.name);
So I think that is not the problem.....
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-12-2018 03:12 AM
How are you filtering your CI field? if you're doing it with a script include you should still be able to pull out the current value of the company field after it has been changed on the form before save/submit.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-12-2018 03:23 AM