Preview:
var = 0;
if(isBlank(input.Stock_Adjustment_No.trim()))
{
	var = 1;
	str = thisapp.Common.Number_Function_New("Stock Adjustment");
	input.Stock_Adjustment_No = str;
	openUrl("#Form:Alert_Messages?Status=" + "Adjusted" + "&Value=" + input.Stock_Adjustment_No + "&zc_LoadIn=dialog","same window");
}
for each  rec in input.Item_Details
{
	fet_inven = Inventory[Part_No == rec.Part_No && Location_Name == rec.Location_Name && Sub_Location == rec.Sub_Location && Rack_Number == rec.Rack_Number];
	getuom = Materials[ID == rec.Part_No].Primary_UoM;
	//if(fet_inven.Part_No == rec.Part_No)
	if(fet_inven.count() > 0)
	{
		// 		for each  fet in Inventory[Part_No == rec.Part_No]
		// 		{
		// 			if(fet.Part_Description == rec.Part_Name && fet.Location_Name == rec.Location_Name && fet.Sub_Location == rec.Sub_Location && fet.Rack_Number == rec.Rack_Number)
		//{
		fet_inven.Total_Qty=rec.New_Quantity_in_Hand;
		fet_inven.Available_Qty=rec.New_Quantity_in_Hand;
		//}
	}
	//}
	else
	{
		insert into Inventory
		[
			Added_User=zoho.loginuser
			Part_No=rec.Part_No
			Part_Description=rec.Part_Name
			Specification=rec.Specification
			Total_Qty=rec.New_Quantity_in_Hand
			Location_Name=rec.Location_Name
			Sub_Location=rec.Sub_Location
			Rack_Number=rec.Rack_Number
			Available_Qty=rec.New_Quantity_in_Hand
			Warehouse=input.Warehouse
			UOM=getuom
		]
	}
	thisapp.Stock_Ledger.Stock_Adj_Stockledger(input.ID);
}
//update the qty in Stock value also
for each  stkvalrec in input.Item_Details
{
	fetstkvalue = Stock_Value[Part_No == stkvalrec.Part_No && Stock_Qty > 0] sort by Added_Time desc;
	if(fetstkvalue.count() > 0)
	{
		fetstkvalue.Stock_Qty=stkvalrec.New_Quantity_in_Hand;
		fetstkvalue.Inventory_Qty=stkvalrec.New_Quantity_in_Hand;
		sendmail
		[
			from :"erp@carrierwheels.com"
			to :"parthasarathy.m@synprosoft.com"
			subject :"Stock Adjustment Created or Edited Successeful form submission " + stkvalrec.Part_No.Part_No + "adjqty " + stkvalrec.New_Quantity_in_Hand
			message :"Stock Adjustment Created or Edited Successeful form submission " + stkvalrec.Part_No.Part_No + "adjqty " + stkvalrec.New_Quantity_in_Hand
		]
	}
}
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter