Script Task list
To create enterprise application Task list, open terminal in the route studio by clicking the link https://web.neome.ai/studio (opens in a new tab).
Enterprise
The whole script to build the example below is available here. Open .neo files with a text editor of your choice, and copy and paste them into the terminal. Alternatively, walk the example below step by step.
Add an enterprise Your task list by sending the commands below into the terminal.
// create enterprise
add enterprise name:"Your Task list"
update enterprise about:"Simple task list for a company"
update enterprise timeZone:"Asia/Kolkata"
update enterprise displayDateFormat:"dd/MM/yyyy, HH:mm:ss"
// creating front end group to use in backend
ensure group TaskList
An enterprise is composed of spreadsheet based backend and conversation based frontend.
Backend
1. Variables
Send the commands below into the terminal to create variables that will be reused.
// add variable VarDateNow to store today's date
ensure variable VarDateNow kind:"date"
update variable VarDateNow value:"now"
// add variable VarSetOfTextPriority to store options for priority
ensure variable VarSetOfTextPriority kind:"setOfText"
update variable VarSetOfTextPriority value:"High, Medium, Low" colors:"error,primary,success"
// add variable VarSetOfTextStatus to store options for status
ensure variable VarSetOfTextStatus kind:"setOfText"
update variable VarSetOfTextStatus value:"Pending, Started, Done"
2. Roles
Send the commands below into the terminal to add roles. Roles allow us to configure role-based access.
// every owner is also an employee
ensure role Owner
ensure role Employee
3. Spreadsheet
a. Create form
Send the commands below into the terminal to create a form FormTask that will be associated with the spreadsheet TaskSheet.
// add the form FormTask to provide structure to the spreadsheet TaskSheet
ensure form FormTask
update form FormTask label:"Task"
ensure formPermission commentRoles:"Employee" allowToPrintForm:"Yes"
// add section Details to form
ensure section Details
// add field Date to section Details defaulting to now
ensure field Date type:"Date"
update field Date defaultValue:"VarDateNow"
// add a task field to capture tasks
ensure field Task type:"text"
// add dropdown field with options for priority
ensure field Priority type:"pickText"
update field Priority source:"VarSetOfTextPriority" defaultOption:"Low"
// add dropdown field with options for status
ensure field Status type:"pickText"
update field Status source:"VarSetOfTextStatus" defaultOption:"Pending"
// add field created by
ensure field CreatedBy type:"system"
update field CreatedBy valueKind:"createdByNickName"
ensure fieldPermission default:"writeOnce"
b. Associate form
Send the commands below into the terminal to associate the form FormTask with the spreadsheet TaskSheet. Spreadsheet TaskSheet contains all the tasks from all the employees i.e. it is a shared spreadsheet.
// associate the form FormTask with the spreadsheet TaskSheet
ensure spreadsheet TaskSheet form:"FormTask"
// add searchable fields. Searchable fields can be searched through search bar in the app
update spreadsheet TaskSheet searchableFields:"Task, Priority, Status"
// add queryable fields. Queryable fields can be used in reporting
update spreadsheet TaskSheet queryableFields:"Task, Priority, Status, Date"
// add permissions for reading, updating, inserting and removing from the spreadsheet
ensure SpreadsheetPermission readRoles:"Owner"
ensure SpreadsheetPermission updateRoles:"Employee"
ensure SpreadsheetPermission insertRoles:"Employee"
ensure SpreadsheetPermission removeRoles:"Owner"
// add permissions for who can forward to whom
ensure SpreadsheetPermissionForwardRoles role:"Employee" roles:"Employee"
ensure spreadsheetPermissionForwardGroups role:"Employee" groups:"TaskList"
c. Associate layout
Add layouts to the spreadsheet TaskSheet. Layouts would be used to display a spreadsheet to the user.
// add table layout to spreadsheet TaskSheet to show my tasks
ensure spreadsheetLayout TableLayout kind:"table"
update spreadsheetLayout TableLayout showFields:"Date,Task,Priority,Status"
update spreadsheetLayout TableLayout columnSizes:"AutoSize"
update spreadsheetLayout TableLayout showCommentCount:"yes"
// add table layout to spreadsheet TaskSheet to show all the tasks
ensure spreadsheetLayout AllTasksTableLayout kind:"table"
update spreadsheetLayout AllTasksTableLayout showFields:"Date,Task,Priority,Status, CreatedBy"
update spreadsheetLayout AllTasksTableLayout columnSizes:"AutoSize"
update spreadsheetLayout AllTasksTableLayout showCommentCount:"yes"
4. Report
Create a report for the owner to see employee's tasks. Every report takes some input form as input and outputs an output form.
a. Input form
Add the report input form FormDateRangeFilter.
// add form FormDateRangeFilter
ensure form FormDateRangeFilter
//** section Details
ensure section Details
// add FromDate defaulting to first date of month
ensure field FromDate type:"Date"
update field FromDate defaultValue:"startOfMonth"
// add ToDate defaulting to last date of month
ensure field ToDate type:"Date"
update field ToDate defaultValue:"endOfMonth"
// add pickEmployee to allow the Owner to select Employees from dropdown
ensure field PickEmployee type:"pickUser"
update field PickEmployee dataSourceRoles:"Employee"
b. Output form
Add the report output form FormTaskSet.
// add form FormTaskSet
ensure form FormTaskSet
//** section Details
ensure section Details
// add text field to get the name of Employee
ensure field Name type:"text"
// add info field to show Employee's task list
ensure field Info type:"info"
update field Info font:"subtitle1"
update field Info bottomPadding:"thin"
update field Info defaultValue:"${p1}'s task list"
ensure fieldProp prop:"default" param:"p1" value:"Name" binder:"field"
// add date field to show FromDate
ensure field FromDate type:"date"
// add info field to show ToDate
ensure field ToDate type:"date"
//** grid TaskSet
ensure grid TaskSet
update grid TaskSet showBorders:"top,left,right"
ensure field Date type:"Date"
ensure field Task type:"text"
// add dropdown field with options of priority
ensure field Priority type:"pickText"
update field Priority source:"VarSetOfTextPriority"
// add dropdown field with options of status
ensure field Status type:"pickText"
update field Status source:"VarSetOfTextStatus"
// add Employee field to show which Employee the task belongs to
ensure field Employee type:"pickUser"
// add role Employee as a data source role to field Employee
update field Employee dataSourceRoles:"Employee"
c. Output layout
Add layout to the output form FormTaskSet to display it as a report.
// add grid layout to the grid TaskSet,
ensure gridLayout TableLayout kind:"table"
update gridLayout TableLayout showFields:"Date, Task, Priority, Status"
update gridLayout TableLayout columnSizes:"AutoSize"
// add above created grid layout to the output form's content layout
ensure formLayoutContent ContentLayout
update formLayoutContent ContentLayout direction:"vertical"
update formLayoutContent ContentLayout position:"start" fields:"Info,FromDate,ToDate"
update formLayoutContent ContentLayout position:"start" showItemBorders:"top,bottom"
update formLayoutContent ContentLayout position:"start" showItemPadding:"top,bottom" padding:"Thick"
update formLayoutContent ContentLayout position:"flexCenter" gridLayouts:"TaskSet.TableLayout"
update formLayoutContent ContentLayout position:"flexCenter" showItemPadding:"top" padding:"Thick"
// add formLayoutHeader to show the enterprise
update formLayoutHeader showEnterprise:"yes"
d. Query
Output form FormTaskSet of the report is filled by making two queries. One for filling details and other for filling grid.
i. Query details
// add report ReportEmployeeTasksSection to get employee details
ensure Report ReportEmployeeTasksSection kind:"query"
update Report ReportEmployeeTasksSection inputForm:"FormDateRangeFilter"
update Report ReportEmployeeTasksSection outputForm:"FormTaskSet"
update Report ReportEmployeeTasksSection fromSpreadsheets:"TaskSheet"
update Report ReportEmployeeTasksSection neoQL:"select\n${in:Details.PickEmployee.displayField} as ${out:Details.Name},\n${in:Details.FromDate} as ${out:Details.FromDate},\n${in:Details.ToDate} as ${out:Details.ToDate}\nfrom ${ss}\nwhere ${ctx:row.type} = ${ss:s1}"
ii. Query grid
// add mapping variable to map from FormTask to FormTaskSet
ensure variable VarMappingTask kind:"mapping"
update variable VarMappingTask description:"FormTask > FormTaskSet.TaskSet"
update variable VarMappingTask fromForm:"FormTask" toForm:"FormTaskSet" toGrid:"TaskSet"
ensure VariableMappingField fromField:"Date" to:"Date"
ensure VariableMappingField fromField:"Task" to:"Task"
ensure VariableMappingField fromField:"Priority" to:"Priority"
ensure VariableMappingField fromField:"Status" to:"Status"
ensure VariableMappingField fromContext:"row.createdBy" to:"Employee"
Add filter condition to filter tasks based on input form FormDateRangeFilter
// add condition variable to filter tasks
ensure variable VarConditionReportEmployeeTasks kind:"condition"
update variable VarConditionReportEmployeeTasks inputForm:"FormDateRangeFilter" sourceForm:"FormTask"
update variable VarConditionReportEmployeeTasks condition:"And(field:Date <= input:ToDate, field:Date >= input:FromDate, context:row.createdBy == input:PickEmployee)"
// create a report to get Employee tasks for the selected date range
ensure report ReportEmployeeTasksGrid kind:"spreadsheet"
// from clause
update report ReportEmployeeTasksGrid fromSpreadsheet:"TaskSheet"
// where clause
update report ReportEmployeeTasksGrid inputForm:"FormDateRangeFilter" filterCondition:"VarConditionReportEmployeeTasks"
// select a, b, c clause
update report ReportEmployeeTasksGrid outputForm:"FormTaskSet" outputFormMapping:"VarMappingTask"
e. Combine everything
// create composite report ReportEmployeeTasks by merging ReportEmployeeTasksSection and ReportEmployeeTasksGrid
ensure Report ReportEmployeeTasks kind:"composite"
update report ReportEmployeeTasks inputForm:"FormDateRangeFilter"
update report ReportEmployeeTasks outputForm:"FormTaskSet"
update Report ReportEmployeeTasks mergeReports:"ReportEmployeeTasksSection,ReportEmployeeTasksGrid"
Frontend
1. Actions
Actions expose a backend function on the conversational frontend as a shortcut on the input bar.
Create three actions for adding a task, getting the task sheet, and for the owner to get the report on the employee's tasks.
a. Add task
// invocation of this action inserts a row into a spreadsheet
ensure action AddTask kind:"rowInsert"
// associate the spreadsheet TaskSheet to this action
update action AddTask spreadsheet:"TaskSheet"
// action's icon on the input bar
update action AddTask icon:"AddTaskRounded"
// wrap the inserted row's rowId into a message send on the wrapping inbox
update action AddTask sendMessageToInbox:"yes"
b. Get my task sheet
// invocation of this action shows a spreadsheet editor
ensure action MyTasksSheet kind:"spreadsheetEditor"
// associate the spreadsheet TaskSheet to this action
update action MyTasksSheet spreadsheet:"TaskSheet"
// action's icon on the input bar
update action MyTasksSheet icon:"ChecklistRounded"
// the spreadsheet layout to show when the action is invoked
update action MyTasksSheet spreadsheetLayout:"TableLayout"
// associate where clause to view my tasks through reusable condition variable
ensure variable VarConditionGetMyTask kind:"condition"
update variable VarConditionGetMyTask sourceForm:"FormTask"
update variable VarConditionGetMyTask condition:"context:row.createdBy == context:caller.entUserId"
update action MyTasksSheet filterCondition:"VarConditionGetMyTask"
c. Report tasks
// invocation of this action shows a report
ensure action ReportTasks kind:"report"
// associate the report ReportEmployeeTasks to this action
update action ReportTasks report:"ReportEmployeeTasks"
// associate the content layout of the report to this action
update action ReportTasks outputFormContentLayout:"ContentLayout"
// action's icon on the input bar
update action ReportTasks icon:"SupervisedUserCircleRounded"
d. Get all tasks sheet
// invocation of this action shows a spreadsheet editor
ensure action AllTasksSheet kind:"spreadsheetEditor"
// associate the spreadsheet TaskSheet to this action
update action AllTasksSheet spreadsheet:"TaskSheet"
// action's icon on the input bar
update action AllTasksSheet icon:"FormatListBulletedRounded"
// the spreadsheet layout to show when the action is invoked
update action AllTasksSheet spreadsheetLayout:"AllTasksTableLayout"
2. Groups
Through frontend groups users chat and invoke actions.
a. Go to group
// to expose the actions go to group TaskList
goto group TaskList
b. Associate actions
// allow employee to add tasks through action AddTask
ensure GroupAction action:"AddTask" roles:"Employee" deviceSizes:"mobile,desktop"
// allow employee to view only their tasks through action TasksSheet
ensure GroupAction action:"MyTasksSheet" roles:"Employee" deviceSizes:"mobile,desktop"
// allow owner to view it's own and employee tasks through action AllTasksSheet
ensure GroupAction action:"AllTasksSheet" roles:"Owner" deviceSizes:"mobile,desktop"
// allow owner to view only employee tasks through action ReportTasks
ensure GroupAction action:"ReportTasks" roles:"Owner" deviceSizes:"mobile,desktop"
// allow employees to chat (i.e. send text messages, send media, etc.)
update group TaskList chatPermissions:"Owner"
// pin few actions on input bar for easy access
update group TaskList pinnedActions:"AddTask,MyTasksSheet,ReportTasks"
update group TaskList pinnedActionsMobile:"AddTask,MyTasksSheet"
Deploy
Finally, deploy the enterprise. On deployment an enterprise is created with the empty address book.
deploy enterprise
Try your creation
To add users to enterprise application Task list through a UI,
- Open the route production by clicking the link https://web.neome.ai/production (opens in a new tab).
- Add users and give them the roles.
Alternatively you can add users by executing following scripts in the route terminal (opens in a new tab).
a. Try for yourself
// add yourself as an owner and an employee
ensureSelf user roles:"Owner,Employee"
b. Try for others
// add others as either owner or employee
add user name:"SomeOwner" handle:"[email protected]" roles:"Owner,Employee"
add user name:"SomeEmployee1" handle:"[email protected]" roles:"Employee"
add user name:"SomeEmployee2" handle:"[email protected]" roles:"Employee"
// send invitation email/SMS to all the users which the user has to accept
inviteAll users
What next?
In this tutorial we have just scratched the surface of what is possible with neome. neome has plugins, automation, drive, prompts, deeplinks, reports, a store of prebuilt enterprises and plugins to accommodate any complex automation use case. Further more neome is community driven; you can always get an expert when you need one.
- Continue to Thinking in neome to understand the thought process required to build with neome.
- Check out Tutorials to see more representative examples to real world problems.
- Dig deeper, read about the Architecture of neome.
- Contact us to see a live demo, start proof-of-concept, or subscribe to our services.