Communicate stakeholders about an out-of-stock situation without manual intervention

Communicate stakeholders about an out-of-stock situation without manual intervention

Requirement  

When an item runs out of stock, send an automated email to the vendor, and alert the customer that the item is not available. Send an alert to the customer when the item gets restocked.

Use Case  

In an order or inventory management application, there are four forms. The Vendors form to track the vendors who supply for the business, the Customers form that holds the details of the customers using the business, the Products form to hold the inventory data, and the Orders form to place the order. Here, an order is placed for a higher quantity than the stock-at-hand. The following things are needed here :
  • Notifying and informing the customer that a lesser quantity of items is available and that will be delivered.
  • Notifying the vendor about this out-of-stock situation.
  • Notifying the customer when the product is restocked.
        See how it works

Steps to follow   

1. Create the forms with the following details :
Form  
Form Link Name
Field Name
Field Link Name
Field Type
Vendors
Vendors
Vendor Name
Vendor_Name
Name
Vendor Email
Vendor_Email
Email
Customers
Customers
Customer Name
Customer_Name
Name
Email
Customer_Email
Email
Address
Address
Address
Products
Products
Product Name
Product_Name
Single Line
Stock
Stock
Number
Vendor
Vendor
Lookup (Vendor)
Customers With Restock Request
Customers_With_Restock_Request
Customer Name
Customer
Lookup (Customer)
Product Name
Product
Lookup (Products)
Mailed
Mailed
Decision Box
Number Of Items Needed
Number_Of_Items_needed
Number
Orders
Orders
 
Customer Name
Customer
Lookup (Customers)
Order Details
  • Product Name
  • Quantity
  • Number of Items Needed
Order_Details
  • Product_Name
  • Quantity
  • Number_of_Items_Needed
Subform
  • Lookup (Products)
  • Number
  • Number

2.  Create a workflow that will be triggered every time the customer updates the Quantity field in the subform of the Orders form.

 
3. Click Add New Action and save the following deluge snippet in the deluge editor to calculate the number of items needed if the customer requested for more items:
  1. //set the value of the Number of Items Needed for the current subform row to be 0
  2. row.Number_Of_Items_Needed=0;
  3. //fetch the corresponding Products record based on the Product Name field in the subform
  4. product = Products[ID == row.Products];
  5. //Compare the value entered by the customer in the Quantity field with the Stock value of the chosen Product and calculate the number of items needed if the requested Quantity is less than the Stock
  6. if(row.Quantity > product.Stock)
  7. {
  8. //Alert if the Quantity value is reset to the available Stock value
  9.  alert "Sorry, we have only " + product.Stock + " items. We will add this to your cart now. We will notify when we get the stock from our vendor.";
  10.  row.Number_Of_Items_Needed=row.Quantity - product.Stock;
  11.  row.Quantity=product.Stock;
  12. }
  13. //Re-Calculate new total values
  14. row.Sub_Total=row.Quantity * row.Rate;
4.  Create another workflow  that will be triggered every time a record is added to  the  Orders  form (successful form submission).
 
5. Click Add New Action and save the following deluge snippet in the deluge editor to notify the stakeholders, Vendors and Customers based on the number of items:                  
For the benefit of understanding, the Deluge code is split into snippets. We explain the snippets and then arrange them appropriately for inserting them to the Deluge Editor.
Please check the attachments for a file with the following snippets consolidated into one working script.

Snippet a
 
The notification to the customers is based on the field value of the Number of Items Needed . Let us analyse it based on the value of this field. If the value is more than 0, a record is inserted into the Customers With Restock Request with the Number of Items Needed value.
  1. //Tracking the restock requesting customer details
  2. //Check if a request with same customer and product is already there
  3.   customers_with_restock_request = Customers_With_Restock_Request[Products == product.ID && Customer == input.Customer && Mailed == false].count();
  4.   if(customers_with_restock_request > 0)
  5.   {
  6. //The customer who had previously raised a request
  7.  customers_with_restock_request = Customers_With_Restock_Request[Products == product.ID && Customer == input.Customer && Mailed == false];
  8.  customers_with_restock_request.Number_Of_Items_needed=customers_with_restock_request.Number_Of_Items_needed - row.Number_Of_Items_Needed;
  9.   }
  10.   else
  11.   {
  12. //A New customer with restock request
  13.    insert into Customers_With_Restock_Request
  14.    [
  15.     Added_User=zoho.loginuser
  16.     Customer=input.Customer
  17.     Mailed=false
  18.     Number_Of_Items_needed=row.Number_Of_Items_Needed
  19.     Products=row.Products
  20.    ]
  21.   }

