Changing a Taxonomy Term initially set from an Entity Reference Field

Created on 8 May 2023, about 1 year ago
Updated 3 August 2023, 11 months ago

I have created a taxonomy list called 'Work Status', with the terms: 'Not Required', 'Instructed', 'Confirmed', 'In Progress' and 'Completed'.

My plan is to use the terms with this taxonomy list to track the progress of work being done by a contractor. So, for example, when a work job is created, and the user requests for a contractor to complete a specific task within the job, then ECA would be used to send an email to the contractor, and then also to change the value of a 'work_status' token within ECA from the 'Not Required' term to the 'Instructed' term.

Then, as the contractor, completes various operations along the journey to complete the task, then ECA would be used to move the 'work_status' along the various taxonomy term options, through to β€˜Completed’.

I have used an entity reference field within the 'Job' content type, linking to the 'Work Status' terms, leaving it as a hidden field and hoping that this would be a way for ECA to load and update the contractor's progress, using the various conditions to trigger the updates to the field.

So, when a new job entity in created, a check is made on whether the user has requested a contractor to complete a task, and if the answer yes, then the work status is updated from 'Not Required' to 'Instructed'.

Anyway, I haven't been able to figure out how to load the 'Instructed' term and replace the original 'Not Required' value of the entity referenced filed with it..

I can't seem to be able to alter the taxonomy term, or even load the correct term (Instructed) from the taxonomy list.. I have tried several ways, including using Type and ID, but obviously haven’t been able to wrap my brain around a solution.

Is there way of getting this done, or am I asking too much of ECA... My guess is that I'm going around this the wrong way, and it might be better to use flags, or something similar, but I thought I see is there is a straightforward solution for this..? I have looked through the existing documentation but cannot find anything that has helped me so for.

I hope that I been able to explain my problem adequately and look forward to being told how silly I am for not working this out on my own.

Thank you…

πŸ’¬ Support request
Status

Closed: outdated

Version

1.1

Component

Miscellaneous

Created by

πŸ‡¬πŸ‡§United Kingdom alastairworters

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @alastairworters
  • πŸ‡©πŸ‡ͺGermany jurgenhaas Gottmadingen

    Loading a taxonomy term entity works with the Entity: load action with the following settings:

    • Load entity from: Type and properties
    • Entity type: Taxonomy term
    • Property values:
      name: "Not Required"
      vid: "work_status"
      

    However, I wonder if this requirement is best suited with taxonomy terms. Have you thought about using workflow or state machine instead?

  • πŸ‡¬πŸ‡§United Kingdom alastairworters

    Thank you, for both the ECA solution and also the suggestion for the alternative way of solving the concept… with Workflow or State Machine.

    Sometimes I should take a step back from the problem and look at the bigger picture, rather than heading down a one way path!!

    Thanks again 😊

  • πŸ‡¬πŸ‡§United Kingdom alastairworters

    Hello again,

    I have changed the process to work with the workflow module, but again am struggling to get an ECA model to change a field value from one state to another..

    Are there any instructions, or even video tutorials, on how to move from one workflow state to another using ECA?

    Thank you and apologies for not being able to figure this out on my own.

  • πŸ‡©πŸ‡ͺGermany jurgenhaas Gottmadingen

    To change the workflow state of an entity, you can use the Entity workflow Editorial: transition action.

    To change other field values, there is the Entity: set field value action.

  • πŸ‡¬πŸ‡§United Kingdom alastairworters

    Thank you again Jurgen.. Very helpful and I now have the model working!

    One last question on this, if that's ok.. and not really specifically on ECA. But maybe you would be kind enough to tell me what would be the token to use, for displaying a message to the user after the transition has happened, saying "The Workflow Status has been updated to: [work_status - New Status]" ?

    Thank you...

  • πŸ‡©πŸ‡ͺGermany jurgenhaas Gottmadingen

    The workflow module perhaps doesn't provide a token for that. But since you know to which state you've just transitioned, you may be able to use a static text for the message too? Otherwise, if you want to make your model more generic, you could use the Token: Set value action to define the new state label like a variable and then use that token in the message.

  • πŸ‡¬πŸ‡§United Kingdom alastairworters

    So.. following your help and some further reading, I decided to use workflows (within core) with ECA to automatically update the workflow status, as certain milestones were met. However, I've now run into another issue, which looks like I will need to change my approach again, and I am hoping you could possibly let me know your thoughts on the best way forward using ECA to 'automatically' update the state of a workflow...

    As per my initial comment (#1), I am looking to build a way to follow the progress of a specific job allocated to a contractor, changing the 'status' of the job as certain milestones are met throughout the task. And with your guidance, I have been able to get the 'status' automatically updated using ECA, along with ECA Workflow module, working with the Drupal Workflows (core) module..

    Unfortunately, although this solution has been testing well today issuing a single job to a contractor, I cannot find a way of introducing multiple jobs being issued to various contractors within the same project, and can only get it to control the workflow of a single 'job' within a main 'project' content type.

    e.g. A new Project (a content type) is created by a user that, based on the answers given, automatically sends emails to various contractors, instructing each of them to carry out a specific job, all as part of the main project. Then the plan is to allow each of the contractor's progress to be tracked through the various workflow states, from the initial 'Instruction' through to their specific job within the project being automatically marked as 'Completed' when the last milestone has been reached.

    Now, after introducing more than one job with the project, I see that only one workflow (made within the workflows core module) can be applied to a content type... meaning that I can only control the status of one 'job', with in the 'project' content type...

    Anyway, after a bit of reading this evening, it appears that the Workflow (contrib) module allows multiple workflows to be applied to a content type.

    Hopefully that all makes sense....??

    So my question is this - Please can you let me know how ECA interacts with the Workflow (contrib) module.. ie. is there a elegant task/action I can use within an ECA model that allows me to change the state of a Workflow (contrib) based workflow, just like the ENTITY WORKFLOW WORK STATUS: TRANSITION one that works with the Workflow (core) workflows..?

    As always, I have exhausted my caffeine allowance and my skill levels are letting me down..

    Thank you...

  • πŸ‡©πŸ‡ͺGermany jurgenhaas Gottmadingen

    This doesn't sound like an ECA question, it's more about data modelling in the first place.

    First, if you have a choice between the contrib "workflow" module and the core "workflows" module, I'd always go for the latter one. For a lot of reasons, but that discussion is out of scope for this issue.

    Reading through your requirements in comment #8, it sounds like you could work with 2 content types: project and task. Each project has a list of references to 1 or more tasks. And each task has a workflow state, which goes through all the stages you described.

    Then, when all tasks of a project reached the completed state, then the project can be flagged as completed as well.

  • πŸ‡¬πŸ‡§United Kingdom alastairworters

    Thank you Jurgen,

    I appreciate you taking the time to let me know your thoughts on working with Workflows and various ways they interact with ECA, and also your suggestions on how to find a solution for my particular data modelling / workflows issues..

    Very helpful indeed.

  • πŸ‡©πŸ‡ͺGermany jurgenhaas Gottmadingen

    @alastairworters what's the status of this, is your issue resolved or do you have any follow-up questions for ECA here?

  • Status changed to Postponed: needs info 12 months ago
  • πŸ‡©πŸ‡ͺGermany jurgenhaas Gottmadingen
  • Status changed to Closed: outdated 11 months ago
  • πŸ‡©πŸ‡ͺGermany jurgenhaas Gottmadingen
Production build 0.69.0 2024