We are trying to create a Zoho Custom Function using Deluge script in Zoho Inventory. The script is as follows:
// Initialize pagination variables
page = 1;
has_more_records = true;
while (has_more_records) // Correct structure of while loop
{
// Fetch items in batches of 200 (maximum limit per API call)
response = zoho.inventory.getRecords("Items", page, 200);
if (response.containKey("items")) // Ensure response contains items
{
items = response.get("items");
for each item in items // Loop through each item
{
stock_level = item.get("quantity");
reorder_point = item.get("reorder_point");
// Check if stock level is below the reorder point
if (stock_level < reorder_point)
{
message = "Stock for item " + item.get("name") + " is below the reorder point. Current stock level: " + stock_level;
// Send email notification
sendmail
[
from : zoho.adminuserid // Ensure no syntax errors in sendmail block
to : "[email protected]"
subject : "Reorder Notification"
message : message
];
}
}
// Check if there are more records to fetch
has_more_records = response.get("has_more_page");
page = page + 1;
}
else
{
has_more_records = false;
}}
But persistently I am getting the following error:
Check and update the code in line 5, position 23 as there is a Exception : Syntax error. Expecting ';'. Found '{'.
Clearly there is no scope for a ; here in the structure of a while loop. Please guide me regarding the resolution.