Skip to main content

We have a junction object called OpportunityAccounts that is a many-to-many relationship between an Account and Opportunity. We have a table of these objects that includes a custom mass action snippet, that I’m using to update a field called “PrimaryAddress__c” on the Account.

However, can’t figure out save my Account objects with the OpportunityAccountModel:


var addressId = getAddressId();<br />var selectedItems = argumentsa0]&#46;list&#46;getSelectedItems();<br />var model = argumentsa0]&#46;model;<br />var rowsToUpdate = {};<br />selectedItems&#46;map(function(item) {<br />&nbsp; &nbsp; rowsToUpdatesitem&#46;row&#46;Account__c] = { PrimaryAddress__c: addressId };<br />});<br />model&#46;updateRows(rowsToUpdate);<br />model&#46;save();

After saving the model, the accounts are not updated. I’m guessing this is because the model is referencing the junction object (OpportunityAccount).

So what do I need to do to update these records? I tried initializing a new model as well as creating a dummy one through the UI. Neither option worked for me.

Kinda at a loss for what else to try, anyone have a solution?

Matt,

I think you are trying to update the Account using the OpportunityAccount object.  This is not supported.

You would need to load another model on Account using the Account Ids from OpportunityAccount and update this model using your script.

Does that make sense?

Thanks,

Bill