Skip to main content
Utils provides small helper functions used by many components and services.

Unified WebSocket calls

These helpers use the built-in client instance (exported as MSM2App) to call the unified WebSocket JSON API:
  • callService(beanId, scope, functionName, args, eventType?, endpoint?)
  • callRepository(repositoryId, query, eventType?, endpoint?)
  • updateBean(beanId, scope, payload, eventType?, endpoint?)

Calling a backend service

callService returns a Promise containing the full client response. The backend value is in response.result:
Arguments are passed in the same order as the backend method parameters. Search requests commonly use a query object:
If the backend method expects a string, serialize the request with JSON.stringify(request). scope is usually PROTOTYPE; eventType can be USER, SHARED, or GLOBAL.

Calling a repository

Updating a bean

updateBean updates values on a bean registered with @Component or @Service.
All three helpers use the shared built-in MSM2App instance, which must be available before they are called.

Context and settings helpers

  • getLangCode()
  • getActiveLanguages()
  • getLanguageDetection()
  • getWebSiteSettings()
  • getCdnFolder()
  • getSecuredFolder()
  • getSeoUrl(entityId, repositoryName)
  • getSuperUserLogin()
  • getAttributeTypes()
  • getAttributeAreaTypes()
  • getFormattedDate(date, pattern)
  • isLogged()
  • getLoggedProfile()
  • isOpenAiActive()

Cookies and URL helpers

  • getCookie(name)
  • setCookie(name, value, expires?, domain?, path?)
  • deleteAllCookies(ignore)
  • getDomainName()
  • languageAwareUrl(url)
  • setPlatformInfo()
  • escapeRegExp(string)
  • getPayloadOfForm(element)