Model rows not getting updated

  • 1
  • Problem
  • Updated 2 years ago
  • (Edited)
I have two objects collateral and applicationCollateral(contains collateralId,Amount). What I'm looking to do is to provide two options to user 1.to create new collateral and applicationCollateral 2. updating existing collateral and applicationCollateral. I have created a wizard for it which works fine for 1st requirement i.e creating new but its not updating values for existing collateral and applicatioCollateral. 
Now here is catch which I feel is creating problem,what I have done is create two model(namely Collateral and CollateralClone model) on same object collateral. first one i.e collateral, which will be used to display the values in wizard steps and the other one  will query the collateral model based on condition(where collateral Id is the Id of collateral selected from lookup( of applicatioCollateral object i.e ApplicationColateral__r.Collateral__c) in previous wizard step). After the query I'm updating rows of the Collateral model which is displaying the correct selected collateral information. 

But now if I'm trying to chnage/modify any values in text fields,etc of collateral model, it's not updating the collateral model row data.I want to be able to update existing collateral model rows.I tried looking for solution but no success. Any directions will be helpful.

Here's the JS 

var params = arguments[0], $ = skuid.$;

var wizard = $('.nx-wizard').data('object'); 
var currentStep = wizard.steps[wizard.currentstep];

var newCollateralModel = skuid.model.getModel('Collateral');
var newCollateralRow = newCollateralModel.data[0];

var newCollateralCloneModel = skuid.model.getModel('CollateralClone');
var newCollateralCloneRow = newCollateralCloneModel.data[0];

var newAppCollModel = skuid.model.getModel('ApplicationCollateral');
var newAppCollRow = newAppCollModel.data[0];

var newAppCollCloneModel = skuid.model.getModel('ApplicationCollateralClone');
var newAppCollCloneRow = newAppCollCloneModel.data[0];

var editor = $('#PanelForAll ').data('object').editor;
editor.clearMessages();


// Handle error messages
var displayMessage = function (message, severity) {
   
    editor.handleMessages([
        {
            message: message,
            severity: severity.toUpperCase()
        }
    ]);
    
    return false;
}

if(newCollateralRow.ExistingCollateral){
    
    if (!newAppCollRow.Collateral__c) {
        return displayMessage('Select a Collateral ', 'ERROR');
    }
    
    
    var collateralIdCondition = newCollateralCloneModel.getConditionByName('Id');
   
    newCollateralCloneModel.setCondition(collateralIdCondition,newAppCollRow.Collateral__c);
    skuid.model.updateData([newCollateralCloneModel],function(){ 
    var rowUpdates = {};
    $.each(newCollateralCloneModel.data[0],function(fieldId,val) {
        if ((fieldId != 'attributes')) {
            rowUpdates[fieldId] = val;
        }
    });

   
    newCollateralModel.updateRow(newCollateralRow, rowUpdates);
    
    
    var AppcollateralCloneIdCondition =   newAppCollCloneModel.getConditionByName('Collateral__c');
    newCollateralCloneModel.setCondition(AppcollateralCloneIdCondition,newCollateralRow.Id);
    
    skuid.model.updateData([newAppCollCloneModel],function(){ 
    
        
    var rowUpdatesnewAppColl = {};
    $.each(newAppCollCloneModel.data[0],function(fieldId,val) {
        if ((fieldId != 'attributes')) {
            rowUpdatesnewAppColl[fieldId] = val;
        }
    });

    
    newAppCollModel.updateRow(newAppCollRow, rowUpdatesnewAppColl);
    
    });
        currentStep.navigate('step3');
    });
}
else{
    
     
    if (!newCollateralRow.clcommon__Collateral_Type__c) {
        return displayMessage('Select a Collateral Type ', 'ERROR');
    }
    currentStep.navigate('step3');
   
}
Photo of Ashish Kumar Singh

Ashish Kumar Singh

  • 300 Points 250 badge 2x thumb

Posted 2 years ago

  • 1

Be the first to post a reply!