I’ve been using this post and a couple of others to get my wizard to work the way I want it, but now I’m trying to fix a bug with it and can’t figure out how. I’ve created a wizard that converts an Opportunity to a custom object called “Sales Orders”. The wizard takes all the relevant fields from the Opportunity object and populates the wizard using URL parameters and a JavaScript Snippet on the “Next Step” button. All the fields work properly, but if I click “previous step” and then “next step” again it doubles all the rows on my table. Before I click Previous step Like so
After I hit previous step I’m assuming this is because I have a loop that runs on the JavaSnippet, so I added an If statement before the loop to check if a variable “PreviousStepClicked” === 0 before starting the loop (and made “PreviousStepClicked = 1 after the loop”, but it doesn’t seem to work. I’m very novice in Javascript and know it’s probably something small and stupid that I’m doing wrong and would greatly appreciate any help anyone has to offer to solve this problem. Here is the JavaSnippet var params = arguments[0]; var step = params.step; var $ = skuid.$; var models = skuid.model.map(); var OppLineItems = models.OppLineItems; var NewSalesOrderItems = models.NewSalesOrderItems; var i = 1; var PreviousStepClicked = 0; if (PreviousStepClicked === 0) { $.each(OppLineItems.data,function(){ var row = NewSalesOrderItems.createRow({ additionalConditions: [ { field: ‘QTY_Req__c’, value: this.QTY_Req__c}, { field: ‘Price_Per_Part__c’, value: this.Price_Per_Part__c}, { field: ‘Part__c’, value: this.Part__c}, { field: ‘Total_Sale_Price__c’, value: this.Total_Sale_Price__c}, { field: ‘Packaging_Note__c’, value: this.Packagig_Note__c}, { field: ‘Part__r.Name’, value: this.Part__r.Name}, { field: ‘Line_Description__c’, value: this.Line_Description__c}, { field: ‘Line_Item_Num__c’, value: i}, i = i + 1, PreviousStepClicked = 1 ], doAppend: true }); }); } // We’re good to go - navigate our wizard to Step 2 step.navigate(‘step2’); Thank you
Question
Javascript Snippet works, but when previous step is clicked it doubles table entries
This topic has been closed for replies.
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.