I want to set a field using a workflow to: red, yellow, or green based on some pretty simple logic that references other fields. How do I do that in the Workflow actions? Right now it feels rigged as I just use the “Only When” condition at the bottom of three actions. That is, “only when X” set to red … next action “only when Y” set to green …
Method 1:
Use the “Only When” feature in the workflow, NOT the actions. So essentially, you’ll have 3 workflows with 1 action each instead of 1 workflow with 3 actions.
Method 2:
PART 1
If you’re using an input (maybe a dropdown input) to choose the color, I’d suggest creating a database table called Colors. 2 fields only. “color” would be the color as a text AND “rank” would be a number (1,2, or 3) used to rank (sort) the colors in whatever order you desire. Then use that new Colors table as the data source for the dropdown.
PART 2
Now in your workflows, you’ll only need 1 workflow and 1 action. The field you’re changing in your action can now be set to the color chosen from the dropdown.
Hope this makes sense. Either should work if I understand your problem correctly.
Let me know how this goes,
Daniel
If I understand correctly, this seems ideally suited to the use of “states”, which are basically just internal properties of an element. Add a state (and the appropriate conditions) to the field whose color you want to change. Then, just simply set the state from workflow.
Thank you for the help. I think I need to provide more context.
-
I need this to be data that is recorded in the table vs. using states. This is because I have other functionality that will require me to show a history of this field (red, yellow, or green).
-
I need to set this field based on other fields that come in via an api. I have the endpoint all set up and it’s working fine. What I need is to change the color_status field based on the combinations of two other fields. This logic will be something like IF(XA+YB) ELSE C
What triggers the workflow? Are all of the fields stored in the db? If so, are they saved at the same time?
Any reason a custom state can’t be stored in the db?
It is a webhook so it’s triggered by an external service. Yes, the webhook updates all fields at the same time. I would want to update the color_status field after those fields have been updated.
I guess I’m not familiar with custom states to answer that question. I didn’t think of using states at all since it seems more like a calculated field to me. I’m open to the solution though if you think it’s the best/only approach.