📁 Docs
Script it

Script Jewellry factory

⚠️
We recommend finishing Tutorial: Task list to understand general usage before continuing here.

To create enterprise Jewellery factory, 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 "Jewellery factory" by sending the commands below into the terminal.

// create enterprise
add enterprise name:"Your Jewellery factory"
update enterprise about:"We sell jewellery"
update enterprise timeZone:"Asia/Kolkata"
update enterprise displayDateFormat:"dd/MM/yyyy, HH:mm:ss"

Backend

1. Variables

// add variable to store g symbol
ensure variable VarTextGramSymbol kind:"Text"
update variable VarTextGramSymbol value:"g"
 
// add variable to store ₹ symbol
ensure variable VarTextRupeeSymbol kind:"Text"
update variable VarTextRupeeSymbol value:"₹"

2. Roles

// add role
ensure role Owner

3. Spreadsheets

a. CategoryMaster

• Create form
// create form FormCategory to provide structure to the spreadsheet CategoryMaster
ensure form FormCategory
update form FormCategory label:"Category"
 
ensure section Details
 
ensure field Category type:"text"
• Associate form
// associate the form FormCategory with the spreadsheet CategoryMaster
ensure spreadsheet CategoryMaster form:"FormCategory"
update spreadsheet CategoryMaster searchableFields:"Category"
• Associate permissions
// spreadsheet crud permissions
ensure spreadsheetPermission insertRoles:"Owner"
ensure spreadsheetPermission updateRoles:"Owner"
ensure spreadsheetPermission removeRoles:"Owner"
• Associate layout
// add a spreadsheet list layout
ensure spreadsheetLayout ListLayout kind:"list"
update spreadsheetLayout ListLayout showSearchBar:"yes"
update spreadsheetLayoutListItem line:"first" segment:"first" source:"field" text:"Category"

b. TypeMaster

• Create form
// create form FormType to provide structure to the spreadsheet TypeMaster
ensure form FormType
update form FormType label:"Type"
 
ensure section Details
 
ensure field Type type:"text"
• Associate form
// associate the form FormType with the spreadsheet TypeMaster
ensure spreadsheet TypeMaster form:"FormType"
update spreadsheet TypeMaster searchableFields:"Type"
• Associate permissions
// spreadsheet crud permissions
ensure spreadsheetPermission insertRoles:"Owner"
ensure spreadsheetPermission updateRoles:"Owner"
ensure spreadsheetPermission removeRoles:"Owner"
• Associate layout
// add a spreadsheet list layout
ensure spreadsheetLayout ListLayout kind:"list"
update spreadsheetLayout ListLayout showSearchBar:"yes"
update spreadsheetLayoutListItem line:"first" segment:"first" source:"field" text:"Type"

c. ItemMaster

• Create form
// create form FormItem to provide structure to the spreadsheet ItemMaster
ensure form FormItem
update form FormItem label:"Item"
 
//** section Details
 
ensure section Details
 
ensure field Name type:"Text"
update field Name required:"yes"
 
ensure field Image1 type:"Image"
update field Image1 required:"yes"
 
ensure field Image2 type:"Image"
 
ensure field Image3 type:"Image"
 
ensure field GrossWeight type:"Decimal"
update field GrossWeight suffix:"VarTextGramSymbol"
 
ensure field NetWeight type:"Decimal"
update field NetWeight suffix:"VarTextGramSymbol"
 
ensure field Karat type:"Number"
update field Karat suffix:" Kt" required:"yes"
 
ensure field Price type:"Number"
update field Price prefix:"VarTextRupeeSymbol" required:"yes"
 
ensure field CategoryRef type:"ref" spreadsheet:"CategoryMaster"
update field CategoryRef spreadsheetLayout:"ListLayout"
update field CategoryRef copyFields:"Category,$RowId"
update field CategoryRef categoryFilterDisplayField:"Category"
 
ensure field TypeRef type:"ref" spreadsheet:"TypeMaster"
update field TypeRef spreadsheetLayout:"ListLayout"
update field TypeRef copyFields:"Type,$RowId"
update field TypeRef categoryFilterDisplayField:"Type"
 
ensure field AvailableQuantity type:"logNumber"
 
