I am using the below code to fetch all CRM 'PurchaseOrders' records from a specified CRM 'Potential' and then insert them as SubRow items "On Success"
At the moment they are inserted in their default order, however I need them to be saved in a custom date order (Start Date).
What is the easiest way to sort the fetched record for inserting in the SubForm?
- var1 = input.ID;
- //pull data from CRM based on Potential id
- srch = zoho.crm.searchRecordsByPDC("PurchaseOrders", "Potential Name_ID", input.Bookid);
- //for each index in data retrieved, allocate the field to variable and then insert the variables into as new subform record and associated with the main form using ID
- for each index res in srch
- {
- vend = srch.get(res);
- vend_name = vend.get("Vendor Name");
- start_date = vend.get("Start Date");
- vend_id = vend.get("VENDORID");
- vend_id_bigint = vend_id.toLong();
- Vendor_Details = zoho.crm.getRecordById("Vendors", vend_id_bigint);
- vend_directions = Vendor_Details.get("Directions");
- insert into SubForm
- [
- Added_User = zoho.loginuser
- Master_look = var1
- Name = vend_name
- id = vend_id
- directions = vend_directions
- Date_field = start_date
- ]
- }
Many thanks