Visit sheet
Backend
1. Variables
// picker variable for customer type
ensure var VarSetOfTextCustomerType kind: setOfText
deploy: fixedOnDeploy
value: "<root>
<node key='keyDistributor'>Distributor</node>
<node key='keyDealer'>Dealer</node>
</root>"
2. VisitBook
ensure spreadsheet: VisitBook
withFields: [
"Date",
"VisitedBy",
"CustomerName",
"MobileNumber",
"CustomerType",
"GSTNo",
"Location",
"Image1",
"Image2",
"Remarks"
]
ofTypes: [
date,
pickUser,
text,
mobileNumber,
pickText,
text,
location,
camera,
camera,
paragraph
]
removeRoleSet: [Owner]
insertRoleSet: [Owner, Salesman]
updateRoleSet: [Owner, Salesman]
readRoleSet: [Owner, $Manager]
ensure form EntityVisit
commentRoleSet: [Employee]
chatLabelField: Details.CustomerName
ensure section: Details
ensure field Date defaultValue: "now"
ensure field VisitedBy disabled: true roleDataSource: [$Self] defaultValue: $Self
ensure field CustomerType sourceVar: VarSetOfTextCustomerType defaultOptionId: "keyDealer"
ensure field Location captureUser: false captureMode: onInsert
ensure field Image1 label: "Image 1" showLabel: false
ensure field Image2 label: "Image 2" showLabel: false
ensure field GSTNo label: "GST No"
ensure field Remarks lineCount: 5
ensure spreadsheet VisitBook
searchables: [Date, VisitedBy]
queryables: [CustomerName, MobileNumber, VisitedBy]
ensure layoutSpreadsheet ListLayout kind: list
filter.showSearchBar: true
firstLine.first.lineFields: [CustomerName]
firstLine.caption.lineFields: [CustomerType]
secondLine.first.lineFields: [MobileNumber]
secondLine.first.showLabels: true
thirdLine.first.lineFields: [Location]
thirdLine.first.showLabels: true
ensure layoutSpreadsheet TableLayout kind: table
columnSizeSet: ["AutoSize"]
showCommentCount: true
showComps: [
Date,
VisitedBy,
CustomerName,
MobileNumber,
CustomerType,
Location,
Remarks
]
3. Reports
a. ReportVisit
• Input form
ensure form FilterVisit
ensure section: Details
ensure field LabelFilterDate kind: label
label: "Filter Date"
bold: true
textPattern: "Filter Date"
ensure field FromDate kind: date defaultValue: "startOfMonth"
ensure field ToDate kind: date defaultValue: "endOfMonth"
ensure field Divider kind: divider
ensure field LabelFilterEmployee kind: label
label: "Filter Employee"
bold: true
textPattern: "Filter Employee"
ensure field Employee kind: pickUser roleDataSource: [Employee]
• Output form
ensure form OutputVisit
ensure grid: VisitSet
ensure field Date kind: date defaultValue: "now"
ensure field VisitedBy kind: pickUser roleDataSource: [Employee]
ensure field VisitRowId kind: rowId
ensure field CustomerName kind: text
ensure field MobileNumber kind: mobileNumber
ensure field CustomerType kind: pickText sourceVar: VarSetOfTextCustomerType
ensure field GSTNo kind: text label: "GST No"
ensure field Location kind: location
ensure field Remarks kind: paragraph
ensure field MapLineStroke kind: lineStroke defaultValue: solid
ensure field MapPinShape kind: pinShape defaultValue: pin
ensure field UserColor kind: color
• Output layout
// change context to VisitSet grid
ensure grid: VisitSet
ensure layoutGrid TableLayout kind: table columnSizeSet: ["AutoSize"]
showComps: [
Date,
VisitedBy,
CustomerName,
MobileNumber,
CustomerType,
GSTNo,
Location,
Remarks
]
// use location fields of grid to show map layout
ensure layoutGrid MapLayout kind: map
locationField: Location
colorField: UserColor
shapeField: MapPinShape
groupByField: VisitedBy
strokeField: MapLineStroke
// change context to OutputVisit
ensure form OutputVisit
// add map layout
ensure layout Map kind: content
direction: horizontal
renderingMode: fullScreen
flexCenter.gridLayouts: [VisitSet.MapLayout]
// add table layout
ensure layout Table kind: content
direction: vertical
allowToSwitchLayouts: [Map]
flexCenter.gridLayouts: [VisitSet.TableLayout]
// let user toggle between Map and Table layouts
ensure layout Map
allowToSwitchLayouts: [Table]
• Output formulas
ensure formula ColorFormula
assignToField: VisitSet.UserColor
formula: "getUserColor(${f:VisitSet.VisitedBy})"
• Report
ensure var VarFilterConditionReportVisit kind: condition
deploy: fixedOnDeploy
inputForm: FilterVisit
sourceForm: EntityVisit
value: "<root>
<and>
<and>
<stmt>${f:Details.Date} >= ${in:Details.FromDate}</stmt>
<stmt>${f:Details.Date} <= ${in:Details.ToDate}</stmt>
</and>
<or>
<and>
<stmt>${in:Details.Employee} has value</stmt>
<stmt>${f:Details.VisitedBy} == ${in:Details.Employee}</stmt>
</and>
<stmt>${in:Details.Employee} has no value</stmt>
</or>
</and>
</root>"
// mapping variable between spreadsheet form and output form
ensure var VarMappingVisit kind: mapping
deploy: fixedOnDeploy
fromForm: EntityVisit
toForm: OutputVisit
toGrid: VisitSet
fieldMappingMap: {
'map': {
'${f:Details.Date}': 'VisitSet.Date',
'${f:Details.VisitedBy}': 'VisitSet.VisitedBy',
'${f:Details.CustomerName}': 'VisitSet.CustomerName',
'${f:Details.MobileNumber}': 'VisitSet.MobileNumber',
'${f:Details.CustomerType}': 'VisitSet.CustomerType',
'${f:Details.GSTNo}': 'VisitSet.GSTNo',
'${f:Details.Location}': 'VisitSet.Location',
'${f:Details.Remarks}': 'VisitSet.Remarks',
'${f:SysRowId}': 'VisitSet.VisitRowId'
}
}
ensure report ReportVisit kind: spreadsheet
inputForm: FilterVisit
outputForm: OutputVisit
fromSpreadsheet: VisitBook
filterConditionVar: VarFilterConditionReportVisit
outputFormMappingVar: VarMappingVisit
b. ReportVisitInfo
• Input form
Output form OutputVisit of ReportVisit is the input form for ReportVisitInfo.
• Output form
ensure form OutputVisitInfo
ensure section: Details
ensure field CustomerType kind: pickText
sourceVar: VarSetOfTextCustomerType
ensure field Customer kind: text
ensure field VisitedBy kind: pickUser roleDataSource: [Employee]
ensure field Address kind: location
ensure field Remarks kind: paragraph
ensure layout ReportLayout kind: content
displayLabel: "Visit Info"
direction: vertical
start.fields: [CustomerType, Customer, Address, Remarks]
• Report
ensure report ReportVisitInfo kind: query
label: "Visit Info"
inputForm: OutputVisit
outputForm: OutputVisitInfo
fromSpreadsheets: [VisitBook]
neoQL: "select
${ss:VisitBook.Details.CustomerType} as ${out:Details.CustomerType},
${ss:VisitBook.Details.CustomerName} as ${out:Details.Customer},
${ss:VisitBook.Details.VisitedBy} as ${out:Details.VisitedBy},
${ss:VisitBook.Details.Location} as ${out:Details.Address},
${ss:VisitBook.Details.Remarks} as ${out:Details.Remarks}
from ${ss}
where ${ctx:row.type} = ${ss:VisitBook}
and ${ctx:row.id} = ${arg:selectedGridId.selectedGridRowId.VisitRowId}"
Frontend
1. Actions
a. AddVisit
ensure action AddVisit kind: rowInsert
icon: "AddLocationRounded"
spreadsheet: VisitBook
sendMessageToInbox: true
b. ReportVisit
ensure action ReportVisit kind: report
icon: "MapRounded"
report: ReportVisit
outputFormContentLayout: Map
sendMessageToInbox: false
c. ReportVisitInfo
ensure action ReportVisitInfo kind: report
label: "Visit Info"
report: ReportVisitInfo
outputFormContentLayout: ReportLayout
sendMessageToInbox: false
d. EditVisitSheet
ensure action EditVisitSheet kind: spreadsheetEditor
icon: "EditNoteRounded"
spreadsheet: VisitBook
layoutSpreadsheet: TableLayout
2. Attach Actions
ensure form OutputVisit
ensure composite VisitSet
actionPermission: {
'ReportVisitInfo': {
'showMessageToolTip': true,
'roles': [
'Employee'
]
}
}
3. Group actions
Actions are grouped here for demo.
ensure group MyVisits
pinnedActions: [AddVisit, ReportVisit]
pinnedActionSetMobile: [AddVisit]
actionPermission: {
'AddVisit': {
'menuGroup': '1',
'roles': [
'Salesman'
]
},
'EditVisitSheet': {
'menuGroup': '2',
'roles': [
'Owner'
]
},
'ReportVisit': {
'menuGroup': '3',
'roles': [
'Owner'
]
}
}