JavaScript help : Updating two models with info from each

Hoping someone can help me with JavaScript. Thank you in advanced for any help fixing the script.

Use Case:
I have two models that I am trying to update. I have a table of sublines and a table of inventory. I want to link the sublines to inventory and inventory to the sublines.

The user selects lines from the subline table and clicks a button that kicks off a snippet. The snippet should run through each subline and associate it with an inventory position.

Problem:
The problem is only the first inventory position gets updated and all the sublines get updated with the same inventory position. (See Screen Shot)

Snippet:

var params = arguments[0],
$ = skuid.$; var models = skuid.model.map(); var AllocateBOMSubLine = models.AllocateSublines; var BOMInventory = models.InventoryPositions; var InvRow = BOMInventory.getFirstRow(); $.each(AllocateBOMSubLine.data,function(){ //Update Invnetory if(this.Inventory_Position__c === undefined && this.Status__c === ‘In Process’){ BOMInventory.updateRow( { Id: InvRow.Id }, { SCMC__Availability__c : false, SCMC__Quantity__c: 0, BOM_Run_Sublines__c: this.Id, } ); //Update BOM Subline AllocateBOMSubLine.updateRow( {Id: this.Id}, { Inventory_Position__c : InvRow.Id, } ); } });

Screenshot:

Maybe I can help, but it’s somewhat hard to understand without seeing code in action. GTM?

Hey Pat! Sure do you have an ID?

https://global.gotomeeting.com/join/565826373

I am getting an invalid meeting id error.

Got it working?

Haven’t had a chance to get back to it. Other projects took priority. Thanks again for your help!