Add Item Rate and Item Quantity to Custom Function

Add Item Rate and Item Quantity to Custom Function

Hi Team - I have a custom function that fetches a product from an invoice and displays it in a related list in the Accounts module.

We need to get the item rate and item quantity of the product for that invoice. I tried to do it myself but I am note getting it. Here is the code. Can you tell me what line of code to add to fetch the item rate and item quantity?

Thanks in advance for any assistance.


invoiceID = invoice.get("invoice_id");
customerid = invoice.get("customer_id");
customername = invoice.get("customer_name");
organizationID = organization.get("organization_id");
//get the account ID of the customer
resp = zoho.books.getRecordsByID("Contacts",organizationID,customerid);
account_id = resp.get("contact").get("zcrm_account_id");
//Loop to get the number of items in a single receipt 
x = 0;
itemslist = invoice.get("line_items");
for each  items in itemslist
{
itemname = items.get("name");
info "THE ITEM TO BE COMPARED WITH";
info customername;
info itemname;
productid_search = zoho.crm.searchRecords("Products","(Product_Name:equals:" + itemname + ")");
production = productid_search.get(0);
productid = production.get("id");
info productid;
x = x + 1;
info x;
productlist = zoho.crm.searchRecords("Accounts_X_Products","(Customer:equals:" + customername + ")");
havethesameitem = 0;
for each  products in productlist
{
product = products.get("Products").get("name");
info product;
if(product == itemname)
{
havethesameitem = havethesameitem + 1;
}
}
//======
info havethesameitem;
if(havethesameitem <= 0)
{
paramap = Map();
paramap.put("Products",productid);
paramap.put("Customer",account_id);
resp = zoho.crm.createRecord("Accounts_X_Products",paramap);
info resp;
}
}