Hey guys, I have a JS mass action that worked great until I installed Rockaway. The console is saying: Uncaught TypeError: Cannot read property ‘Id’ of undefined The source marks the error on this line of code: var CaseID = proto.Case__r.Id; I read Irvin’s message about a similar error, and the resolution had to do with add a trivial sub condition to a subquery. Is that the same error we have here? Also, how do I actually do that? Full snippet: var params = argumentsu0];var step = params.step;var $ = skuid.$; // REFERENCE MODELS var models = skuid.model.map(); var protoAppt = models.protoAppt; var newAppts = models.newAppts; var proto = protoAppt.getFirstRow(); // GET conditions var caseCondition = newAppts.getConditionByName(‘Case’); var userCondition = newAppts.getConditionByName(‘User’); var recurrencetotalCondition = newAppts.getConditionByName(‘RecurrenceTotal’); var recurrencestarttimeCondition = newAppts.getConditionByName(‘RecurrenceStartTime’); var recurrenceendtimeCondition = newAppts.getConditionByName(‘RecurrenceEndTime’); var recurrenceapptidCondition = newAppts.getConditionByName(‘RecurrenceApptID’); var recurrenceisrecurrenceCondition = newAppts.getConditionByName(‘RecurrenceIsRecurrence’); // SET conditions newAppts.setCondition(caseCondition,protoAppt.getFieldValue(proto,‘Case__c’)); newAppts.setCondition(userCondition,protoAppt.getFieldValue(proto,‘User__c’)); newAppts.setCondition(recurrencetotalCondition,protoAppt.getFieldValue(proto,‘RecurrenceNumberTotal__c’)); newAppts.setCondition(recurrencestarttimeCondition,protoAppt.getFieldValue(proto,‘StartDateTime__c’)); newAppts.setCondition(recurrenceendtimeCondition,protoAppt.getFieldValue(proto,‘EndDateTime__c’)); newAppts.setCondition(recurrenceisrecurrenceCondition,protoAppt.getFieldValue(proto,‘RecurrenceIsRecurrence__c’)); newAppts.setCondition(recurrenceapptidCondition,protoAppt.getFieldValue(proto,‘Id’)); // SET loop vars var CaseID = proto.Case__r.Id; //ERROR CAUSED BY THIS LINE var CaseName = proto.Case__r.Name; var UserID = proto.User__r.Id; var UserName = proto.User__r.Name; var loopRecurrenceNumber = 1; var loopRecurrenceNumberTotal = protoAppt.getFieldValue(proto,‘RecurrenceNumberTotal__c’); var loopStartDateTime = protoAppt.getFieldValue(proto,‘StartDateTime__c’); var jsloopStartDateTime = skuid.time.parseSFDateTime(loopStartDateTime); var loopEndDateTime = protoAppt.getFieldValue(proto,‘EndDateTime__c’); var jsloopEndDateTime = skuid.time.parseSFDateTime(loopEndDateTime); var loopDate = protoAppt.getFieldValue(proto,‘Date__c’); var jsloopDate = skuid.time.parseSFDate(loopDate); // ACTION CODE - loop and set non default values var i=1; while(i < 54){ var row = newAppts.createRow({ additionalConditions: r {field: ‘RecurrenceNumber__c’, value: i}, {field: ‘Case__c’, value: CaseID, operator: ‘=’, nameFieldValue: CaseName}, {field: ‘User__c’, value: UserID, operator: ‘=’, nameFieldValue: UserName}, {field: ‘RecurrenceIsRecurrence__c’, value: ‘True’}, {field: ‘Date__c’, value: loopDate}, {field: ‘Start_Time__c’, value: protoAppt.getFieldValue(proto,‘Start_Time__c’)}, {field: ‘End_Time__c’, value: protoAppt.getFieldValue(proto,‘End_Time__c’)}, {field: ‘Subject__c’, value: protoAppt.getFieldValue(proto,‘Subject__c’)}, {field: ‘Type__c’, value: protoAppt.getFieldValue(proto,‘Type__c’)} ] }); var jsloopStartDateTime = skuid.time.parseSFDateTime(loopStartDateTime); jsloopStartDateTime.setDate(jsloopStartDateTime.getDate() + 7); var loopStartDateTime = skuid.time.getSFDateTime(jsloopStartDateTime); var jsloopEndDateTime = skuid.time.parseSFDateTime(loopEndDateTime); jsloopEndDateTime.setDate(jsloopEndDateTime.getDate()+7); var loopEndDateTime = skuid.time.getSFDateTime(jsloopEndDateTime); var jsloopDate = skuid.time.parseSFDate(loopDate); jsloopDate.setDate(jsloopDate.getDate()+7); var loopDate = skuid.time.getSFDate(jsloopDate); //loopRecurrenceNumber = loopRecurrenceNumber + 1; //console.log(loopRecurrenceNumber); i++; } // FINISH CODE step.navigate(‘step2’);
Steps to reproduce: https://drive.google.com/file/d/0B28GLsVI2VfsaVZzNmo1RHM4cVk/view
That’s a standard JavaScript error when you try to access properties of undefined. In this case, the row returned by protoAppt.getFirstRow(); doesn’t have any related Case data (or the user running the page doesn’t have permission to access the Case record). If you use protoAppt.getFieldValue(proto,‘Case__r.Id’) instead, we work around it for you. It still might not make the snippet work the way you expect, but that should at least make the error go away.
I’m not immediately seeing how a Rockaway update would have caused this issue since the error wasn’t coming from one of our APIs. I’d start by switching to getFieldValue in your snippet, and confirming that a Case record does exist for that record and that the User can access it.
Hey J. That definitely resolved that issue, and a new one came up. It’s saying Uncaught TypeError: jsloopStartDateTime.getDate is not a function from this line: var jsloopStartDateTime = skuid.time.parseSFDateTime(loopStartDateTime); jsloopStartDateTime.setDate(jsloopStartDateTime.getDate() + 7); Any tips?
Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.