I'm trying to learn JS and have created a very simple lookup after reviewing relevant blogs but cannot seem to get it to generate an alert to confirm working.
From the Service Activity entity, linked to the Case with a lookup on the regardingobjectid field, I am trying to lookup the contents of a field in the Case called new_traveltimeaverage (whole number, duration), then output via alert to verify.
I'm working from an existing Service Activity record where regardingobjectid contains saved data, but I keep getting an undefined error. Can anyone see what I've done wrong here? Thank you.
var avgtravel = new Array();
avgtravel = Xrm.Page.getAttribute("regardingobjectid").getValue();
if (avgtravel !== null) {
var name = lookup[0].name;
var id = lookup[0].id;
var time = lookup[0].new_traveltimeaverage;
}
alert(time);