Jump to content

Omitting Certain Words from Data Field


Recommended Posts



I'm trying to set up a rule for a two-language (double-sided) marketing letter, and I'm running into difficulty setting up the salutation.


One side of the letter is in German and the other is in French. My data is in German but I need to remove the German words from the Name field for the salutation on the French side of the letter.


Also, some of the records have a generic salutation and others are personalized with the customer's name.


Below is the rule I have so far:


if (Field("SALUT") == "Sehr geehrte Damen und Herren")


return "<span>" + RawText("Chère Madame cher Monsieur") + "</span>";


if (Field("SALUT").indexOf("Frau") > -1)


return "<span>" + RawText("Chère") + RawText(" ") + (Field("NAME") + "</span>");


if (Field("SALUT").indexOf("Herr") > -1)


return "<span>" + RawText("Cher") + RawText(" ") + (Field("NAME") + "</span>");




return "<span>" + RawText("Chère Madame cher Monsieur") + "</span>";


return "";


The first part of the rule addresses the generic records, "Sehr geehrte Damen und Herren" being the generic German salutation and "Chère Madame cher Monsieur" being the generic French salutation.


The 2nd and 3rd if statements address whether to use the feminine or masculine version of the French salutation. "Chère" being the feminine and "Cher" being the masculine.


All is working fine until we get to the part where we add the Name field. All of the names are listed the way we address German customers.


Examples: "Frau Alexandra Roth" (feminine)

"Herrn Roger Brand" (masculine)


The customer's names are actually Alexandra Roth and Roger Brand. I need to remove the "Frau" and the "Herrn" from the returned text. The end result needs to be "Chère Alexandra Roth" and "Cher Roger Brand" instead of "Chère Frau Alexandra Roth" and "Cher Herrn Roger Brand."


Any help would be greatly appreciated.


Thank you

Link to comment
Share on other sites

You can replace the German words with the French words in the "NAME" field by using the replace method:

return Field("NAME").replace('Herrn', 'Cher').replace('Frau','Chère');

You could do the same for your generic salutation, as well:

return Field("SALUT").replace("Sehr geehrte Damen und Herren", "Chère Madame cher Monsieur");

If you're goal is to return the generic salutation when the "NAME" field is empty and otherwise return the value of the "NAME" field translated to French you could remove all of your 'if/else' statements and simplify your code:

return Field("NAME") ? Field("NAME").replace('Herrn', 'Cher').replace('Frau','Chère') : "Chère Madame cher Monsieur";

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...