AnsweredAssumed Answered

Replacing a Relationship in Code Not Working

Question asked by Arthur Chocholacek on Nov 9, 2015
Latest reply on Nov 11, 2015 by Alan Beam

Hi Folks. Tearing what little hair I have left out over a seemingly nonsensical bug that I cannot figure out.


Perhaps the problem is me, so I come to you for help.

Install is Sugar on Prem.


We have a heavy duty custom EditView page that is supposed to replace relationships if the field is changed, yadda yadda yadda. My code to do so is as follows


// Load the Relationship

// Delete the relationship for each related account
foreach ($oppBean->accounts->getBeans() as $relBean) {

// Display the related records, which you would expect to be nil, but instead it outputs the id of the original related record.
foreach ($oppBean->accounts->getBeans() as $relBean) {
                error_log(" PostDel Now Reld to: "  . $relBean->id);

// Add the new related account

// Display the new list of related records, which should only be the one we just added, but instead it outputs the ID of the original related record.
foreach ($oppBean->accounts->getBeans() as $relBean) {
error_log("Now Reld to: "  . $relBean->id);


If there's no existing Opp->Account relationship, it updates fine, but if there's an existing one, it behaves as above.


What am I missing? What am I doing wrong? I've done the same thing elsewhere and it works fine. Suggestions? Places to look? Common gremlins? Help!