Skip to main content

Hi,
please consider below data model. 
Account–>Opportunity–> OpportunityLineItem 

I am rendering opportunities into picklist with master model as account. on account level I have one field which will store opportunityID (just for filtering  model data).

on selection change of picklist value of opportunity, I am updating account row with currently selected OpportunityId. 

now, on OpportuniyLineItem Model, I have one filterable condition which matches the value of this account row’s opportunityId and all OpportunityLineItems Id. 

I am trying to refresh data model of OpportuityLineItem by below code on selection change of Opportunity. 

var OppLineItemModel= skuid.model.getModel(‘OpportunityLineItem’);          
 condition = OppLineItemModel.getConditionByName(‘OpportunityId’);
         OppLineItemModel.emptyData();
      
        OppLineItemModel.setCondition(condition, selectedOption,true);
        OppLineItemModel.activateCondition(condition);
       
        
        OppLineItemModel.updateData(function() {});
           
           
 
 but it’s throwing error " Uncaught Model ‘OpportunityLineItem’ has unsaved changes. To update this model’s data, you must first save or cancel the changes."

I tried to use .save() method and in success callback of Save method, I am trying to execute .updateData() function, but I am getting same error. 

any help in this would be highly appreciated. 

Thanks in Advance ! 

Why are you calling " OppLineItemModel.emptyData();"? What does that even do? You can probably add a model.cancel() before the updateData as well, to avoid unsaved changes. I would also remove the empty function from model.updateData if you’re not using it…


Reply