Change date format field on word template from Dynamics 365 CRM

Anonymous
2019-08-23T14:38:58+00:00

Hi,

I wanted to know if there is a way to change the date format for a field pulled through from Dynamics 365 CRM in a word template. This is as part of the mail merge deprecation and transitioning over to word templates.

Basically, I have a date field (via developer, XML Mapping Pane tab) DD/MM/YYYY. I would like the field to be simply YY when it comes through into word.

Is this possible? Or will I have to create a new field in CRM to cater for this (which I don't really want to do).

Thanks,

Forid.

Microsoft 365 and Office | Word | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

9 answers

Sort by: Most helpful
  1. Jay Freedman 208K Reputation points Volunteer Moderator
    2019-08-27T21:02:09+00:00

    From the three-dot handle in the screenshot, I can see that the selected item is a content control, but I can't tell what kind of content control it is; I'll assume it's plain text. Also, I can't see what the control displays before it pulls the data from the CRM database. Anyway, this works for me:

    Click on the three-dot handle to select the whole control (but not the table cell that contains it). Press Ctrl+F9 to insert field braces around the control's contents. Between the opening brace and the original contents, type the word DATE, a space, and a double quote mark. Between the original contents and the closing brace, type a double quote mark, a space, and the switch @ "yy". It should look something like this:

    { DATE "27/8/2019" @ "yy" }

    Press F9 to update the field and display its result, which in this case will be 19. (If you really meant that you want the day, month, and two-digit year. the switch should be @ "dd/MM/yy".)

    Was this answer helpful?

    7 people found this answer helpful.
    0 comments No comments
  2. Jay Freedman 208K Reputation points Volunteer Moderator
    2019-09-04T18:36:18+00:00

    No, other than the switches there is no provision for any "active" programming in a mail merge. The remaining option is a macro that you run separately on the result of the merge to modify the contents of the box (is that a table cell?). I have very little familiarity with Dynamics CRM, so I'm not sure whether you can make it run such a macro automatically after the merge occurs, or whether you'd have to trigger it manually in Word. Properly, that would be a question for the Dynamics forum, https://community.dynamics.com/crm/f/microsoft-dynamics-crm-forum.

    Was this answer helpful?

    1 person found this answer helpful.
    0 comments No comments
  3. Jay Freedman 208K Reputation points Volunteer Moderator
    2019-09-02T16:00:53+00:00

    Which box is supposed to show the ID with the YY in the middle? Is it the one with the MERGEFIELD or the one that's empty?

    If it's the MERGEFIELD one, you're still seeing the field code. Can you right-click the code and click Toggle Field Codes in the menu? (Since the other fields appear to be showing their results, you must not have pressed Alt+F9, which would toggle all the field codes vs. their results.)

    It might help in diagnosing the problem if you show me the field code of the Collection Date field.

    Was this answer helpful?

    1 person found this answer helpful.
    0 comments No comments
  4. Anonymous
    2019-08-27T13:21:06+00:00

    Hi,

    Thanks for your reply.

    The word template is stored within D365 i.e. clicking the three dots, navigating to word templates and then selecting the template uploaded into D365 CRM.

    How would I edit the code? It doesn't appear to give me the option to edit anything as it does with mail merge fields.

    Was this answer helpful?

    1 person found this answer helpful.
    0 comments No comments
  5. Jay Freedman 208K Reputation points Volunteer Moderator
    2019-08-23T18:19:48+00:00

    Is the Word template stored in the Dynamics 365 project, or is it a separate file somewhere else? Wherever it is, you need to edit the code of the date's field to include the switch

    @ "yy"

    (and remove any other @ switch that already exists in that field).

    For more on switches in Word fields, see http://www.gmayor.com/formatting_word_fields.htm.

    Was this answer helpful?

    1 person found this answer helpful.
    0 comments No comments