Hi guys I am trying to write a script which makes a call on click of any button or any other event and as soon as call finish reports the duration of that call to a server.
I am facing the problem in stopping the listener to the call logs. the alert for last call duration comes in recursive manner.
following is the code I am trying for listening the logs
Code:var so = null; var noItemsErrorCode = 1012; function init() { StartListiningLogs(); } function StartListiningLogs() { try { so = device.getServiceObject("Service.Logging", "IDataSource"); } catch (err) { alert("error receiving Logging service handle"); return; } var filter = new Object(); filter.DelayTime = 2000000; var criteria = new Object(); criteria.Type = 'Log'; criteria.Filter = filter; try { so.IDataSource.RequestNotification(criteria, ListnerCallback); } catch (err) { alert("error listining log"); } } function ListnerCallback(transId, eventCode, result) { var criteria = new Object(); criteria.Type = "Log"; criteria.Filter = new Object(); criteria.Filter.RecentList = 2;//outgoing calls try { so.IDataSource.GetList(criteria, GetRecordCallback); } catch (err) { alert("error receiving log items"); } } function GetRecordCallback(transId, eventCode, result) { if (result.ErrorCode != 0) { // if error code is not "no suitable items" -- // show alert otherwise leave the function if (result.ErrorCode != noItemsErrorCode) { alert(result.ErrorMessage); } return; } else { var item; // pointer to item in received list var temp = " "; for (var i = 0; (item = result.ReturnValue.getNext()) != undefined; i++) { if (i == 0) { if (item['PhoneNumber'] != undefined) { temp += item['PhoneNumber']; } temp += " "; if (item['EventDuration'] != undefined) { temp += item['EventDuration']; } } } alert(temp); try { var criteria = new Object(); criteria.TransactionID = result.TransactionID; var result2 = so.IDataSource.Cancel(criteria); } catch (e) { alert("cancelRequestNotification: " + e); } } }
here in above code I am getting the value of result.TransactionID as undefined in function GetRecordCallback.
I wrote this code 2 months back at that time it worked fine for me. and now I am not able to figure out where
is the problem.
Thanks

Reply With Quote




