Skip to main content

Loan Request ID Generation

LoanRequestIdGenerator creates the human-readable RequestId stored on a LoanQuote. It replaces the previous day-and-hour-based reference, which could produce the same value when one customer requested the same product more than once within an hour.

Internal platform utility

This is a C# application utility used automatically by the loan-creation commands. It is not a JavaScript function and cannot be called from an execution engine script, workflow expression, or formula.

Method​

LoanRequestIdGenerator.Generate(
long loanQuoteId,
long? selfServiceUserId,
string productCode)

Generated format​

{customerReference}{productCode}-{loanQuoteId:D10}

For example:

00006PR-2-0000000101
ComponentExampleBehaviour
Customer reference00006Uses SelfServiceUserId, padded to at least five digits. A missing value becomes 00000.
Product codePR-2Trimmed and converted to uppercase. A missing or blank value becomes LOAN.
Loan quote ID0000000101Uses the persisted LoanQuote.Id, padded to at least ten digits.

Why the value is unique​

The loan quote is saved first so that the database assigns its existing primary key, LoanQuote.Id. The request ID is then generated from that value and saved on the same record. Because each persisted loan quote has a different primary key, two concurrent applications cannot receive the same generated request ID.

No GUID, timestamp, random value, new database column, or schema migration is required.

await loanQuoteRepository.AddAsync(loanQuote);
unitOfWork.SaveChanges(); // Populates loanQuote.Id.

loanQuote.RequestId = LoanRequestIdGenerator.Generate(
loanQuote.Id,
loanQuote.SelfServiceUserId,
loanQuote.LoanProductCode);

loanQuoteRepository.UpdateAsync(loanQuote);
unitOfWork.SaveChanges();

Validation and normalisation​

  • loanQuoteId must be greater than zero. Calling the utility before the quote has been persisted throws ArgumentOutOfRangeException.
  • Customer and loan quote numbers use invariant-culture numeric formatting.
  • Product codes are trimmed and normalised to uppercase.
  • The generated value is deterministic: the same inputs produce the same value.

Where it is applied​

The generator is applied by both supported loan-origination entry points:

  • Self-service loan requests.
  • Administrator-created loans for new and existing customers.

Downstream process events use the saved LoanQuote.RequestId, ensuring that the reference in event context and logs is the same value stored on the loan quote.

Operational notes​

  • This change guarantees uniqueness for newly created loans through the application creation paths. Existing duplicate request IDs are not rewritten.
  • RequestId does not currently have a database unique constraint. Direct SQL changes or another writer that bypasses the generator can still introduce an invalid or duplicate value.
  • LoanQuote.QuoteId remains a separate internal GUID and is not used to form the human-readable request ID.

See also​