The form to subscribe to the newsletter. It has the Name and e-mailid fields to enable visitors to subscribe to the newsletter by specifying their e-mail ids. There is also one hidden field "isUnsubscribed" to check the status of each subscription. This field is hidden when the form is loaded. The on add -> on load script given below, hides the isUnsubscribed field, when form is loaded.
on add |
This form is used by the owner to send mails to the subscribers mailing list. It has the Send decision check-box field which when set to "true" will send e-mails to the subscriber mailing list. This is achieved by adding on user input script to the Send field as given below.
Send |
Code Explanation
if (input.Send) - The if statements will be executed if the Send decision check-box is set to true.
for each r in Subscription_Form [isUnsubscribed == false] - Here, isUnsubscribed is a Decision Check field and r is a variable that stores the records whose isUnsubscribed status is false.
sendmail - Send mail to the e-mail id specified in the row variable r.
The form used to unsubscribe from the newsletter. This form contains the e-mailId field, using which the user unsubscribes from the newsletter. When a user submits his e-mailid, the on add -> on success script added to this form, updates the decision checkbox fieldisUnsubscribed in the Subscription form to true, as shown in the code given below:
on add |
Code Explanation:
temp = Subscription_Form [EmailId == input.EmailId];
-The above code will fetch records from the Subscription Form whose EmailId is equal to the EmailId specified in this form, and store it in a collection variable named temp.
temp.isUnsubscribed = true;
- The above code sets the isUnsubscribed field in the fetched record to true.