calculated value not appearing in DB view
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2018 03:34 AM
Hello team,
I have created a simple Calculated field on the table asmt_metric_result:
(function calculatedFieldValue(current) {
if (current.nps_value !='') {
return current.nps_value * 100;
}
})(current);
It works fine when I display the asmt_metric_result table, but does not work as expected in the Database view that contain that table.
I have a DB view that connect the incident table to the asmt_metric_result, but here the field does not show any value. is that normal or I made some mistake?
I thought that this could happen as the name of the field I am calculating has clearly a different "name" in the DB view... smth like mtrt_nps_value, but even pointing to it does not change the result.
My main goal is to display this calculated field within a report that use the DB view as "table".
Any suggestion is appreciated!
Thanks
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2018 01:12 AM
Me again, I have tried several different ways, and nothing... not even the Function field type display any value on a Database View... but works fine on the native table.
Is that a limitation? like Function field and Calculated field will not display any value on DB views? I could not find any documentation about this.
And if so, is there anyway to show a calculated value on a DB view? I tried also with Script include but still value is not shown on a DB View.
Thanks a lot!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-18-2018 07:11 AM
Replying to myself, seems I figured out the following:
a calculated field on a table: display it's value for both new record and all existing record in the table.
the same calculated field on the Database view related to the previous table, display the value only on new records (no value is shown on old records).
I have then run a Fix script to force an update on all old records, and at this point the Calculated value appeared for all records also on the DB View.
I thought that Calculated field automatically save the value in the Database (different from Function field) but apparently till the record got updated no value was saved.
Anyway good to know
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-23-2018 09:43 AM
Hi,
Just interested on how you have it? One of my customer has similar problem and we are wondering what could be the solution for this.
Thanks,
Satya.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-23-2018 10:39 AM
Hey Satya,
Yes, I sorted that out... was long ago;)
Anyway you need to generate an update on all old records, so the value from the calculated field is "inserted" and it will be visible in DB view as well.
I did this by running a background script that would push an update on all affected records.
Hope this helps!