{"id":17405061,"url":"https://github.com/jongpie/apexuuid","last_synced_at":"2026-01-25T00:01:49.577Z","repository":{"id":98193643,"uuid":"81063353","full_name":"jongpie/ApexUUID","owner":"jongpie","description":"A small library to provide UUID generation and validation in Apex","archived":false,"fork":false,"pushed_at":"2026-01-20T23:04:31.000Z","size":160730,"stargazers_count":65,"open_issues_count":3,"forks_count":23,"subscribers_count":6,"default_branch":"main","last_synced_at":"2026-01-21T09:27:47.828Z","etag":null,"topics":["apex","apex-guid","apex-uuid","forcedotcom","guid","salesforce","uuid","uuid4"],"latest_commit_sha":null,"homepage":"","language":"Apex","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jongpie.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2017-02-06T08:10:50.000Z","updated_at":"2025-04-03T18:00:45.000Z","dependencies_parsed_at":"2024-01-16T00:52:00.938Z","dependency_job_id":"54fac96f-18f0-4c5a-8684-bd11530cf508","html_url":"https://github.com/jongpie/ApexUUID","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/jongpie/ApexUUID","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jongpie%2FApexUUID","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jongpie%2FApexUUID/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jongpie%2FApexUUID/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jongpie%2FApexUUID/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jongpie","download_url":"https://codeload.github.com/jongpie/ApexUUID/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jongpie%2FApexUUID/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28739320,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-24T22:12:27.248Z","status":"ssl_error","status_checked_at":"2026-01-24T22:12:10.529Z","response_time":89,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["apex","apex-guid","apex-uuid","forcedotcom","guid","salesforce","uuid","uuid4"],"created_at":"2024-10-16T20:22:47.459Z","updated_at":"2026-01-25T00:01:49.560Z","avatar_url":"https://github.com/jongpie.png","language":"Apex","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Apex UUID\n\nProvides a way to generate a [UUID (Universally Unique Identifier)](https://en.wikipedia.org/wiki/Universally_unique_identifier) in Salesforce's Apex language. This uses Verion 4 of the UUID standard - more details available [here](\u003chttps://en.wikipedia.org/wiki/Universally_unique_identifier#Version_4_(random)\u003e)\n\n## Unlocked Package (no namespace) - v2.1.0\n\n[![Install Unlocked Package in a Sandbox](./images/btn-install-unlocked-package-sandbox.png)](https://test.salesforce.com/packaging/installPackage.apexp?p0=04t4x000000NYNEAA4)\n[![Install Unlocked Package in Production](./images/btn-install-unlocked-package-production.png)](https://login.salesforce.com/packaging/installPackage.apexp?p0=04t4x000000NYNEAA4)\n\n# Getting Started\n\n## Generating \u0026 Using A UUID\n\nTo generate a UUID, simply instantiate a new instance. The string value can be retrieved with `getValue()`\n\n```java\nUuid myUuid = new Uuid();\nString myUuidValue = myUuid.getValue();\n```\n\nYou can use the UUID value as a unique ID, generated by Apex. This lets you do some powerful things in Apex when your objects have external ID fields to store the UUID value.\n\nIt's best if you create a custom field on your object to store the UUID value with these properties: Text(36) (External ID) (Unique Case Insensitive).\n\nIn the code samples below, the field name Uuid\\_\\_c is used as an example field name.\n\n\u003e #### Example: Using a code-generated external ID (such as a UUID), we can create multiple accounts and related contacts with only 1 DML statement\n\n```java\nList\u003cSObject\u003e recordsToCreate = new List\u003cSObject\u003e();\n// Create 10 sample accounts\nfor(Integer accountCount = 0; accountCount \u003c 10; accountCount++) {\n    // Create a new account \u0026 set a custom external ID text field called Uuid__c\n    Account newAccount = new Account(\n        Name    = 'Account ' + accountCount,\n        Uuid__c = new Uuid().getValue()\n    );\n    recordsToCreate.add(newAccount);\n\n    // For each sample account, create 10 sample contacts\n    for(Integer contactCount = 0; contactCount \u003c 10; contactCount++) {\n        // Instead of setting contact.AccountId with a Salesforce ID...\n        // we can use an Account object with a Uuid__c value to set the Contact-Account relationship\n        Contact newContact = new Contact(\n            Account  = new Account(Uuid__c = newAccount.Uuid__c),\n            LastName = 'Contact ' + contactCount\n        );\n        recordsToCreate.add(newContact);\n    }\n}\n// Sort so that the accounts are created before contacts (accounts are the parent object)\nrecordsToCreate.sort();\ninsert recordsToCreate;\n\n// Verify that we only used 1 DML statement\nSystem.assertEquals(1, Limits.getDmlStatements());\n```\n\n### Using a UUID's string value\n\nIf you already have a UUID as a string (previously generated in Apex, generated by an external system, etc), there are 3 static methods to help work with the string value.\n\n1. **Do I have a valid UUID value?**\n\n   This checks if the string value matches the regex for a UUID v4, including hyphens (but it is case-insensitive)\n\n   ```java\n   Boolean isValid = Uuid.isValid(myUuidValue);\n   ```\n\n2. **I have a UUID value but need to format it**\n\n   This returns a formatted string that follows the UUID pattern 8-4-4-4-12 in lowercase. If an invalid string is provided, a UuidException is thrown.\n\n   ```java\n   String formattedUuidValue = Uuid.formatValue(myUnformattedUuidValue);\n   ```\n\n3. **I have a UUID value, how can I use it to construct a UUID?**\n\n   This will automatically format the value for you, but the intial value must be a valid (unformatted) UUID string\n\n   ```java\n   Uuid myUuid = Uuid.valueOf(myUuidValue);\n   ```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjongpie%2Fapexuuid","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjongpie%2Fapexuuid","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjongpie%2Fapexuuid/lists"}