Reputation: 1476
Hey I would like to know what is the way to populate multiple line field by plugin, I need to start a new line in the multiple line field. my code is:
foreach (Entity ent in allMyEnts.Entities)
{
//base_filesName is the multiple field need to be filled
//inside my loop
entityHoldsMultipleLineField.base_filesName =ent.base_name;
}
Or should I create an Array and populate my field with a loop ? What is the best way?
Upvotes: 0
Views: 1989
Reputation: 7224
First, you have a bug in your code with Entity ent
because you then refer to ent.base_name
- this won't work because you are calling the object as an early-bound entity but you are casting it as late-bound in the foreach
statement. I'm going to assume you intended to use late-bound for my answer (you can change this to early-bound, as needed.
A multi-line textbox is still a string
as far as Dynamics and .NET are concerned. You can use the StringBuilder
class to easily create a multi-line string and then add that the resultant string
(via .ToString()
) to the proper field.
var multiLineStringResult = new StringBuilder();
foreach (Entity ent in allMyEnts.Entities)
{
//base_filesName is the multiple field need to be filled
//inside my loop
multiLineStringResult.AppendLine(ent.GetAttributeValue<string>("base_name"));
}
entityHoldsMultipleLineField["base_filesName"] = multiLineStringResult.ToString();
Upvotes: 1