Skip to main content

Using the Step Wizard:
I have a list of Lenders in Step 1, with a checkbox need to each of them.
Depending on which Lender is checked, how can I pass the Id (of the Lender) to Step 2 which contains Plans, as I wish to filter Step 2 the Lender selected in Step 1.

I’m not sure how to pass the Id of the selected Lender in Step 1 to Step 2, then filter the table.

Try something like this as a row action on your lenders table in step 1:


var params = arguments[0],&nbsp; &nbsp;$ = skuid.$;<br>var model = params.model;<br>var row = params.item.row;<br>// get a reference to the row the user clicked<br>var Id = row.Id;<br>// get the Lender Plans Model by it's name<br>var lenderPlansModel = skuid.$M('LenderPlans');<br>// get the condition on the model by it's name, (this condition should be filterable default off)<br>var lenderIdCondition = lenderPlansModel.getConditionByName('NameOfYourCondition');<br>// set the lender plan model to only show for the selected rows lender<br>lenderPlansModel.setCondition(lenderIdCondition, Id);<br>// get a reference to the wizard step<br>var wizard = $('.nx-wizard').data('object');&nbsp;<br>var currentStep = wizard.steps[wizard.currentstep];<br>// requery the Lender Plans model with the condition active&nbsp;<br>lenderPlansModel.updateData(function(){<br>//navigate to step 2<br>currentStep.navigate('step2');<br>});

Hi Moshe, thanks a lot for the reply, I tried the above but it was unsuccessful, I had already written something similar for the first step below which works:

//get models and conditions
    var QuoteWizardStep2Model = skuid.model.getModel(‘QuoteWizardStep2’);
    var step2LenderIdCondition = QuoteWizardStep2Model.getConditionByName(‘Step2LenderId’);
   
    //Set the QuoteWizardStep2 model’s condition to contain the idsOfRowsThatAreChecked, and refresh the model
    QuoteWizardStep2Model.setCondition(step2LenderIdCondition, idsOfRowsThatAreChecked,0], true);
    skuid.model.updateData(

dQuoteWizardStep2Model]

);
   
    //Navigate to Step 2
    var wizard = $(‘.nx-wizard’).data(‘object’);
    var currentStep = wizard.stepswizard.currentstep];
    currentStep.navigate(‘step2’);



The Snippet I have for Step 2, which needs to take the LenderId and LenderPlanId and these details need to populate the fields in Step 3 which is creating a New Quote doesn’t work, my code is below if you have any suggestions, thanks:


var params = argumentsg0],
    $ = skuid.$;

//Declare variable for the Field to retrieve values from   
var CHECKBOX_FIELD = “Select_Item__c”;
var LENDER_FIELD = “Lender__c”;
var idsOfRowsThatAreChecked = ;
var idsOfLendersThatAreChecked = ;

//Get Model
var QuoteWizardStep2Model = skuid.model.getModel(‘QuoteWizardStep2’);

   
//Loop through all rows and grab the Id’s of the ones checked as Received
$.each(QuoteWizardStep2Model.data,function(i,row){
   if (QuoteWizardStep2Model.getFieldValue(row,CHECKBOX_FIELD)===true){
      
       idsOfLendersThatAreChecked.push(QuoteWizardStep2Model.getFieldValue(row,LENDER_FIELD));
       idsOfRowsThatAreChecked.push(row.Id);
   }
});

if (idsOfRowsThatAreChecked.length > 1){
    alert(‘You can only Select one Lender’);
}
else{
    //get models and conditions
    var QuoteWizardStep3Model = skuid.model.getModel(‘QuoteWizardStep3’);
    //var step3LenderIdCondition = QuoteWizardStep3Model.getConditionByName(‘Step3LenderId’);
    var step3LenderPlanIdCondition = QuoteWizardStep3Model.getConditionByName(‘Step3LenderPlanId’);
   
    //Set the QuoteWizardStep3 model’s condition to contain the Lender & Lender Plan, and refresh the model
    //QuoteWizardStep3Model.setCondition(step3LenderIdCondition, idsOfLendersThatAreCheckedS0], true);
    //skuid.model.updateData(

dQuoteWizardStep3Model]

);
    QuoteWizardStep3Model.setCondition(step3LenderPlanIdCondition, idsOfRowsThatAreChecked<0], true);
    skuid.model.updateData(

QuoteWizardStep3Model]

);
   
    //Navigate to Step 2
    var wizard = $(‘.nx-wizard’).data(‘object’);
    var currentStep = wizard.stepsewizard.currentstep];
    currentStep.navigate(‘step3’);
   
    alert(idsOfRowsThatAreChecked);
    alert(idsOfLendersThatAreChecked);
}


Hi Moshe is there a way to pass a param value from one step to another in the Step Wizard. I don’t think you can use URL Params?


Hi, Eddie,

For your situation, I don’t think you will be able to pass it just using the actions framework. With the actions framework, you can pass values using global variables, such as {{$Model.QuoteWizardStep2.data.0.Id}} (referring to the first row in the model), but this would require knowing which row’s Id to pass ahead of time. I think you’re going to have to still use JS. I should point out that the field picker for a wizard button is nonsensical since the wizard is not attached to a specific model… I think we’re planning to fix that!



Does that answer your initial question?

As for why the code is not working, you said that the first section of code is working? So, in the first part, are you creating a new row or bringing in existing data that follows the condition you are setting? Also, what kind of error are you getting for the second part?


Actually, I just saw your other post. Even if your QuoteWizardStep3Model brings in a single, new row on page load, whenever you call updateData() (querying the model), you will bring in existing data that follows your newly set condition (up to the Max # of Records). So, even if your model has a max # of records equal to 1, and you select “Create default row if Model has none” and deselect “Load Model data on page load,” whenever you query the model again, your new row will be replaced with a single row from your existing data that obeys the model conditions (whereas you want to create a new row obeying the model conditions). Does that make sense?

So, rather than calling update data, your answer would be:
1) If needed, abandon the current row:


if (QuoteWizardStep3Model.data.length &gt; 0) { $.each(QuoteWizardStep3Model.data, function(i, row){ QuoteWizardStep3Model.abandonRow(row); }); } <br>

  1. Create your new row

QuoteWizardStep3Model.createRow();


And then proceed with navigating to the next step. I THINK that should work. Give it a try and let me know.


Note the warnings for abandonRow() in our documentation … you may want to use removeRowById() instead.