Basics
Fetching records
GrandTotalQuery = grandtotal.newQuery("EntityName");
GrandTotalQuery
GrandTotalQuery.records();
GrandTotalQuery.filter("Predicate");
GrandTotalQuery.sort("Fieldname",(Boolean) ascending);
GrandTotalRecord = grandtotal.fetchRecord("EntityName","Predicate");
Sample Predicate:
- "name LIKE 'x' AND uid LIKE 'y'"
Creating Records
EditableGrandTotalRecord = grandtotal.insertRecord("EntityName");
GrandTotalRecord
grandtotalrecord.formattedNumber(theNumber);
grandtotalrecord.formattedDuration(theNumber);
grandtotalrecord.propertyName();
grandtotalrecord.valueForKeyPath("keypath");
Sample KeyPaths:
- "dateSent.yearOfCommonEra"
- "dateSent.monthOfYear"
- "dateSent.dayOfMonth"
- "client.formattedAddress"
- "currency.name"
EditableGrandTotalRecord (inherits from GrandTotalRecord)
grandtotalrecord.setValue("propertyName",value);
Sample
var aClient = grandtotal.insertRecord("Client");
aClient.setValue("firstName","Joe");
aClient.setValue("lastName","Doe");
var aInvoice = grandtotal.insertRecord("Invoice");
aInvoice.setValue("parentDocument",aClient);
var aCost = grandtotal.insertRecord("Cost");
aCost.setValue("parent",aInvoice);
aCost.setValue("quantity",3);
aCost.setValue("unitPrice",99);
aCost.setValue("name","Three Items");
aCost.setValue("notes","with a lousy description");
Entities
%@
Plugin Anatomy
-
PluginName.grandtotalplugin (Folder)
-
Info.plist (Required, see below)
-
index.html (Required, holds html and JavaScript)
-
additional resources (Optional)
index.html
Regular html that executes your JavaScript onLoad
Info.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleIdentifier</key>
<string>com.mediaatelier.grandtotal.plugin.dashboard</string>
<key>CFBundleVersion</key>
<string>1.0</string>
<key>GrandTotal3Ready</key>
<true/>
<key>copyright</key>
<string>© 2015 Your Name>
<key>types</key>
<array>
<string>overview</string>
<string>dashboard</string>
<string>invoices</string>
<string>estimates</string>
</array>
</dict>
</plist>