Kaizen #129 : Client Script Support for Blueprints

Kaizen #129 : Client Script Support for Blueprints

Hello everyone!

Welcome to another week of Kaizen. Today, let us discuss about how you can use Client Script during a Blueprint transtion to meet your requirements. This Kaizen post will provide solution for the post - Need non-mandatory fields in blueprint pop-up using Client Script.


In this Kaizen post,
  1. What is a Blueprint?
  2. Blueprint event in Client Script
  3. ZDKs and methods available in Client Script related to Blueprint
  4. Use Case - During a blueprint transition, show a pop up with fields that are not mandatory
  5. Solution
  6. Summary
  7. Related Links
  8. Kaizen Collection


1. What is a Blueprint?

Blueprint is an online replica of a business process. For instance, leads generation and follow-up, deals closure and order management. Each of these processes has several stages, and different teams may be responsible to complete each stage. At this point, one needs to take a moment to see if the CRM dictates how these processes should be executed. It captures every detail of your entire offline process within the software. Click here to know more about Blueprint in Zoho CRM.

Moving from one stage of a blueprint to the next stage  is called as Blueprint transition.

2. Blueprint event in Client Script

Whenever you want to meet your custom requirements in Zoho CRM before a Blueprint transition happens, you can use the beforeTransition event type available in Client Script. This event occurs before the transitions occur, as per the process flow designed in the Blueprint. You can add the "return false" statement at the end of the script to prevent the blueprint transition. Click here to know more about the events in Client Script.

3. ZDKs and methods available in Client Script related to Blueprint

Here is the list of ZDKs and methods using which you can code in Client Script.

ZDK.Page.getBlueprintTransitionByID()    -       You can get the blueprint transition by id.

ZDK.Page.getBlueprintTransitions().          -       You can get all the blueprint transitions in page.

getId()                                                            -       You can get the id of transition using Blueprint transition object.

getName()                                                     -        Get the name of transition using Blueprint transition object.

initiate()                                                         -        Initiate the transition using Blueprint transition object.


Click here to view the detailed documentation of ZDKs and methods related to Blueprint in Client Script.

4. Use Case

Zylker is a manufacturing organisation which uses Blueprint to manage the various updates in the status of Leads. Below is the blueprint configuration. For the transition "Gather details", the field  "Alternate Number" will be prompted as mandatory. Without entering this detail, the transition cannot proceed.



This is the existing Blueprint.
Now, the Admin wants to prompt the user to enter a value for the Alternate Number, but it should not be mandatory for the transition "Gather Details".

4. Solution

Currently in Blueprint the fields in the pop-up are mandatory. You can achieve non-mandatory fields in a pop-up using Client Script and update the values to that record. However you should not add the fields in the "During" phase of the "Gather Details" transition in Blueprint, to achieve this non-mandatory pop-up using Client Script. This solution will work for the requirement raised in this post.

For this,  you need to create a Client Script and use the "Before Transition" type of "Blueprint" Event.  



For more details on how to configure a Client Script, click here. Once you give the module and event details, you can see the Client Script IDE's Editor.



The argument "transition" will hold the the details of current Blueprint transition.

In the Client Script IDE, type the below script and click Save.

 if (transition.name == 'Gather details') {
// To show pop up and get the Alternate Number and update the 
//record's Alternate Number 
var var_alt = ZDK.Client.getInput([{ type: 'text', label: Alternate Number}], 'Give these details', 'OK', 'Cancel');

    if (var_alt != null) {

        var lead = ZDK.Apps.CRM.Leads.fetchById($Page.record_id);
        lead.alternate_number = var_phone.toString();
        var response = lead.__update();
    }

    else {

        ZDK.Client.showMessage('Details have been gathered successfully' });

    }

 
   $Client.refresh();// to refresh the page

}

The above script will get executed before every transition happens in the Blueprint. So, in the script, the code is added based on the transition name. As per the requirement, when the transition name is "Gather details" , you can show the pop-up through Client Script's getInput() function. Once you capture this value you can update the alternate number using the CRM API ZDKs. $Page.record_id will return the id of the current Lead record.

Here is how the Client Script works.



You can see that the transition happens even after the "Alternate Number" field is not filled by the user.


Note : 

1.  If you want to prevent a Blueprint Transition you need to add "return false" statement in the Script.      

2.  The blueprint event and the related ZDKs are  available only for Detail(Standard) Page and Detail(Canvas) Page
5. Summary

In this post, we have discussed,
  • About Blueprint events in Client Script.
  • The ZDKs and methods related to Blueprint.
  • How to configure a Client Script to trigger before a Blueprint transition
  • How to open a non - mandatory fields pop up before a blueprint transition
  • How to update current record using Update Records API through Client Script
  • How to refresh a page using Client Script
  • How to prevent a Blueprint Transition
6. Related Links
Kaizen Collection : 


Cheers!
Maadhari M








      Zoho Developer Community







                                Zoho Desk Resources

                                • Desk Community Learning Series


                                • Digest


                                • Functions


                                • Meetups


                                • Kbase


                                • Resources


                                • Glossary


                                • Desk Marketplace


                                • MVP Corner


                                • Word of the Day



                                    Zoho Marketing Automation


                                            Manage your brands on social media



                                                  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 WorkDrive Resources



                                                                      Zoho Campaigns Resources


                                                                        Zoho CRM Resources

                                                                        • CRM Community Learning Series

                                                                          CRM Community Learning Series


                                                                        • Tips

                                                                          Tips

                                                                        • Functions

                                                                          Functions

                                                                        • Meetups

                                                                          Meetups

                                                                        • Kbase

                                                                          Kbase

                                                                        • Resources

                                                                          Resources

                                                                        • Digest

                                                                          Digest

                                                                        • CRM Marketplace

                                                                          CRM Marketplace

                                                                        • MVP Corner

                                                                          MVP Corner





                                                                            Design. Discuss. Deliver.

                                                                            Create visually engaging stories with Zoho Show.

                                                                            Get Started Now