ensure field UnitSold type:"logNumber"
update field UnitSold disabled:"yes"
• Associate form
// associate the form FormItem with the spreadsheet ItemMaster
ensure spreadsheet ItemMaster form:"FormItem"
update spreadsheet ItemMaster searchableFields:"Name,Price,GrossWeight,NetWeight,Karat"
update spreadsheet ItemMaster queryableFields:"Price,Category,CategoryMasterRowId,Type,TypeMasterRowId"
• Associate permissions
// spreadsheet crud permissions
ensure spreadsheetPermission insertRoles:"Owner"
ensure spreadsheetPermission updateRoles:"Owner"
ensure spreadsheetPermission removeRoles:"Owner"
• Associate list layout
// add a spreadsheet list layout
ensure spreadsheetLayout ListLayout kind:"list"
 
update spreadsheetLayout ListLayout categoryFields:"CategoryRef,TypeRef"
update spreadsheetLayout ListLayout advanceFilterFields:"Price"
update spreadsheetLayout ListLayout showSearchBar:"yes"
 
update spreadsheetLayoutListItem source:"field" images:"Image1,Image2,Image3"
update spreadsheetLayoutListItem line:"first" segment:"first" source:"field" text:"Name"
update spreadsheetLayoutListItem line:"second" segment:"first" source:"field" text:"GrossWeight,NetWeight" showLabels:"yes"
update spreadsheetLayoutListItem line:"third" segment:"first" source:"field" text:"Category,Type,Karat" showLabels:"yes"
update spreadsheetLayoutListItem line:"fourth" segment:"first" source:"field" text:"Price" showLabels:"yes"
update spreadsheetLayoutListItem line:"fifth" segment:"first" source:"field" text:"AvailableQuantity" showLabels:"yes"
• Associate card layout
// add a spreadsheet card layout
ensure spreadsheetLayout CardLayout kind:"card"
update spreadsheetLayout CardLayout categoryFields:"CategoryRef,TypeRef"
update spreadsheetLayout CardLayout advanceFilterFields:"Price"
update spreadsheetLayout CardLayout showSearchBar:"yes"
 
update spreadsheetLayoutCardItem source:"field" images:"Image1,Image2,Image3"
update spreadsheetLayoutCardItem line:"first" segment:"first" source:"field" text:"Name"
update spreadsheetLayoutCardItem line:"second" segment:"first" source:"field" text:"GrossWeight,NetWeight" showLabels:"yes"
update spreadsheetLayoutCardItem line:"third" segment:"first" source:"field" text:"Karat" showLabels:"yes"
update spreadsheetLayoutCardItem line:"fourth" segment:"first" source:"field" text:"Price" showLabels:"yes"
update spreadsheetLayoutCardItem line:"fifth" segment:"first" source:"field" text:"AvailableQuantity" showLabels:"yes"

d. OrderBook

• Create form
// add the form FormOrder to provide structure to the spreadsheet OrderBook
ensure form FormOrder
update form FormOrder label:"Order"
ensure formPermission commentRoles:"Owner,$Public" allowToPrintForm:"Yes"
 
//** grid Items
 
ensure grid Items
 
ensure field Quantity type:"counter"
 
ensure field ItemRef type:"ref" spreadsheet:"ItemMaster"
 
update field ItemRef spreadsheetLayout:"CardLayout"
update field ItemRef copyFields:"Category,Type,Name,GrossWeight,NetWeight,Karat,Price,$RowId"
update field ItemRef forceOpenOnFormCreate:"yes"
update fieldRefOverlayLayout line:"first" segment:"caption" source:"field" text:"Items.Quantity"
 
ensure field Amount type:"decimal"
update Field Amount prefix:"VarTextRupeeSymbol"
update field Amount formula:"${f:Items.Price} * ${f:Items.Quantity}"
 
// attach list layout to grid Items
 
ensure gridLayout ListLayout kind:"list"
 
update gridLayoutListItem line:"first" segment:"first" source:"field" text:"Name"
update gridLayoutListItem line:"second" segment:"first" source:"field" text:"GrossWeight,NetWeight" showLabels:"yes"
update gridLayoutListItem line:"first" segment:"caption" source:"field" text:"Amount" showLabels:"yes"
update gridLayoutListItem line:"second" segment:"caption" source:"field" text:"Quantity" showLabels:"yes"
 
update grid Items asideDefaultLayout:"ListLayout"
 
// attach table layout to grid Items
 
ensure gridLayout TableLayout kind:"table"
 
update gridLayout TableLayout showFields:"Name,Type,Category,NetWeight,GrossWeight,Karat,Quantity,Price,Amount"
update gridLayout TableLayout columnSizes:"AutoSize"
 
//** section details
 
ensure section Details
 
ensure field Date type:"Date"
update field Date defaultValue:"now"
 
ensure field Name type:"text"
update Field Name required:"yes"
 
ensure field Address type:"paragraph"
update Field Address required:"yes"
 
ensure field MobileNumber type:"mobileNumber"
update Field MobileNumber helperText:"Start with +91xxxxxxxxxx"
update Field MobileNumber required:"yes"
 
//** section Summary
 
ensure section Summary
 
ensure field NetTotal type:"decimal"
update Field NetTotal prefix:"VarTextRupeeSymbol"
update field NetTotal formula:"SUM(${f:Items.Amount})"
 
ensure field GST type:"decimal"
update Field GST prefix:"VarTextRupeeSymbol"
update Field GST helperText:"Applicable 18% GST"
update field GST formula:"(${f:Summary.NetTotal} * 0.18)"
 
ensure field GrossTotal type:"decimal"
update Field GrossTotal prefix:"VarTextRupeeSymbol"
update field GrossTotal formula:"${f:Summary.NetTotal} + ${f:Summary.GST}"
• Associate Content Layout
// add form content layout
ensure formLayoutContent DlOrderContentlayout
update formLayoutContent DlOrderContentlayout direction:"vertical"
 
update formLayoutContent DlOrderContentlayout position:"start" fields:"Date,Name,Address,MobileNumber"
update formLayoutContent DlOrderContentlayout position:"start" showItemBorders:"top,bottom" showItemPadding:"top,bottom" padding:"thick"
 
update formLayoutContent DlOrderContentlayout position:"flexCenter" gridLayouts:"Items.TableLayout"
update formLayoutContent DlOrderContentlayout position:"flexCenter" showItemPadding:"top,bottom" padding:"thick"
 
update formLayoutContent DlOrderContentlayout position:"end" fields:"NetTotal,GST,GrossTotal"
update formLayoutContent DlOrderContentlayout position:"end" showItemBorders:"top" showItemPadding:"top,bottom" padding:"thick"
 
// add form layout header
update formLayoutHeader showEnterprise:"yes"
• Associate form
// associate the form FormOrder with the spreadsheet OrderBook
ensure spreadsheet OrderBook form:"FormOrder"
update spreadsheet OrderBook searchableFields:"Name,Address,MobileNumber,GrossTotal"
• Associate permissions
// spreadsheet crud permissions
ensure spreadsheetPermission insertRoles:"Owner,$Public"
ensure spreadsheetPermission readRoles:"Owner"
ensure spreadsheetPermission updateRoles:"Owner"
ensure spreadsheetPermission removeRoles:"Owner"
• Associate layout
// add a spreadsheet table Layout
ensure spreadsheetLayout TableLayout kind:"table"
 
update spreadsheetLayout TableLayout showFields:"Name,Address,NetTotal,GST,GrossTotal"
update spreadsheetLayout TableLayout masterDetailGrids:"Items"
update spreadsheetLayout TableLayout columnSizes:"AutoSize"
update spreadsheetLayout TableLayout showCommentCount:"yes"

Frontend

Actions

a. AddCategory

ensure action AddCategory kind:"rowInsert"
 
update action AddCategory spreadsheet:"CategoryMaster"
update action AddCategory icon:"AddRounded"
update action AddCategory sendMessageToInbox:"yes"

b. CategoryMaster

ensure action CategoryMaster kind:"spreadsheetEditor"
 
update action CategoryMaster spreadsheet:"CategoryMaster"
update action CategoryMaster spreadsheetLayout:"ListLayout"
update action CategoryMaster icon:"CategoryRounded"

c. AddType

ensure action AddType kind:"rowInsert"
 
update action AddType spreadsheet:"TypeMaster"
update action AddType icon:"AddRounded"
update action AddType sendMessageToInbox:"yes"

d. TypeMaster

ensure action TypeMaster kind:"spreadsheetEditor"
 
update action TypeMaster spreadsheet:"TypeMaster"
update action TypeMaster spreadsheetLayout:"ListLayout"
update action TypeMaster icon:"CategoryRounded"

e. AddItem

ensure action AddItem kind:"rowInsert"
 
update action AddItem spreadsheet:"ItemMaster"
update action AddItem icon:"AddRounded"
update action AddItem sendMessageToInbox:"yes"

f. ItemMaster

