Created
June 11, 2014 20:59
-
-
Save smcllns/b2aef40f2a64ec683b6b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{!REQUIRESCRIPT("/soap/ajax/13.0/connection.js")} | |
var q1 = sforce.connection.query("SELECT Id, Name, PBSI__Item__r.Id, PBSI__Total_Quantity__c FROM PBSI__Lot__c where PBSI__Item__r.Name ='" + item + "' AND PBSI__Total_Quantity__c > 0.1"); | |
var lots = q1.getArray("records"); | |
var inserts = [] | |
for (var i=0; i<lots.length; i++) { | |
var newLine = new sforce.SObject("PBSI__Count_Line__c"); | |
newLine.PBSI__Count_Journal__c = '{!PBSI__Count_Journal__c.Id}'; | |
newLine.PBSI__Item__c = lots[i].PBSI__Item__r.Id; | |
newLine.PBSI__Lot__c = lots[i].Id; | |
newLine.PBSI__Quantity_In_Inventory__c = Math.abs(parseFloat(lots[i].PBSI__Total_Quantity__c).toFixed(2)); | |
inserts.push(newLine) | |
} | |
var result=sforce.connection.create(inserts); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment