Creating roll ups on custom_fields

Creating roll ups on custom_fields

portalId = 60XXXXXX;
// projectId = 19063XXXXXXX;
// taskid = 19063XXXXXXX;
response = zoho.projects.getRecordById(portalId,projectId,"tasks",taskid,"bs");
// info response;
tasks = response.get("tasks").get(0);
info tasks.get("id");
p_task_id = tasks.get("parent_task_id");
info "task_parent" + p_task_id;
custom_fields = tasks.get("custom_fields");
for each  custom_field in custom_fields
{
if(custom_field.get("label_name") == "Actual_Cost")
{
task_amount_act = ifnull(custom_field.get("value").toDecimal(),0);
// Convert value to decimal
// actual_cost_l1 = actual_cost_l1 + task_actual_cost;
info "task_amount_act >>" + task_amount_act;
}
}
p_task_res = zoho.projects.getRecordById(portalId,projectId,"tasks",p_task_id,"bs");
tasks_p = p_task_res.get("tasks").get(0);
tasks_p_id = tasks_p.get("id");
info "P_t_id :" + tasks_p_id;
custom_fields_p = tasks_p.get("custom_fields");
for each  custom_field in custom_fields_p
{
if(custom_field.get("label_name") == "Actual_Cost")
{
task_actual_cost = ifnull(custom_field.get("value").toDecimal(),0);
// Convert value to decimal
// actual_cost_l1 = actual_cost_l1 + task_actual_cost;
info "task_actual_cost >>" + task_actual_cost;
}
}
total_sum_st_l1 = task_actual_cost + task_amount_act;
total_sum_dis = total_sum_st_l1.toLong();
info "total_sum_st_l1>>" + total_sum_dis;
task_details = Map();
ts = Map();
ts.put("UDF_LONG10",total_sum_dis);
task_details.put("custom_fields",ts);
res = zoho.projects.update(portalId,projectId,"tasks",tasks_p_id,task_details,"bs");
info "res >>" + res;
return "";

This script is designed to aggregate the value of a custom field (e.g., "Actual Cost") from a subtask and add it to the corresponding custom field of its parent task. The workflow can be extended by implementing a rule that triggers this script whenever the subtask's custom field is updated.

Key Considerations:

  • Single Update Application: This script is intended for scenarios where the custom field value is updated once. If the field is subject to frequent updates, additional logic may be required to ensure accurate aggregation.
  • Custom Field Handling: When updating values in custom fields, it is crucial to verify the field type and format the input accordingly. You can determine the field type by inspecting the task's page.

Code Workflow:

  1. Retrieve Subtask Details:

    • Fetches the subtask details using getRecordById.
    • Extracts the custom field value for "Actual Cost."
  2. Retrieve Parent Task Details:

    • Fetches the parent task details using getRecordById.
    • Extracts the custom field value for "Actual Cost."
  3. Calculate Total Cost:

    • Sums the "Actual Cost" values from the subtask and the parent task.
  4. Update Parent Task:

    • Updates the parent task's custom field with the aggregated cost.

