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

  • Iphahla
    commented on 's reply
    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.

  • rabii
    commented on 's reply
    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
    replied
    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?

    Leave a comment:


  • Iphahla
    commented on 's reply
    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
    replied
    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.

    Leave a comment:


  • Iphahla
    replied
    I renamed Task module to Job Cards.
    Attached Files

    Leave a comment:


  • Iphahla
    commented on 's reply
    Hi Rabii,

    This is my formula in Task Entity:

    ifThen(entity\isAttributeChanged('status'),
    ifThen(status == "Not Started", entity\setAttribute('color', '#6fa8d6'));
    ifThen(status == "Started", entity\setAttribute('color', '#5cb85c'));
    ifThen(status == "Completed", entity\setAttribute('color', '#f0ad4e'));
    ifThen(status == "Canceled", entity\setAttribute('color', '#d9534f'));
    ifThen(status == "Deferred", entity\setAttribute('color', '#5bc0de'));
    )

    I will post a screenshot also

  • rabii
    replied
    can you share your code here and also if you are using the latest version of espocrm the field will be prefixed with letter c so myfield will be cMyfield.

    Leave a comment:


  • Iphahla
    replied
    Hi all, I've tried to do the above in my system, as I would like to have different colors for different "Tasks" in my Calendar (planner), but when I look on my Calendar, it still only gives me the one colour (in my case RED) for the Tasks I've loaded.

    I've tried all the above solutions.

    I was wondering if maybe the new field created "color" (Varchar) should be "read only" maybe, or should have pre-defined options maybe?

    Any assistance will be much appreciated!

    Leave a comment:


  • geonaute
    replied
    Originally posted by yuri View Post
    Use == instead of ===. === not supported in formula.
    Thank you so much Yuri, rabil and all that lost time to assist me.

    It is working now at 100%. Amazing!!!

    Thank you for all the support.

    Leave a comment:


  • yuri
    replied
    Use == instead of ===. === not supported in formula.

    Leave a comment:


  • geonaute
    replied
    Originally posted by geonaute View Post

    Hi Rabii, Thank you for your assistance regarding my challenge with the calendar.

    I have tried to make the steps advised by Yuri and you but I did not have any sucess.

    I am missing something in here.

    1- I created the new varchar field for my "event" with the name color. (Please see picture attached.

    2-- I wrote on the formula field your formula, but when entering the calendar, nothing changed.

    Any ideas which step I am doing wrong?

    Thanks
    Hi rabil,

    Thank you for your comments, I almost missed them in the forum.
    I have been banging my head against the wall to try to fix this one.

    When adjusting the quote as suggested by you, I tried to verify it and it is giving a syntax error. Already tried to review it several times with no sucess.

    Please see attached picture. And also my "Status field" details.

    The code:

    ifThen(entity\isAttributeChanged('status'),
    ifThen(status === "Planned", entity\setAttribute('color', '#6fa8d6'));
    ifThen(status === "Confirmed", entity\setAttribute('color', '#5cb85c'));
    ifThen(status === "On Hold", entity\setAttribute('color', '#f0ad4e'));
    ifThen(status === "Canceled", entity\setAttribute('color', '#d9534f'));
    ifThen(status === "Completed", entity\setAttribute('color', '#5bc0de'));
    )



    Thanks again for the amazing support.
    Last edited by geonaute; 04-24-2022, 05:45 AM.

    Leave a comment:


  • rabii
    commented on 's reply
    Just seen your first post pictures and it seems that your status has (Planned, Confirmed, On Hold, Canceled, Completed), therefore please use the formula below:

    Code:
    ifThen(entity\isAttributeChanged('status'),
    ifThen(status === "Planned", entity\setAttribute('color', '#337ab7'));
    ifThen(status === "Confirmed", entity\setAttribute('color', '#5cb85c'));
    ifThen(status === "On Hold", entity\setAttribute('color', '#f0ad4e'));
    ifThen(status === "Canceled", entity\setAttribute('color', '#d9534f'));
    ifThen(status === "Completed", entity\setAttribute('color', '#5bc0de'));
    )
    Remember that this code will be executed once the status field has changed, so if you want to try it out you need to update some events's status field to reflect the changes in the calendar.

    Good luck

  • rabii
    commented on 's reply
    I noticed that you have an entity called Booking, is it an event type entity ?

    If yes, please note that new event Entities will only have a status with values [ Planned, Held, Not Held], so in this case the code should be:

    Code:
    ifThen(entity\isAttributeChanged('status'),
    ifThen(status === "Planned", entity\setAttribute('color', '#6fa8d6'));
    ifThen(status === "Held", entity\setAttribute('color', '#7cc4a4'));
    ifThen(status === "Not Held", entity\setAttribute('color', '#ed8f42'));
    )
    if you wish you can extend the values in status and add more status and just update the formula to update color based on new values.

    try this code on the Booking formula and just try to update the status and it should work. you are just missing the correct values of the status field of your booking entity. you can share your progress and we are happy to help.

  • geonaute
    replied
    Originally posted by yuri View Post
    Did you create new events? This should apply to new events, not existing ones, as the formula script runs only when create/edit records.

    You can run re-calculate formula from the list view > select all results > actions to apply the script for all records.
    Hi Yuri,

    Thank you again for your help on this one.

    I am almost sure that I am missing something from my side.
    Basically I ested to create a new entrie and still only shows green.

    Regarding your suggestion, " you can run re-calculate formula from the list view > select all results > actions to apply the script for all records. " I have no idea where to find this List view. Newbie here.

    Still learning Espo on the go as needed.

    Looking forward for some guidance.

    Thank you so much for all the assistance


    Leave a comment:

Working...
X