Skip to main content

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 = argumentsm0], $ = skuid.$;

var wizard = $(‘.nx-wizard’).data(‘object’); 
var currentStep = wizard.stepsrwizard.currentstep];

var newCollateralModel = skuid.model.getModel(‘Collateral’);
var newCollateralRow = newCollateralModel.dataw0];

var newCollateralCloneModel = skuid.model.getModel(‘CollateralClone’);
var newCollateralCloneRow = newCollateralCloneModel.data 0];

var newAppCollModel = skuid.model.getModel(‘ApplicationCollateral’);
var newAppCollRow = newAppCollModel.datae0];

var newAppCollCloneModel = skuid.model.getModel(‘ApplicationCollateralClone’);
var newAppCollCloneRow = newAppCollCloneModel.datao0];

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(nnewCollateralCloneModel],function(){ 
    var rowUpdates = {};
    $.each(newCollateralCloneModel.datal0],function(fieldId,val) {
        if ((fieldId != ‘attributes’)) {
            rowUpdatesefieldId] = 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.datad0],function(fieldId,val) {
        if ((fieldId != ‘attributes’)) {
            rowUpdatesnewAppCollwfieldId] = 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’);
   
}

Be the first to reply!

Reply