I’m running the following script. Somewhere in the middle of that, it’s triggering this function in main.js:
And it loops and loops over lines 19531-19534 (doesn’t seem to ever reach 19535).
Here’s my code:
var mA = skuid.$M('Open'), rA = mA.getFirstRow(),
$ = skuid.$;
//Check for related caller info
$.blockUI({
message: 'Checking for Caller other than Patient...'
});
console.log('Checking for Caller other than Patient.');
if (rA.Caller\_Other\_Than\_Patient && rA.Caller\_First\_Name\_\_c) {
console.log('Adding Caller other than Patient as Related Person.');
var dfd = new $.Deferred(),
mR = skuid.$M('Related'),
fullName = rA.Caller\_First\_Name\_\_c + ' ' + rA.Caller\_Last\_Name\_\_c;
//Check if row for caller already exists (if so, update that row)
var exists = false;
$.each(mR.data, function(i,row){
if (row.Name == fullName) {
exists = true;
mR.updateRow(row,{
Relationship\_to\_Patient\_\_c: rA.Relationship\_to\_Patient\_\_c,
Primary\_Phone\_\_c: rA.Caller\_Primary\_Phone\_\_c,
Primary\_Phone\_Type\_\_c: rA.Caller\_Primary\_Phone\_Type\_\_c
});
}
});
//If row for caller doesn't exist, create it
if (!exists){
mR.createRow({
additionalConditions:d
{field: 'Name', value: rA.Caller\_First\_Name\_\_c + ' ' + rA.Caller\_Last\_Name\_\_c},
{field: 'First\_Name\_\_c', value: rA.Caller\_First\_Name\_\_c},
{field: 'Last\_Name\_\_c', value: rA.Caller\_Last\_Name\_\_c},
{field: 'Relationship\_to\_Patient\_\_c', value: rA.Relationship\_to\_Patient\_\_c},
{field: 'Primary\_Phone\_\_c', value: rA.Caller\_Primary\_Phone\_\_c},
{field: 'Primary\_Phone\_Type\_\_c', value: rA.Caller\_Primary\_Phone\_Type\_\_c},
]
});
}
$.when(mR.save())
.done(function(){
console.log('Created Related Person.');
dfd.resolve();
})
.fail(function(){
console.log('Related Person model save failed.');
dfd.reject();
});
return dfd.promise();
}
Any thoughts on what might be going on?