Text merge

  • Thread starter Thread starter Andrus
  • Start date Start date
A

Andrus

I have signature templates containing variable parts like user name between
<< and >> signs, like

Best regards,
<<User.FirstName>> <<User.FirstName>>
MyCompany
Baker street 123
Phone: <<User.Phone>>


How to replace fields between << and >> marks with current values in
runtime ?
Is it possible to evaluate expressions also if << >> contains expressions ?

Andrus.
 
Andrus said:
I have signature templates containing variable parts like user name
between << and >> signs, like

Best regards,
<<User.FirstName>> <<User.FirstName>>
MyCompany
Baker street 123
Phone: <<User.Phone>>


How to replace fields between << and >> marks with current values in
runtime ?

Create a method that returns the value when you send it the key of a
variable:

private static string GetValue(string key) {
switch (key) {
case "User.FirstName": return "Göran";
case "User.LastName": return "Andersson";
case "User.Phone": return "012-34 56 78";
default: throw new ArgumentOutOfRangeException("key", key, "Unknown
key.");
}
}

Then you can use that with a regular expression that replaces the variables:

Is it possible to evaluate expressions also if << >> contains expressions ?

Everything is possible, but that is quite a bit trickier. What kind of
expressions were you thinking of?
 
Göran,

thank you very much.
Everything is possible, but that is quite a bit trickier. What kind of
expressions were you thinking of?

Expression are simple expressions e.q if contact person name is not
specified, use copmany name, otherwize use contact person name like

<< Iif(Customer.LastName!=null, "Dear " + Customer.LastName,
Customer.CompanyName) >>

They should hect
Andrus.
 
Back
Top