Updating Sales Order "Ordered Items" values with Quotes "Quoted Items" via custom function

Updating Sales Order "Ordered Items" values with Quotes "Quoted Items" via custom function

Hi! 

I'm updating a custom function that populates the Sales Order fields with values from the Quotes module. I'm trying to add a conditional statement that, when a certain field is X value i also bring all Products inside the Quote to the Sales Order. 

So far i have been succesfull, the conditional statement works and i'm able to get values from the Quote. The issue starts when i update the Sales Order module, only the "Total" field is updated, but the unit price does not update. How come i can have a total without a price?

I have attached prints from one example containing the Quotes module products and one after i ran the code in the respective Sales Order.

The section from the code is the following:

  1. salesorder = zoho.crm.getRecordById("Sales_Orders",SalesOrderID);
    prodetails = salesorder.get("Product_Details").toList();
    proidList = List();
    for each  prodetail in prodetails
    {
    proid = prodetail.get("id").toLong();
    proidList.add(proid);
    }
  2. quote = ifnull(salesorder.get("Quote_Name"),"");
    quoteID = if(quote != "",quote.getJSON("id"),0);
    mapa_atualiza = Map();
    if(cInvoice == "Partner")
    {
    quote_info = invokeurl
    [
    type :GET
    connection:"my_connection" 
    ];
    quoted_customs = quote_info.get("data").get(0);
    quoted_items = quoted_customs.get("Quoted_Items");
    itemsList = List();
    for each  quoted_item in quoted_items
    {
    itemsMap = Map();
    // itemsMap.put("list_price",quoted_item.get("Unit_Price1"));
    itemsMap.put("Price",quoted_item.get("Unit_Price1"));
    itemsMap.put("quantity",quoted_item.get("Quantity"));
    itemsMap.put("Net_Total",quoted_item.get("Total_CLM"));
    index = itemsList.size();
    // Get the current index
    if(index < proidList.size())
    {
    itemsMap.put("id",proidList.get(index));
    }
    else
    {
    itemsMap.put("id",null);
    // Or set a default value
    }
    itemsList.add(itemsMap);
    }
    mapa_atualiza.put("Product_Details",itemsList);
    }
  3. mapa_atualiza.put("Status","Draft");
    //info mapa_atualiza;
    atualiza = zoho.crm.updateRecord("Sales_Orders",SalesOrderID,mapa_atualiza,{"trigger":{"workflow":true}});
    //info atualiza;

Can you guys help me with a possible solution to this problem? Am i missing something?

Thank you!