AI Generate X++ docs instantly

X++ Cheat Sheet

Quick reference guide with copy-paste ready code snippets

Try DocuWriter Free

Basics

3 snippets

X++ fundamentals

Variables & Types

str name = "Hello";
int count = 42;
real price = 19.99;
boolean active = true;
date today = systemDateGet();
utcDateTime now = DateTimeUtil::utcNow();

Class & Method

class MyService
{
    public str greet(str _name)
    {
        return strFmt("Hello, %1!", _name);
    }

    public static void main(Args _args)
    {
        MyService svc = new MyService();
        info(svc.greet("World"));
    }
}

Info & Error

info("Informational message");
warning("Warning message");
error("Error message");
Global::info(strFmt("Count: %1", count));

Table Operations

4 snippets

Select, insert, update, delete

Select

CustTable custTable;

select firstOnly custTable
    where custTable.AccountNum == "US-001";

if (custTable.RecId)
    info(custTable.Name);

While Select

SalesTable salesTable;

while select salesTable
    where salesTable.SalesStatus == SalesStatus::Open
{
    info(salesTable.SalesId);
}

Join

SalesTable st;
CustTable ct;

while select st
    join ct
    where ct.AccountNum == st.CustAccount
       && st.SalesStatus == SalesStatus::Open
{
    info(strFmt("%1 - %2", st.SalesId, ct.Name));
}

Insert & Update

ttsBegin;
CustTable cust;
cust.AccountNum = "US-999";
cust.Name = "New Customer";
cust.insert();
ttsCommit;

ttsBegin;
select forUpdate cust where cust.AccountNum == "US-999";
cust.Name = "Updated Name";
cust.update();
ttsCommit;

Set-Based Operations

3 snippets

Bulk data manipulation

insert_recordset

insert_recordset tmpTable (AccountNum, Name)
    select AccountNum, Name from custTable
    where custTable.Blocked == CustVendorBlocked::No;

update_recordset

update_recordset custTable
    setting Blocked = CustVendorBlocked::All
    where custTable.LastTransDate < prevYr(today());

delete_from

delete_from tmpTable
    where tmpTable.Processed == NoYes::Yes;

Tired of looking up syntax?

DocuWriter.ai generates documentation and explains code using AI.

Try Free

Exception Handling

2 snippets

Try/catch and transactions

Try / Catch

try
{
    ttsBegin;
    // database operations
    ttsCommit;
}
catch (Exception::Error)
{
    error("Operation failed");
}
catch (Exception::Deadlock)
{
    retry;
}

Throw

if (!custTable.RecId)
{
    throw error("Customer not found");
}

if (!this.validate())
{
    throw error("@SYS12345");  // Label reference
}

Collections

3 snippets

Lists, maps, and sets

List

List myList = new List(Types::String);
myList.addEnd("first");
myList.addEnd("second");

ListEnumerator le = myList.getEnumerator();
while (le.moveNext())
{
    info(le.current());
}

Map

Map myMap = new Map(Types::String, Types::Integer);
myMap.insert("a", 1);
myMap.insert("b", 2);

if (myMap.exists("a"))
    info(int2Str(myMap.lookup("a")));

Container

container c = ["a", 1, "b", 2];
str val = conPeek(c, 1);    // "a"
int len = conLen(c);         // 4
c = conIns(c, 3, "new");     // Insert at position 3
c = conDel(c, 1, 1);         // Delete 1 element at pos 1

More Cheat Sheets

FAQ

Frequently asked questions

What is a X++ cheat sheet?

A X++ cheat sheet is a quick reference guide containing the most commonly used syntax, functions, and patterns in X++. It helps developers quickly look up syntax without searching through documentation.

How do I learn X++ quickly?

Start with the basics: variables, control flow, and functions. Use this cheat sheet as a reference while practicing. For faster learning, try DocuWriter.ai to automatically explain code and generate documentation as you learn.

What are the most important X++ concepts?

Key X++ concepts include variables and data types, control flow (if/else, loops), functions, error handling, and working with data structures like arrays and objects/dictionaries.

How can I document my X++ code?

Use inline comments for complex logic, docstrings for functions and classes, and README files for projects. DocuWriter.ai can automatically generate professional documentation from your X++ code using AI.

Related resources

Stop memorizing. Start shipping.

Generate X++ Docs with AI

DocuWriter.ai automatically generates comments, docstrings, and README files for your code.

Auto-generate comments
Create README files
Explain complex code
API documentation
Start Free - No Credit Card

Join 33,700+ developers saving hours every week