Snippet b
 
The  Vendor is e mailed highlighting this and Stock field of the corresponding Products record is set as 0.
  1. //Mail the Vendor
  2. sendmail
  3.   [
  4.    from :zoho.adminuserid
  5.    to :vendor.Email
  6.    subject :"Out Of Stock"
  7.    message :"<div><div>Hi, " + vendor.Vendor_Name + ",<br></div><div><br></div><div>Recently our product, " + product.Product_Name + " has gone out of stock. Kindly restock.<br></div><div><br></div><div>Thank you.<br></div><div><br></div></div><div><br></div>"
  8.   ]
  9. //Set the Stock field of the corresponding Products record to be 0
  10.  product.Stock=0;

Snippet c
 
If the customer's request is well under the Stock value of the Products record, we shall add the row and update the Stock value. Proactively, we mail the Vendor if the Stock becomes less than a threshold value, say, 50 items.
  1.   //Calculate new stock
  2.   product.Stock=product.Stock - row.Quantity;
  3. //Mail Vendors when numbers go less than 50
  4.   if(product.Stock <= 50)
  5.   {
  6.    sendmail
  7.    [
  8.     from :zoho.adminuserid
  9.     to :vendor.Email
  10.     subject :product.Product_Name + " is running out!"
  11.     message :"<div><div>Hi, " + vendor.Vendor_Name + ",<br></div><div><br></div><div>Recently our product, " + product.Product_Name + " is being most sought after, that we are running out of it. Only " + product.Stock + " remain! Kindly restock.<br></div><div><br></div><div>Thank you.<br></div><div><br></div></div><div><br></div>"
  12.    ]
  13.   }
 
Snippet d
 
Now, we shall combine Snippet a, Snippet b, and Snippet c; the snippets need to be  looped through the total number of rows inserted into the subform. The Products and the Vendor records are found fetched based on the value chosen in the subform row.
  1. //Assign the subform of the current record to a variable
  2. subform = input.Inline_Subform;
  3. for each row in subform
  4. {
  5.  //Fetch the relevant product
  6.  product = Products[ID == row.Products];
  7.  //Get the Vendor
  8.  vendor = product.Vendor;
  9. if(row.Number_Of_Items_Needed > 0)
  10. {
  11.   //Insert Snippet a & b
  12.  } 
  13.  else
  14. {
  15. //Insert Snippet c
  16. }
  17. }

6. Create a workflow on the  Product  form, on the successful form submission when a product record is edited.  
 

