Skip to main content
16-Pearl
July 17, 2025
Solved

Accessing State Definition Style Information via Service

  • July 17, 2025
  • 1 reply
  • 307 views

Hi ThingWorx Community,

I’m working with a State Definition (project.States.SD) where each state (e.g. taskCreated, taskAssigned, taskInProgress, etc.) has its own display‐style (colors, icons, shapes) configured in Composer:

 

 

 

Right now, to apply those styles at runtime I’ve been hard‑coding the color/icon mappings in my mashup scripts. What I’d really like is to dynamically retrieve the full style definition (all state keys, display names, style palettes, icons, etc.) via a service call.

My questions:

  1. Is there a built‑in ThingWorx service (for example under DefinitionServices or MetadataManager) that returns the complete style configuration for a given State Definition?

  2. If not, is there a recommended pattern or existing code snippet for querying a State Definition’s metadata (including style properties) at runtime?

Any pointers, sample code or best‑practice guidance would be hugely appreciated!

Thanks in advance,

Best answer by Rocko
let params = { name: "SimpleAlarm", type: "StateDefinitions" };
result = Resources["EntityServices"].ReadEntityAsJSON(params);

 

1 reply

Rocko
Rocko19-TanzaniteAnswer
19-Tanzanite
July 17, 2025
let params = { name: "SimpleAlarm", type: "StateDefinitions" };
result = Resources["EntityServices"].ReadEntityAsJSON(params);