
Custom entity(event) - color in calendar based on the status
Collapse
X
-
espocrm when I copy paste it from here it adds dot at the end of the script and its returning syntax error, after removing the dot syntax is fine for me
-
do this to sort it out:
1. Create a new varchar field for your new entity event with the name 'color'.
2. Write formula that sets a HEX value to the 'color' attribute, depending on the 'status'.
PHP Code:ifThen(entity\isAttributeChanged('status'),
ifThen(status === "Planned", entity\setAttribute('color', '#0ea5e9'));
ifThen(status === "Held", entity\setAttribute('color', '#10b981'));
ifThen(status === "Not Held", entity\setAttribute('color', '#eab308'));
ifThen(status === "Finished", entity\setAttribute('color', '#14b8a6'));
)
Code:/// CODE GUI 1001 - Change color of Calendar for Task. ifThen(entity\isAttributeChanged('status'), ifThen(status == 'Not Started', entity\setAttribute('color', '#0ea5e9')); ifThen(status == 'Started', entity\setAttribute('color', '#10b981')); ifThen(status == 'Completed', entity\setAttribute('color', '#eab308')); ifThen(status == 'Canceled', entity\setAttribute('color', '#14b8a6')); ifThen(status == 'Deferred', entity\setAttribute('color', '#14b8a6')); ) ////////////////// CODE END
Anyway, Thank you!
Need to make decision on color later.Leave a comment:
-
rabii LuckyLouie hello guys, I just wanted to let you know that your solution is working perfectly fine as expected! thanks a lot for the helpLeave a comment:
-
Remember that color attribute is a bridge between the entity's status colors and the calendar display color. see this https://github.com/espocrm/espocrm/b...lendar.json#L3 -
for example if the status is "Not Held" the entity is being crossed out in the calendar. So I am wondering if I am able to control this behavior as well and if there is any attribute saying that it is crossed -
rabii LuckyLouie thank you guys for the tip! Please is there any place where I can check what other attributes the entity has like the color? Because when I check api json for the entity the attribute color is not there so without your help I would not be able to figure it out.
Leave a comment:
-
wow I did not know this is possible. So if I understand correctly the attribute color does not exist, but if I create an attribute with name "color" it controls the color of the entity? Iam asking because as LuckyLouie mentioned above I can change color directly without creating new attribute "color". Anyway, thanks a lot for this guys. This is new for me and it is going to be super usefull -
do this to sort it out:
1. Create a new varchar field for your new entity event with the name 'color'.
2. Write formula that sets a HEX value to the 'color' attribute, depending on the 'status'.
PHP Code:ifThen(entity\isAttributeChanged('status'),
ifThen(status == "Planned", entity\setAttribute('color', '#0ea5e9'));
ifThen(status == "Held", entity\setAttribute('color', '#10b981'));
ifThen(status == "Not Held", entity\setAttribute('color', '#eab308'));
ifThen(status == "Finished", entity\setAttribute('color', '#14b8a6'));
)
This will even change the colors of the event entity on the calendar to avoid mixing them with the other event entities like call - task - meeting.
I use this trick in almost all other custom events entities i add to the system and it makes the calendar clear.
UPDATE: FORMULA DOES NOT SUPPRT (===) IT SHOULD BE (==)Last edited by rabii; 06-14-2023, 03:42 PM.Leave a comment:
-
Hello,
Administration -> entity manager -> your entity -> formula
add code:
ifThen(
status == 'your custom status',
color = '#822f95'
);Last edited by LuckyLouie; 05-30-2023, 01:05 PM.Leave a comment:
-
Custom entity(event) - color in calendar based on the status
Hello guys,
I have created a new entity event with 3 default statuses and each is being displayed in the calendar with a bit different color which is perfect. However, I have added one more custom status "Finished" and it is being displayed with exactly same color as "Held". Is there any way how to change the color for that custom status?
Thanks a lot.Tags: None
Leave a comment: