Xmerge coding query
Might be one for you courtney.youngblutt.
Can you adapt this code to display the previous month?
<:=datetime_merge.format(‘%Y %B’):> (2025 April)
Can we make it display 2025 March? I want to use this in an email template and email subject line.
Thank you as always. I will give this a crack, and it should work for my purpose as I will be sending automated monthly reports from IPS to our clients approximately mid month.
2 Replies
- courtney.youngblutt
Iress Contributor
Thanks luke.watson3 - I am definitely not a champion coder and had to use a lifeline for this one. 😄
The tricky bit with this is that email syntax differs from xmerge syntax used in word templates. So while <:= dateutils.dateToStr(dateutils.getEndOfLastMonth(int(today)), format='%Y %B'):> works in a word document, it doesn't work in an email template.
For email try:
<:=datetime_merge.fromordinal(datetime_merge.toordinal() - 30).strftime('%Y %B'):>
⚠️ There is a limitation though - this code will merge the month based on the date that was 30 days ago (-30). So if the email is sent on the 15th of the month, you will likely get the result you are after, but if sent on the 31st day of a month, it won't work as expected.
Let me know if the code I provided doesn't do what you need it to and we can brainstorm some alternatives.
Otherwise, I'd love to hear from any expert coders out there who may have an alternative solution for email syntax that might work in this instance.
And while the answer to your specific question Luke, was not in our Community resources, for others who might be reading this - there is a reasonably comprehensive library of codes in the Xmerge Library in Community that can be useful when trying to source codes for your templates. I've also found the blog articles on the following website to be super useful in helping me understand how xmerge code functions - https://www.createsomething.com.au/blog/
And, while again it didn't help me in this particular instance - Chat GPT or similar has also helped me work out codes in the past!
- luke.watson3
Advisely Contributor
Thank you as always. I will give this a crack, and it should work for my purpose as I will be sending automated monthly reports from IPS to our clients approximately mid month.
Recent Discussions
🤓 Xplan Hint: Client Hub - your one-stop-shop for client activity
Did you know the Xplan Client Hub is essentially a one-stop-shop for all client activity? Centralise the way you work and stop navigating between screens, the Client Hub should be your go-to page f...courtney.youngblutt3 days agoIress Contributor6Views0likes0CommentsThe Meeting System Myth: Why Structure Beats Style Every Time
A well-run financial planning business doesn’t just deliver advice – it delivers it predictably. Inconsistency across key meetings – the Initial Appointment, the Statement of Advice Presentation, or ...marklewin15 days agoValued Supporter15Views3likes0CommentsForm type Checklist in Notes for ongoing use?
Hi All, Has anyone set up or created a form type document in Xplan notes. I have used Note Templates before and am aware I can use a table. Or a merge output however we don't want to re-tick opt...sarah.burke385 days agoActive Interactor55Views1like2CommentsThe Offshoring Blind Spot: How Poor Systems Cripple Profitability
Australia is experiencing a unique mismatch: adviser head-count has fallen by roughly 40 % since 2019, yet the pool of advice-seeking households keeps growing as 3.6 million baby-boomers move deeper ...marklewin15 days agoValued Supporter50Views3likes2Comments