Automatically calculating pricing
Hello Zoho Community,
I am trying to automate the process of updating a currency field with a product's price based on selections made in three different lookup fields in Zoho Creator. However, the workflow doesn’t seem to be working as expected, and I'm not seeing any logs being generated, which makes troubleshooting difficult.
Here’s the script I’m currently using:
- info "Script started";
- // Fetch the values of the lookup fields
- standard_coffin_range = input.Standard_Coffin_Range;
- return_to_sender_coffin_range = input.Return_To_Sender_Coffin_Range;
- casket_range = input.Casket_Range;
- // Initialize the price variable
- price = 0.0;
- // Mapping coffin names to their prices
- coffin_prices = Map();
- coffin_prices.put("WAYFARER",2995.00);
- // Return to Sender
- coffin_prices.put("FERNWOOD",2495.00);
- // Return to Sender
- coffin_prices.put("ARTISAN",3995.00);
- // Return to Sender
- coffin_prices.put("ARCHETYPE BEECH",3995.00);
- // Return to Sender
- coffin_prices.put("CAMPHOR LAUREL",4295.00);
- // Standard
- coffin_prices.put("BLACKWOOD",4295.00);
- // Standard
- coffin_prices.put("KARRAGARRA",2995.00);
- // Standard
- coffin_prices.put("LAWSON",3495.00);
- // Standard
- coffin_prices.put("COOCHIEMUDLO",2995.00);
- // Standard
- coffin_prices.put("PEEL",2995.00);
- // Standard
- coffin_prices.put("NATURE",2395.00);
- // Standard
- coffin_prices.put("KING",2995.00);
- // Standard
- coffin_prices.put("PEARL",3395.00);
- // Standard
- coffin_prices.put("SANDGATE",2495.00);
- // Standard
- coffin_prices.put("AMITY ROSE",2995.00);
- // Standard
- coffin_prices.put("STRADBROKE",2495.00);
- // Standard
- coffin_prices.put("MORETON",2295.00);
- // Standard
- coffin_prices.put("AMITY WHITE",2995.00);
- // Standard
- coffin_prices.put("BURLEIGH",2995.00);
- // Standard
- coffin_prices.put("FLINDERS",2595.00);
- // Standard
- coffin_prices.put("MACLEAY",1995.00);
- // Standard
- coffin_prices.put("DUNWICH",1595.00);
- // Standard
- coffin_prices.put("RUSSELL",1395.00);
- // Standard
- coffin_prices.put("LAMB",1195.00);
- // Standard
- coffin_prices.put("GOLDEN JEWEL METAL CASKET",4995.00);
- // Casket
- coffin_prices.put("DIPLOMAT STAINLESS STEEL CASKET",5995.00);
- // Casket
- coffin_prices.put("MONARCH METAL CASKET",6995.00);
- // Casket
- coffin_prices.put("HARMONY METAL CASKET",7995.00);
- // Casket
- coffin_prices.put("ONYX METAL CASKET",8995.00);
- // Casket
- coffin_prices.put("ROSETTA METAL CASKET",9995.00);
- // Casket
- coffin_prices.put("SILVER JEWEL METAL CASKET",10995.00);
- // Casket
- // Check which lookup field has a value and fetch the corresponding price
- if(standard_coffin_range != null)
- {
- price = coffin_prices.get(standard_coffin_range.toUpperCase());
- info "Price set from Standard Coffin Range: " + price;
- }
- else if(return_to_sender_coffin_range != null)
- {
- price = coffin_prices.get(return_to_sender_coffin_range.toUpperCase());
- info "Price set from Return To Sender Coffin Range: " + price;
- }
- else if(casket_range != null)
- {
- price = coffin_prices.get(casket_range.toUpperCase());
- info "Price set from Casket Range: " + price;
- }
- // Set the Coffin/Casket Fee (inc GST) field with the fetched price
- input.Coffin_Casket_Fee_inc_GST = price;
- info "Final Price set: " + price;
Issues I'm Facing:
- Workflow Not Logging: Despite adding
info
statements, nothing appears in the logs, which makes it difficult to troubleshoot. - No Price Update: The currency field (
Coffin_Casket_Fee_inc_GST
) is not being updated with the price based on the lookup field selections.
What I’ve Checked:
- The field link names are correct.
- The workflow is supposed to trigger on user input for the lookup fields.
- I’ve verified that the
map
contains the correct price values.
Questions:
- Is there something I'm missing in the script that could cause the workflow to not trigger?
- Could the currency field type be causing issues with setting the price?
Any guidance or suggestions on how to resolve this issue would be greatly appreciated.
Thank you in advance!
Access your files securely from anywhere
Zoho Developer Community
Deliver unforgettable customer experiences
Deliver unforgettable customer experiences
New to Zoho Marketing Plus?
Everything you need to run your marketing
New to Zoho Marketing Plus?
Everything you need to run your marketing
Zoho Desk Resources
-
Desk Community Learning Series
-
-
-
-
-
-
-
-
-
Zoho TeamInbox Resources
Zoho DataPrep Resources
Zoho CRM Plus Resources
Zoho Books Resources
Zoho Subscriptions Resources
Zoho Projects Resources
Zoho Sprints Resources
Qntrl Resources
Zoho Creator Resources
Zoho Campaigns Resources
Zoho CRM Resources
Zoho Show Resources
Writer Get Started. Write Away!
Writer is a powerful online word processor, designed for collaborative work.