Skip to main content

Notifications

Microsoft Dynamics CRM (Archived)

calculated field to generate user initials

Posted on by 365

When we create orders in CRM, they are sent over to GP. When they go over to GP they are printed as invoices and we need to know who to hand them to. I would like the initials of the user who created the order to be sent over.

I would therefore like a calculated field on an order entity that takes the created by field and turns "John Smith" into "JS" and "Adam Jones" into AJ etc. I can then use these initials in my mapping over to GP. Taking the full name uses too many characters in GP hence my need for just initials.

Thanks

*This post is locked for comments

  • Suggested answer
    Abed Haniyah Profile Picture
    Abed Haniyah 4,285 on at
    RE: calculated field to generate user initials

    You can use normal text field instead of calculated field, then by using javascript code you fill it by first letter of each word in a string ( Use Full Name):

    First you need to get the value of created by:

    var createdby    =Xrm.Page.getAttribute("createdby").getValue();

    Then you can get the first letter of each word in a string by :

    var matches = createdby.match(/\b(\w)/g);

    var initial = matches.join('');  

    Then set the field value by :

    Xrm.Page.getAttribute("new_field").setValue(initial);

  • Suggested answer
    Wayne Walton Profile Picture
    Wayne Walton 13,726 on at
    RE: calculated field to generate user initials

    How are you handling collisions?  Such as, if you have Wayne Walton and Will Wheaton in the CRM system, having both of them listed as WW would be an issue.

    My suggestion would be to update the User record with an Initials area and manually choose everyone's initials.  Then update your GP integration to look up the Initials field instead of the full name field.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,253 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans