Forms in Cliq are platform components that can take in multiple user inputs in a single go, standardize the way work gets kicked off in an organization and helps you automate your everyday workflow.
Let's understand forms better by considering the following scenario.
Scenario
Assume, your team is now working on a new project and your lead decides to assign the tasks to the concerned person in Zoho Projects. As a first step, let's connect Zoho Projects with Cliq and add tasks right from the Cliq window using forms. To do this,
1. Connect Cliq with Zoho Projects by giving your connection a name followed by specifying the scopes.
2. The scopes required to add a task in Zoho Projects are,
- ZohoProjects.portals.READ
- ZohoProjects.projects.READ
- ZohoProjects.users.READ
- ZohoProjects.tasks.CREATE
3. The required method is POST and the URL to connect Zoho Projects with Cliq is
4. Once after you initiate the connection use the deluge code generated, in your script.
5. To know more about the scopes available in Zoho Projects head on over
here.
The bots menu handler and form submit handler code to add a task in Zoho Projects is attached here. Try copying the code in your deluge editor and execute it.
Bot menu handler code
- response = Map();
- inputs = list();
- inputs.add({"type":"text","name":"taskname","label":"Task Name","placeholder":"Specify the task name","mandatory":true,"value":"Enter the task name here"});
- inputs.add({"type":"textarea","name":"desc","label":"Add Description","placeholder":"A small description of the task","mandatory":false,"value":"A small description about the task"});
- inputs.add({"type":"date","name":"startdateinfo","label":"Start Date","placeholder":"01-01-2020","mandatory":false});
- inputs.add({"type":"date","name":"duedateinfo","label":"Due Date","placeholder":"01-01-2020","mandatory":false});
- inputs.add({"type":"select","name":"prior","label":"Priority","placeholder":"None","mandatory":false,"value":"None","options":[{"label":"None","value":"none"},{"label":"High","value":"high"},{"label":"Medium","value":"medium"},{"label":"Low","value":"low"}]});
- por = invokeurl
- [
- url :"https://projectsapi.zoho.com/restapi/portals/"
- type :GET
- connection:"Your connection name"
- ];
- portals = por.get("portals");
- user_listing=Collection();
- for each portal in portals
- {
- id = portal.get("id_string");
- pro = invokeurl
- [
- url :"https://projectsapi.zoho.com/restapi/portal/" + id + "/projects/"
- type :GET
- connection:"Your connection name"
- ];
- projects = pro.get("projects");
- for each project in projects
- {
- pid = project.get("id_string");
- users = invokeurl
- [
- url :"https://projectsapi.zoho.com/restapi/portal/"+id+"/projects/"+pid+"/users/"
- type : GET
- connection:"Your connection name"
- ];
- for each user in users.get("users")
- {
- user_id=user.get("id");
- user_name=user.get("name");
- user_listing.insert({"label":user_name,"value":user_id});
- }
- }
- }
- inputs.add({"type":"select","max_selections":"2","multiple":true,"name":"assignee","label":"Owner","placeholder":"Add a user","mandatory":true,"value":"Olivia","options":user_listing});
- form = {"type":"form","title":"New Task","hint":"Add a new task in Projects","name":"addtasks","version":1,"button_label":"Add","action":{"type":"invoke.function","name":"tasks"},"inputs":inputs};
- return form;
Form submit handler code
- response = Map();
- param = Map();
- formValues = form.get("values");
- priority = formValues.get("priority");
- param.put("name",formValues.get("taskname"));
- param.put("description",formValues.get("desc"));
- param.put("start_date",formValues.get("startdateinfo").toString("MM-dd-yyyy"));
- param.put("end_date",formValues.get("duedateinfo").toString("MM-dd-yyyy"));
- param.put("priority",formValues.get("prior").get("label"));
- param.put("person_responsible",(formValues.get("assignee").get("0").get("value")).toString());
- por = invokeurl
- [
- url :"https://projectsapi.zoho.com/restapi/portals/"
- type :GET
- connection:"Your connection name"
- ];
- portals = por.get("portals");
- for each portal in portals
- {
- id = portal.get("id_string");
- pro = invokeurl
- [
- url :"https://projectsapi.zoho.com/restapi/portal/" + id + "/projects/"
- type :GET
- connection:"Your connection name"
- ];
- user_listing_map = Map();
- projects = pro.get("projects");
- for each project in projects
- {
- pid = project.get("id_string");
- tasks = invokeurl
- [
- url :"https://projectsapi.zoho.com/restapi/portal/" + id + "/projects/" + pid + "/tasks/"
- type :POST
- parameters:param
- connection:"Your connection name"
- ];
- }
- }
- return {"text":"Hurray! Successfully added a task in Projects :happy:"};
With a multitude of possibilities available with forms, Zoho Cliq let's you build dynamic forms using a form builder. A form builder in Cliq is a form building platform for non coders to build interactive forms easily.
Here's a small video on building a form using the form builder.
There you go! A small example to understand how forms can come in handy to get your works done on the go. In case of any doubts or queries, do comment below. We'd be happy to assist you.
Regards,
Divya P
Zoho Cliq