Announcement

Collapse
No announcement yet.

Help needed with calendar events / tasks with colors depending on the status

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • #16
    I renamed Task module to Job Cards.
    Attached Files

    Comment


    • #17
      try this code below

      PHP Code:
      if(entity\isAttributeChanged('status')) {
          if(
      status == "Not Started") {entity\setAttribute('cColor''#6fa8d6');}
          if(
      status == "Started") {entity\setAttribute('cColor''#5cb85c');}
          if(
      status == "Completed") {entity\setAttribute('cColor''#f0ad4e');}
          if(
      status == "Canceled") {entity\setAttribute('cColor''#d9534f');}
          if(
      status == "Deferred") {entity\setAttribute('cColor''#5bc0de');}
      }
      ​ 

      THIS WILL NOT WORK. THE CUSTOM FIELD MUST BE NAME 'color' NOT 'cColor'
      Last edited by rabii; 06-22-2024, 01:20 PM.
      Rabii
      Web Dev | Freelancer

      Comment


      • Iphahla
        Iphahla commented
        Editing a comment
        Hi Rabii,

        I've tried the above code - no luck. Thanks so much for your assistance though!

        Just to confirm - the formula is to create different colored tasks in my calender - based on the status of the task.
        In other words - if I have a "status" called "job" or "request for quote" for example, they must display as different colored tasks in the calendar.

        What is the purpose of the "varchar" named "color"? Maybe if I understand the purpose I can figure out another way to do this? When I create a new task, it still gives me the options "danger" etc. What if I change these (danger/success/warning etc.) to different colors?
        Last edited by Iphahla; 06-22-2024, 06:15 AM.

      • rabii
        rabii commented
        Editing a comment
        Hi,

        This should work however it seems you are using the latest version of espocrm which add a prefix of letter 'c' to custom fields.

        in order for this to work on any event entity, you should add a field called (color) a varchar that reflects the colors on the calendar. However since you are using the latest version you custom field is called (cColor) that is why the system can't map the field to the color of the calendar. You need to disable this prefix option or you can just create a varchar in metadata called (color) and that should work fine.

      • Iphahla
        Iphahla commented
        Editing a comment
        Thank Rabii, will try to disable the prefix! Thanks!

        Update: IT WORKED! Thanks so much!!!!
        Last edited by Iphahla; 06-22-2024, 02:19 PM.

    • #18
      Note: I have managed to get it to work when I create a new event type Entity. Have copied the code / varchar and edited it for "Task", still doesnt work for Task. But works for new entity. Could this be a back end coding issue?

      Comment

      Working...
      X