0

How I can create Dynamic list as parameter in Action to use it in function after then

        [Action("Send Email", "Send Email")]
    public void SendEmail(CaseRequest caserequest, [Parameter(ValueInputType.User, Description = "Output message")] List<string> ListEmail)
    {

        //Send Email
    }

Is doable to pass list of action , I need to it for this condition

if condition is true then sendEmail( display list of emails)

Sara
  • 1

1 Answers1

0

In Code Effects, you can't just type a new list of strings directly in a method as param. You need to populate that list in your rule first and then pass it to the action method. Something like this:

public class Test
{
   public Test()
   {
      this.EmailList = new List<string>();
   }

   public List<string> ListEmail { private get; set; }

   public void AddEmail(string email)
   {
      if(string.IsNullOrEmpty(email)) return;
      this.ListEmail.Add(email);
   }

   public void SendEmail(CaseRequest caserequest, List<string> emails)
   {
      // Do your thing here...
   }
}

This allows you to create the following rule:

If
   Something equals to True
      then
         AddEmail("test1@test.com") and
         AddEmail("test2@test.com") and
         SendEmail(yourEnum, ListEmail)
Alex
  • 566
  • 1
  • 6
  • 14
  • Thanks for answer , but I need get list of email form DB to allow user to choose email already exist not write again email , I have more than 30 email, Its not true write all email in AddEmail function – Sara Jan 08 '21 at 11:31
  • Can't you just get all emails inside of your SendEmail action method before actually sending the email? IN this case, you won't even need to pass anything to the method. Of course, that works only if your email list does not vary much between multiple rules. In any case, the example I posted should give you an idea of how to manipulate with params in Code Effects engine – Alex Jan 08 '21 at 11:35
  • Thanks but this Inappropriate bcz list of of emails are dynamic , Can you plz me how I can fix this issue, I faced "The Save action is not defined" when I want save rule – Sara Jan 08 '21 at 11:54
  • Please read the documentation of the editor's client API and specifically the use of its .setClientActions method at https://codeeffects.com/Doc/Business-Rule-Ajax-Api. Also, you need to have a good understanding of how the editor operates before you can use it in your code. Please refer to the main article at https://codeeffects.com/Doc/Business-Rule-Management and follow all links that that article provides. – Alex Jan 10 '21 at 11:36