This script provides a foundational approach, allowing you to tailor the logic according to your specific requirements.

    • Sticky Posts

    • Tip of the Week: Task Sorting

      I believe that sorting of tasks helps managing the activities in a better fashion. You might second it too . By default, the tasks are listed chronologically. However, you can sort the tasks either by its title, start date, end date, priority, created by and percentage completion. All you have to do is, click the Task Sorting option and select the required criteria. Few points to be noted about task sorting: This option is available in the Classic View only (within My Tasks, Tasks & Milestones section).
    • Tip # 3 - Follow And Add Followers To Your Project Modules

      Besides owning effective managers and quick-witted employees, you need to have supportive followers for accomplishing your project goals. Accompanying this note, today, lets run through a quick and easy tip on  'How to follow and add followers to your project activities?' . Follow the project activities all by yourself -Follow to get real-time milestone updates Milestones are nothing but your project goals, which can ultimately uplift your projects' quality to the next level. Now, users in the portal
    • Tip of the Week: Task Dependency (Duration in Hours)

      I hope the tip on task dependency helped in understanding how it works in Zoho Projects. In a real-time, the successor task may or may not start on the predecessor's completion date. On either case, a project management tool should allow the users to set dependency between tasks. Ain't it? In Zoho Projects, the Task Duration in Hours option allows the users to set dependency between tasks that ends and starts on the same day. The Portal Owner and Admin role users can activate this option from the
    • Tip of the Week: Task Dependency

      Task Dependency - a feature that allows the users to establish dependency / linking between tasks within the project. Points to be noted with respect to this feature: Task Dependency can be set only from the Dependency View section within the Tasks & Milestones module Tasks setup with duration (start & end date) will only be displayed in the Dependency View The supported dependency model is Finish to Start Dependency can be established only between the tasks in the same project A task can be dependent
    • Tip of the Week: Drag and Drop option in Calendar

      As the thoughts flow in your mind, you plan the tasks, provide duration and assign users. While you go through the calendar later, you feel that a couple of tasks should needs to be postponed by a couple of days. Do you navigate to the Tasks & Milestones section and change the task duration? is the question I have for you. In case of YES, I would say that the task duration can be changed from the Calendar module itself. All you need to do is: Drag the task bar and Drop it on the required date. Note:
    • Recent Topics

    • Ticket to article and Ticket to template

      Hello! I would like to know if it is possible (and how) to do the following actions: 1. To generate an article from a ticket (reply + original message) 2. Easy convert an answer to an email template
    • Create an article template

      I have a question concern the Knolwedge Database from Zoho Desk. There is any possibility to create an article template ? Exemple of what I research : TODAY : I want to create a lot af articles with the same baseline > I create one article > I copy/paste
    • Persisting email signals to contact timeline?

      Hello there. Regarding the email signals that are logged when a contact opens an email, am I correct that these signals are not logged to a contact's timeline? Ideally, I would like to have this context available for future follow-ups, if the contact
    • Add Attachment Support to Zoho Flow Mailhook / Email Trigger Module

      Dear Zoho Support Team, We hope you are well. We would like to kindly request a feature enhancement for the Mailhook module in Zoho Flow. Currently, the email trigger in Zoho Flow provides access to the message body, subject, from address, and to address,
    • FOLDER DISAPPEARED

      Hello Zoho Community. I recently found a problem with no explanation: a folder in Zoho Analytics just disappeared, but the tables and SQL sentences still existed, the folder was not deleted. The solution for me in this case was to create a new folder,
    • Unified WhatsApp Number Management in Zoho Desk and SalesIQ

      Dear Zoho Desk Support Team, We are currently utilizing both Zoho Desk and Zoho SalesIQ for our customer support operations. While both platforms offer WhatsApp integration, we are facing challenges due to the requirement of separate WhatsApp numbers
    • Change of Blog Author

      Hi, I am creating the blog post on behalf of my colleague. When I publish the post, it is showing my name as author of the post which is not intended and needs to be changed to my colleague's name. How can I change the name of the author in the blogs?? Thanks, Ramanan
    • Zoho FSM API Delete Record

      Hi FSM Team, It would be great if you could delete a record via API. Thank you,
    • How create a draft via workflow?

      I wish to create a workflow rule for specific emails that creates a draft response - not an automatic email reply, but just a draft with a set response ready to be verified by an agent who can then manually select recipients. Alternatively, the workflow
    • Instant Messaging Update | Now migrate your WhatsApp Business phonenumber from another BSP to Zoho Desk | Dec'23

      Hi All, Everything seems to move at lightning speed these days, and time is certainly flying by for the IM team. But we are delighted at how much ground we covered this year. 🚀 For one, we enabled WhatsApp business phone number migration so that you
    • CRM x WorkDrive: File storage for new CRM signups is now powered by WorkDrive

      Availability Editions: All DCs: All Release plan: Released for new signups in all DCs. It will be enabled for existing users in a phased manner in the upcoming months. Help documentation: Documents in Zoho CRM Manage folders in Documents tab Manage files
    • Upload ticket attachments via Drag-&-Drop

      Hello, if you want to upload a file to the ticket attachment you need to click the button and use the file browser to select and upload the desired file. In many cases, it would be much more efficient if you could simply drag the file to the browser window...
    • Can we disable add to cart in Zoho Commerce?

      Hello, Our sales happen on the phone. During the call the customer is directed to our website to inspect the products together with the sales rep. So we need a way to present our inventory. I figured Zoho Commerce is a good fit for this use case. However
    • Introducing WhatsApp integration in Bigin

      Greetings! In today's business landscape, messaging apps play a significant role in customer operations. Customers can engage with businesses, seek support, ask questions, receive personalized recommendations, read reviews, and even make purchases—all
    • Issues with Zoho Sheet in Mac

      I have downloaded the Zoho App from App Store but It is failing to Save As, Open & Download Operations. App Store
    • Ability to re-order Workflow Rules

      We really need the ability to re-order workflow rules within departments.  Either the ability to drag/drop them into a different order or something.
    • Zoho One account closure vs deactivation

      I wonder what are the best practices and guidelines around deactivating vs deleting Zoho accounts in organisations? Any practical considerations?
    • Global Search placement in the new UI

      Having a hard time with the global search placement in the UI redesign. Surely I can't be the only one. Previously global search placement was perfect. A bar at the top/center of the page. Exactly where you would expect it to be. Since the new UI has
    • Cliq iOS can't see shared screen

      Hello, I had this morning a video call with a colleague. She is using Cliq Desktop MacOS and wanted to share her screen with me. I'm on iPad. I noticed, while she shared her screen, I could only see her video, but not the shared screen... Does Cliq iOS is able to display shared screen, or is it somewhere else to be found ? Regards
    • Can I re-send the Customer Satisfaction Survey after a ticket closure?

      Hello, Some customers does not answer the survey right after closure, is it possible to re-send after a few days or weeks? Best Regards!
    • CRM gets location smart with the all new Map View: visualize records, locate records within any radius, and more

      Hello all, We've introduced a new way to work with location data in Zoho CRM: the Map View. Instead of scrolling through endless lists, your records now appear as pins on a map. Built on top of the all-new address field and powered by Mappls (MapMyIndia),
    • Schedule Zoho CRM reports only on Business Days

      Hello, Is it possible to schedule reports only on business days ? We currently get daily sales reports on weekend which has no value since the sales team doesn't work on weekends. Thanks
    • Missing the "Find & Merge Duplicates" choice

      Hi, I am missing the "Find & Merge Duplicates" choice. I looked under the "More Actions" menu in Contacts, Accounts, Vendors, and Leads and it is not there.  I have full permissions.  Please assist me on finding this feature. Thanks!
    • How to install Widget in inventory module

      Hi, I am trying to install a app into Sales Order Module related list, however there is no button allow me to do that. May I ask how to install widget to inventory module related list?
    • Improved Contact Sync flow in Google Integration with Zoho CRM

      Hello Everyone, Your contact sync in Google integration just got revamped! We have redesigned the sync process to give users more control over what data flows into Google and ensure that this data flows effortlessly between Zoho CRM and Google. With this
    • Cannot see Application from Lookup field

      Hi all, I am trying to access data for an application on our account via a lookup field; however, the application doesn't appear in the dropdown at all. Can anyone shed any light on this, please? I have asked Zoho support; however, they're just as confused,
    • Sharing URLs and direct access

      Hello, I am storing my team's email signature images on Workdrive. I am creating a public image download share and adding “?directDownload=true” so that the image can be accessed without the Workdrive interface. A few questions: 1) Can we generate friendly
    • Deluge Error Code 1002 - "Resource does not exist."

      I am using the following script in a Custom Button on a Sales Return. Basically, the function takes the information in the sales return (plus the arguments that are entered by the user when the button is pushed) and creates a return shipping label via
    • How to track a contact or customer's past product purchases in Bigin Premiere?

      Hello there. I am the sole user of Bigin for a small company (chess club), and would like to track current and past purchases made by a contact (player) or company (family which includes the player). Players may register for multiple tournaments, take
    • LENTITUD EN RECIBIR MAIL

      Buenas tardes, Estamos experimentando lentitud en la recepción de correos electrónicos.
    • Items should display under specific warehouse

      I have configured the multi warehouse but it show all the items under all warehouse which is not correct according to our business logic, so i want that items should only display under that specific warehouse not under all the warehouses not even with zero quantity. Some items should be common but not all so is there any option for that purpose so i can specific the items to its warehouse. Regards
    • Tracking Non-Inventory Items

      We have several business locations and currently use zoho inventory to track retail items (sales and purchase orders). We were hoping to use zoho inventory to track our non-inventory items as well (toilet paper, paper towels, etc). I understand that we
    • Partial refunds

      I am trying to process refund for a one item invoice, however the refund is partial: i am getting this error while creating credit note, can anyone share some wisdom about this
    • Best practice importing items and matching assemblies

      Hi, I was wondering what would be the best practice to import items and composite items (assemblies) From my backup, what should I import first? The items or the composite items? I am on Zoho one, using inventory and books. Kind regards, Sabine
    • Bulk Fill In & Edit PO/Bill/SO/Invoice

      Hello, I am adding stock in bulk on a PO, the system is automatically populating the Rate (price) and Tax from the item data. Problem is that the bill rate is different from the rate on the item data, so I have to manually erase each and enter the price.
    • Separate Items & Services

      Hi, please separate items and services into different categories. Thank you
    • Items Below Reorder Point Report?

      Is there a way to run a report of Items that are below the Reorder Point? I don't see this as a specific report, nor can I figure out how to customize any of the other stock reports to give me this information. Please tell me I'm missing something s
    • Zoho CRM for Everyone's NextGen UI Gets an Upgrade

      Hello Everyone We've made improvements to Zoho CRM for Everyone's Nextgen UI. These changes are the result of valuable feedback from you where we’ve focused on improving usability, providing wider screen space, and making navigation smoother so everything
    • Allocating inventory to specific SO's

      Is there a way that allocate inventory to a specific sales order? For example, let's say we have 90 items in stock. Customer 1 orders 100 items. This allocates all 90 items to their order, and they have a back order for the remaining 10 items which could
    • Cancelled Transfer order problem

      Hello, We've canceled a transfer order, and we can't add the related items to a new Transfer Order. The system tells us that the bin doesn't have the required quantity, but when we check the item, it indicates that there are 2 units in the bin. It also
    • Next Page