ensure action ItemMaster kind:"spreadsheetEditor"
 
update action ItemMaster spreadsheet:"ItemMaster"
update action ItemMaster spreadsheetLayout:"ListLayout"
update action ItemMaster icon:"DatasetRounded"

g. AddOrder

ensure action AddOrder kind:"rowInsert"
 
update action AddOrder spreadsheet:"OrderBook"
update action AddOrder icon:"AddRounded"
update action AddOrder sendMessageToInbox:"yes"

h. OrderBook

ensure action OrderBook kind:"spreadsheetEditor"
 
update action OrderBook spreadsheet:"OrderBook"
update action OrderBook spreadsheetLayout:"TableLayout"
update action OrderBook icon:"AddShoppingCartRounded"

Groups

a. Add groups

//Add group ItemMaster to add Jewellery items
ensure group ItemMaster
 
// Add OrderBook to add order
ensure group OrderBook

b. Associate actions

goto group ItemMaster
 
ensure groupAction action:"AddCategory" menuGroup:"ADD" roles:"Owner"
ensure groupAction action:"AddType" menuGroup:"ADD" roles:"Owner"
ensure groupAction action:"AddItem" menuGroup:"ADD" roles:"Owner"
 
ensure groupAction action:"CategoryMaster" menuGroup:"MASTER" roles:"Owner"
ensure groupAction action:"TypeMaster" menuGroup:"MASTER" roles:"Owner"
ensure groupAction action:"ItemMaster" menuGroup:"MASTER" roles:"Owner"
 
update group ItemMaster pinnedActions:"CategoryMaster,TypeMaster,ItemMaster"
 
goto group OrderBook
 
ensure groupAction action:"AddOrder" roles:"Owner,$Public"
ensure groupAction action:"OrderBook" roles:"Owner"
update group OrderBook pinnedActions:"AddOrder,OrderBook"

Deeplinks

a. AddOrder

// Create deeplinks
 
// share order form to customer for them to order Jewellery
 
ensure deeplink DlAddOrder kind:"spreadsheetInsert"
 
update deeplink DlAddOrder spreadsheet:"OrderBook"
update deeplink DlAddOrder visibilityConstraint:"enforceFollowerSignIn"
update deeplink DlAddOrder creationRoles:"Owner"
update deeplink DlAddOrder showHeader:"yes"
update deeplink DlAddOrder showEnterprise:"yes"
update deeplink DlAddOrder showSeparator:"yes"
update deeplink DlAddOrder showEnterprisePreviewImage:"yes"
update deeplink DlAddOrder expiry:"noExpiry"
 
// to show success message after order
 
update deeplink DlAddOrder successMessage:"Thank you, ${p1}, for your purchase of, ${p2}, with us!"
ensure deeplinkProp prop:"successMessage" param:"p1" value:"Name"  binder:"field"
ensure deeplinkProp prop:"successMessage" param:"p2" value:"GrossTotal"  binder:"field"
 
// add a button to order again
 
update deeplink DlAddOrder showRepeatButton:"yes"
update deeplink DlAddOrder repeatButtonLabel:"Order Again"
 
// add hyperlink to show your website link
 
ensure variable VarHyperlinkWebsite kind:"Hyperlink"
update variable VarHyperlinkWebsite value:"https://neome.ai/" displayText:"Jewellery Store"
update variable VarHyperlinkWebsite kind: "general"
 
update deeplink DlAddOrder hyperlinkVars:"VarHyperlinkWebsite"

b. FormOrder

ensure deeplink DlFormOrder kind:"spreadsheetRow"
 
update deeplink DlFormOrder spreadsheet:"OrderBook" formContentLayout: "DlOrderContentlayout"
 
update deeplink DlFormOrder visibilityConstraint:"allowPublicSharing"
update deeplink DlFormOrder showEnterprisePreviewImage:"yes"
update deeplink DlFormOrder creationRoles:"Owner"
update deeplink DlFormOrder expiry:"noExpiry"

Deploy

deploy enterprise

Try your creation

To add users to enterprise application Jewellery factory through a UI,

  1. Open the route production by clicking the link https://web.neome.ai/production (opens in a new tab).
  2. Add users and give them the roles.

Alternatively you can add users by executing following scripts in the terminal.

a. Try for yourself

ensureSelf user roles:"Owner"

b. Try for others

add user name:"SomeOwner" handle:"[email protected]" roles:"Owner"
 
inviteAll users