Read the statement by Michael Teeuw here.
CalendarExt3 - Event transformer wildcard
-
if (ev.title.search("YCBM") > -1) { ev.title = "Client" }did you mean replace ycbm w client?
-
@BKeyport search is like indexOf
let r=ev.title.search("YCBM") or let r=ev.description.search("YCBM") if (r > -1) { ev.title = "Client" } -
@sdetweil What I meant is to replace the Client’s name with “Client” - it’s a wildcard.
The “YCBM” is in the event description to help my booking manager (YouCanBook.ME) to track the bookings for me.
-
@BKeyport ok, what does ‘clients name’ look like
any examples?
-
BEGIN:VEVENT DTSTART:20250417T020000Z DTEND:20250417T030000Z DTSTAMP:20250215T064845Z UID:sla6c0fbp2f6m06mscbt8961hg@google.com CREATED:20250215T064259Z DESCRIPTION:<p>Phone: +12015551212<br />Email: test@email.com<br />Notes: S pecial Request</p>\n<p><a href="">Reschedule this booking</a><br /><a href="">Cance l this booking</a></p>\n<p>YCBM link ref: e4c41a9e-28a5-4528-90e8-dd8a18c64 ae5</p> LAST-MODIFIED:20250215T064333Z SEQUENCE:0 STATUS:CONFIRMED SUMMARY:Client Name TRANSP:OPAQUE END:VEVENTWeb links removed, Test client deleted, so no clicky. The event title is solely the client name, but that can be adjusted if need be, I think.
-
@BKeyport ok, this should work
if(ev.description.search("YCBM")>-1){ ev.title = "Client" }you already have the
return evyou can
console.log(ev.description)
to make sure it is what you expectbetter if mmm-logging is installed to copy the browser log to startup log
-
@sdetweil perfection, thanks. Never even thought about direct replacement - only seen more complex solutions.
-
S sdetweil has marked this topic as solved on
-
I think we’re gonna have to call @MMRIZE in on this one. it worked initially - however, if the description is blank in any event, it’ll stop completely, and not process anything. Here’s what I got now.
eventTransformer: (ev) => { if (ev.title.search("🏠") > -1) { ev.title = ev.title.replace("🏠 Personal Commitment", "Personal Event"); ev.color = 'yellow'; } if (ev.title.search("✈ Flight") > -1) { ev.title = ev.title.replace("✈ Flight", "Personal Event"); ev.color = 'yellow'; } if(ev.description.search("YCBM") > -1) { ev.title = "Client" } return ev }, -
B BKeyport has marked this topic as unsolved on
-
-
@sdetweil That did it… Well, other than typing out event rather than ev. :)
All the same, Maybe it should be a check inside the javascript…
-
B BKeyport has marked this topic as solved on
-
For completeness - here’s the answer:
if(ev.description && ev.description.search("YCBM") > -1) { ev.title = "Client" } -
B BKeyport has marked this topic as solved on
-
@BKeyport sorry, phone decided to autocorrect for me.
but you got it. this IS javascript. without the test, the transformer crashed
-
@sdetweil right - what I’m saying is that maybe it should be in the module’s JS, rather than the config’s JS.
Seems trivial to add a safeguard to automatically check for empty items before the transformer gets it. Might also protect against other bugs that way, thus improving the overall product.
-
@BKeyport ah, but description is an optional field
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login
