Question

Concat text to form an email with multiple records

I want to concat multiple records into one text field to form a email with multiple records, for example list all products from an Order.

I've added a Read data (named ReadDataUserTask5) to my process and the added Script element like this:



 

var list = Get> ("ReadDataUserTask5.ResultCompositeObjectList");
 
var sb = new StringBuilder(); 
foreach (ICompositeObject item in list) 
{
  if (item.TryGetValue("Quantity", out decimal value)) {
    sb.Append(value.ToString()).Append("x\t");
  }
 
  if (item.TryGetValue("Name", out string valueName))
  {
    sb.Append(valueName).Append("\n");
  }
}
 
Set("ListaProducta", sb.ToString());
return true;

 

but my process is stuck on this script element and never finishes. What am I missing here?

 

I've tried adding "ListaProducta" as an process parameter but that didnt help

Like 0

Like

1 comments

Hi Lj



Instead of trying to access ReadDataUserTask values, please use Creatio ORM to read data from DB and process result as required.

Find details here:



https://academy.creatio.com/docs/developer/back-end_development/working…



Best Regards, 



Bogdan L.

Show all comments