getGuid
This function generates a new globally unique identifier (GUID) in the standard UUID format. Each call to this function creates a new, unique identifier that can be used for creating unique keys, temporary IDs, or other purposes requiring uniqueness.
Syntax
app.getGuid()
Parameters
This function takes no parameters.
Return Value
Returns a String containing a new GUID in the format "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" (where x is a hexadecimal digit).
Examples
Example 1: Generate a simple unique identifier:
// Generate a unique ID
const uniqueId = app.getGuid();
console.log("Generated GUID:", uniqueId);
// Output example: "550e8400-e29b-41d4-a716-446655440000"
Example 2: Create a unique temporary file name:
// Generate a unique filename for a temporary file
const fileName = "temp_" + app.getGuid() + ".pdf";
console.log("Temporary file name:", fileName);
// Output example: "temp_550e8400-e29b-41d4-a716-446655440000.pdf"
Example 3: Generate a unique client-side ID for new record:
// Create a new order with a temporary client-side ID
const newOrder = {
tempId: app.getGuid(),
customerName: app.getFieldValue("customerName"),
orderDate: app.getToday(),
items: []
};
// Add items to the order
const orderItems = app.getFieldValue("orderItemsGrid");
for (let i = 0; i < orderItems.length; i++) {
newOrder.items.push({
itemId: app.getGuid(),
productId: orderItems[i].productId,
quantity: orderItems[i].quantity
});
}
// Store the order in client-side storage until it can be saved to the server
localStorage.setItem("pendingOrder", JSON.stringify(newOrder));
Example 4: Create unique correlation IDs for logging or tracking:
// Start a process with a correlation ID for tracking
const processId = app.getGuid();
// Log the start of the process
console.log(`Process ${processId} started at ${new Date().toISOString()}`);
// Perform some operations
const result = processData();
// Log the completion with the same correlation ID
console.log(`Process ${processId} completed at ${new Date().toISOString()} with result: ${result}`);
Related Functions
getDeviceId()
- For retrieving a persistent device identifiergetBrowserToken()
- For retrieving a browser-specific identifier
Notes
- Each call to this function generates a new, unique GUID
- The generated GUIDs follow the standard UUID format (version 4, random)
- These IDs are generated client-side and are not registered in any central database
- While collisions are theoretically possible, they are extremely unlikely in practice
- These GUIDs are suitable for temporary IDs, but for permanent storage, server-generated IDs are recommended
- GUIDs are case-insensitive when comparing, but are typically displayed in lowercase