7. Click Add New Action and save the following deluge snippet in the deluge editor to e mail customers accordingly for the Stock field updated successfully:
  1.   //Assigning subject and message for sending email to the customers
  2. subject = "";
  3. message = "";
  4. if(input.Stock > 0)
  5. {
  6.  //This condition ensures that mailing is only for restocked
  7.  //Mail only those customers who asked for that product
  8.  for each  customer in Customers_With_Restock_Request[Products == input.ID && Mailed == false]
  9.  {
  10. //Check the customer restock request items is equal to the updated Stock and mail accordingly
  11.   if(customer.Number_Of_Items_needed <= input.Stock)
  12.   {
  13.    subject = input.Product_Name + " is now re-Stocked!";
  14.    message = "<div>Hello<br></div><div><br></div><div>" + input.Product_Name + " is now restocked with " + input.Stock + " items. Order now!</div>";
  15.   //Mark them as mailed to stop from spamming
  16.    customer.Mailed=true;
  17.   }
  18.   else
  19.   {
  20. //Mail when the number of restock items is less than what the customer had requested
  21.    subject = input.Product_Name + " is re-Stocked, but...";
  22.    message = "<div>Hello<br></div><div><br></div><div>" + input.Product_Name + " is now restocked with " + input.Stock + " items. We know you had asked for " + customer.Number_Of_Items_needed + " items. We were able to procure a lesser number. Sorry! We will notify when we get the remaining items!</div>";
  23.   }
  24.   sendmail
  25.   [
  26.    from :zoho.adminuserid
  27.    to :customer.Customer.Email
  28.    subject :subject
  29.    message :message
  30.   ]
  31. //Since the customer should be mailed again, Mailed is not updated
  32.  }

See how it works      





    Access your files securely from anywhere

      Zoho CRM Training Programs

      Learn how to use the best tools for sales force automation and better customer engagement from Zoho's implementation specialists.

      Zoho CRM Training
        Redefine the way you work
        with Zoho Workplace

          Zoho DataPrep Personalized Demo

          If you'd like a personalized walk-through of our data preparation tool, please request a demo and we'll be happy to show you how to get the best out of Zoho DataPrep.

          Zoho CRM Training

            Create, share, and deliver

            beautiful slides from anywhere.

            Get Started Now


              Zoho Sign now offers specialized one-on-one training for both administrators and developers.

              BOOK A SESSION









                                            You are currently viewing the help pages of Qntrl’s earlier version. Click here to view our latest version—Qntrl 3.0's help articles.




                                                Manage your brands on social media

                                                  Zoho Desk Resources

                                                  • Desk Community Learning Series


                                                  • Digest


                                                  • Functions


                                                  • Meetups


                                                  • Kbase


                                                  • Resources


                                                  • Glossary


                                                  • Desk Marketplace


                                                  • MVP Corner


                                                  • Word of the Day


                                                    Zoho Marketing Automation

                                                      Zoho Sheet Resources

                                                       

                                                          Zoho Forms Resources


                                                            Secure your business
                                                            communication with Zoho Mail


                                                            Mail on the move with
                                                            Zoho Mail mobile application

                                                              Stay on top of your schedule
                                                              at all times


                                                              Carry your calendar with you
                                                              Anytime, anywhere




                                                                    Zoho Sign Resources

                                                                      Sign, Paperless!

                                                                      Sign and send business documents on the go!

                                                                      Get Started Now




                                                                              Zoho TeamInbox Resources



                                                                                      Zoho DataPrep Resources



                                                                                        Zoho DataPrep Demo

                                                                                        Get a personalized demo or POC

                                                                                        REGISTER NOW


                                                                                          Design. Discuss. Deliver.

                                                                                          Create visually engaging stories with Zoho Show.

                                                                                          Get Started Now









                                                                                                              • Related Articles

                                                                                                              • Display subform's report in parent form's report

                                                                                                                Requirement   When the user views a particular record in a report that has subform, the values in the corresponding records are also shown. Use Case   An order management application contains two forms: Customers and Orders. The Customer s form is ...
                                                                                                              • Auto-calculating values on a subform's field

                                                                                                                Requirement Perform statistical operations on the numerical fields in subforms for analysis. Use Case  In an order management application, there are two forms, Order and Product. The Product form lists all the products in the inventory and the Order ...
                                                                                                              • Rent calculation based on multiple values selected by customers for events

                                                                                                                Requirement Estimate rent for a property based on the date and time it is booked, as well as attendance numbers. Use Case A party hall of a hotel is being rented out. Here is the pricing structure of the hall: Day Base price (in USD) Standard guests ...
                                                                                                              • Automatically create daily reports and send current day's reports as email attachment

                                                                                                                Requirement Schedule custom actions to automatically create labour reports everyday at the specified time and send a filtered report of all the reports corresponding to the current day as an email attachment. Use case Let's assume your company has ...
                                                                                                              • Create Serial Number for subform rows

                                                                                                                Requirement Create serial numbers or auto-numbers for subform rows when a new row is added. Use Case In an employee management system, an employee can add up to five dependents. It will be easy for the employees if the dependents added in the subform ...
                                                                                                                Wherever you are is as good as
                                                                                                                your workplace

                                                                                                                  Resources

                                                                                                                  Videos

                                                                                                                  Watch comprehensive videos on features and other important topics that will help you master Zoho CRM.



                                                                                                                  eBooks

                                                                                                                  Download free eBooks and access a range of topics to get deeper insight on successfully using Zoho CRM.



                                                                                                                  Webinars

                                                                                                                  Sign up for our webinars and learn the Zoho CRM basics, from customization to sales force automation and more.



                                                                                                                  CRM Tips

                                                                                                                  Make the most of Zoho CRM with these useful tips.



                                                                                                                    Zoho Show Resources