The basics A command is written Name(arguments) and always returns a value. An argument can be a value, a field, a variable, an operation or another command. Names are in English; text in quotes stays in your language.
Language elements Text "Urgent quote" Number 12.5 Boolean true Field of the current row $amount Field of a record form.next Application variable @vat_rate List ["Draft" , "Sent" ] Command Round ($amount , 2 )Comment # Reminder after 15 days
Operators Calculate $price * 1.2 + 5 Join text "Quote " & $number Compare $amount >= 1000 Combine $amount > 0 and not IsEmpty ($customer )Dates Today () + 15
A few scripts Approve a quote A button on the record, visible when the quote is a draft.
SetField ("status" , "Validated" )SetField ("validated_on" , Today ())SetField ("validated_by" , CurrentUser ())Notify ("Quote validated." )Refuse a save The record.before_save event: Fail cancels the save and shows the message.
If (IsEmpty ($customer ), Fail ("Choose a customer." ))If ($amount < 0 , Fail ("The amount cannot be negative." ))Calculate live The field.change event on the quantity.
SetField ("total" , Round ($quantity * $unit_price * (1 + @vat_rate / 100 ), 2 ))Keep the kanban in order The card.before_move event: the card goes back to its place if the rule is not met.
Switch (event.to, "Signed" , If (event.from <> "Sent" , Fail ("A quote must be sent before being signed." )), "Lost" , If (not HasRole ("manager" ), Fail ("Only a manager can mark a quote as lost." )), ) How a script runs Writes are applied at the end, all at once: if the script fails, nothing is written. A script grants no extra rights: it acts with those of the person. The ODESA workstation acts with its own rights, even with the application closed. A filter decides whether a button is shown or an event fires. Limits of a run 10 000 commands run2 000 milliseconds10 000 milliseconds on the ODESA workstation200 rows written500 rows returned by a searchCommands Control CancelEnds, shows the message and writes nothing. DoRuns the commands in order and returns the last value. Set("name", Do(…)) with @name elsewhere in the script… FailLike Cancel; also refuses the operation of a "before" event. In an action: the form opens again with this… ForEachRuns the command for each item of the list, under the given name; returns the number of rounds. IfRuns only the chosen branch and returns its value. StopEnds the run normally. SwitchRuns the result of the first case equal to the value; a last lone argument is the default. TryIf the command fails, runs the second one; "error" then holds {code, message, line}.
Variables GetThe value of a variable, or the default if it does not exist. SetGives a value to a run variable and returns it. Set("name", Do(…)) with @name elsewhere in the script defines…
Values AbsAbsolute value. AddDaysAdds n days. AddMonthsAdds n months (end of month kept). AppendThe list with one more item at the end. AverageThe average (null if the list is empty). ContainsTrue if the text contains the part (ignoring case and accents), or the list the item. CountThe number of items. DayThe day of the month. EndOfMonthThe last day of the month. FirstThe first item, or null. FormatDateThe formatted date (yyyy, MM, dd, HH, mm). FormatNumberThe number formatted for the language. InTrue if the value is in the list. IsEmptyTrue if the value is empty (null, empty text, empty list). IsFormatTrue if the value has the right format, including its check digits when it has any: email, url, phone, iban,… IsNumberTrue if the value is a number or a text holding one. LastThe last item, or null. LengthLength of a text, or number of items of a list. LowerLower case. MatchesTrue if the text matches the regular expression (add ^ and $ for the whole text). MaxThe largest of the numbers (or of a list). MinThe smallest of the numbers (or of a list). MonthThe month (1 to 12). NotEmptyTrue if the value is not empty. NowThe date and time. RenderThe template with its {…} markers replaced by their values. ReplaceReplaces every occurrence (literal text). RoundRounds (0 decimals by default). SortThe sorted list, on a field for a list of rows ("asc" by default or "desc", empty last). SplitSplits the text: the list of pieces, or the n-th (from 1). StartOfMonthThe first day of the month. StartsWithTrue if the text starts so (ignoring case and accents). SumThe sum of the numbers, or of a field of the rows. ToDateA date from a text (YYYY-MM-DD or DD/MM/YYYY), or from year, month, day. ToNumberConverts to a number ("12,5" and "12.5" are accepted). ToTextConverts to text. TodayToday's date. TrimWithout spaces at the start or the end. UpperUpper case. WeekdayThe day of the week (Monday = 1). YearThe year.
Reading data FindThe rows of a table meeting all the conditions (field, operator, value), 500 at most. FindOneThe first row meeting the conditions, or null. FindSortedThe rows meeting the conditions, sorted on a field ("asc" or "desc", empty last), then the first "limit" ones… GetRowThe row with this id (lig-…), or null.
Writing CreateRowCreates a row (field, value pairs); returns its provisional id. DeleteRowDeletes a row, after the person confirms; returns its id. SetFieldChanges a field of the current row; returns {field, before, after}. UpdateRowChanges a row (field, value pairs); returns {id, changes}.
Person CurrentUserThe person running the script (m-…). HasRoleTrue if the person has this role in the company (manager, admin, member). InGroupTrue if the person is in this work group. UserNameThe display name of a member.
Screen and input AskOpens a form of the application; returns the answers, or null if the person cancels. ConfirmAsks the person a yes/no question. NotifyShows a message (toast) at the end of the run, if it succeeds. OpenOpens a node of the application (and a row) at the end of the run. RefreshRefreshes the display at the end of the run.
Files AttachFileStation view: copies the station's file into the field's documents on the row (the row may have just been… FileCountThe number of files of the file field. FileExtensionThe extension of a file or a name, in lower case. FileLinkThe link opening the file in the application. FileNameThe name of the first file of the file field, or null. GenerateDocumentGenerates a document from a template of My templates (name or id, written as is) for the row, and stores it… LinkFileLinks to the row's field, without copying, a file already stored (pce-…, or the value of a file field) or a… MoveFileStation view: moves the file into a sub-folder of its folder, at the end, after the writes. Returns the new… RowLinkThe link opening the current row in the application. StraightenFileStraightens a document photo already stored (pce-…, or the value of a file field): turned the right way up,…
External AgentThe agent (AI) step, handled by the AI server linked to ODESA. Agent("reflexion", prompt);… CallCalls a function published by the application's ODESA server and ticked in its definition (Functions tab).… FunctionsThe list of functions the application may call (name, description, parameters, read or action, no… SendMailSends a plain-text email through ODESA's mail service, at the end, with the writes (all or nothing). At most…
Mail AddMailNoteAdds “when, who: text” to the message's notes (Notes field of the ProMail view) and records it in its history. AddMailTabPuts a tab on the message (AI Agent's add_interface). viewer: text, markdown, html (sanitised), json, widget… CreateMailboxCreates a mailbox (a folder) on the mail server, inside the parent mailbox if given, after the writes. The… DeleteMailMoves the message to its mailbox's trash, after the writes. Without a record: the poste.mail event's message;… DeleteMailboxDeletes a mailbox on the mail server, after the writes: its messages first go to the Trash, then the mailbox… ForwardMailForwards the message, with its attachments, to the recipients (10 at most), with an optional introduction.… MarkMailMarks the received message as read (default) or unread. Without a record: the poste.mail event's message;… MoveMailMoves the received message to a folder of the mailbox (IMAP, Gmail, Microsoft; not POP). Without a record:… ReadMailReads the message live from its mailbox: de, a, cc, objet, date, texte, pieces [{nom, taille, type}]. Online… RemoveMailTabRemoves the tab of that name from the message. RenameMailboxRenames a mailbox on the mail server, after the writes; the node follows. Mailboxes with a role (Inbox,… ReplyMailReplies to the sender of the received message, in the same thread, with the quote. Sent by ODESA after the… SaveMailAttachmentsSaves the attachments of the received message (poste.mail event) into the row's file field. Optional pattern:… SyncMailFetches the mailbox of the open ProMail view now (a button): recent messages that are not rows yet become…