- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-25-2024 02:03 PM
Hello,
I need to create a metric definition based on two date fields.
When the AD Review field is changed to "Needed" and saved, a business rule puts the Date/Time in the AD Review Start field:
When the review is completed, the Reviewer changes the AD Review field to Complete. A business rule updates the AD Review End field to the current Date/Time:
I'm trying to create a metric instance using this metric definition which is mostly OOB, and I cannot get it to create the metric. Any ideas?
var end = current.ad_review_end;
if (!end.nil()) {
createMetric();
}
function createMetric() {
var mi = new MetricInstance(definition, current);
if (mi.metricExists()) {
return;
}
var gr = mi.getNewRecord();
gr.start = current.ad_review_start;
gr.end = current.ad_review_end;
gr.duration = gs.dateDiff(gr.start.getDisplayValue(), gr.end.getDisplayValue());
gr.calculation_complete = true;
gr.insert();
}
Thank you,
Laurie
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-26-2024 09:22 AM
Found it! On the original metric definition I forgot to populate the field AD Review End. Type should be Script Calculation. And then it worked!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-26-2024 09:22 AM
Found it! On the original metric definition I forgot to populate the field AD Review End. Type should be Script Calculation. And then it worked!