Method Community

 

Loop the data in the Email

Last post 05-23-2014 9:36 AM by Method_Russell. 9 replies.
Page 1 of 1 (10 items)
Sort Posts: Previous Next
  • 03-04-2012 11:07 PM

    Loop the data in the Email

    Hi, 

    I am generating the email from methods. I need to retrieve the data from the database and display in the tabular format. But when I am merging the data using the Character function, i am able to retrieve only one row data, I am not seeing the multiple rows. Is there any other way to display the data in the E-mail in the tabular format.

    Thanks & Regards

    Navitha.

     

  • 03-05-2012 11:22 AM In reply to

    Re: Loop the data in the Email

    Hi Navitha,

    I have some questions for you:

    1. How are you generating the e-mail in Method?
    2. Are you trying to display data from a table in Method in the body of the e-mail?

    Ronen

  • 03-06-2012 11:45 PM In reply to

    Re: Loop the data in the Email

    Hi Ronen,

    I am creating a EmailTemplate and using that, yes in the body of the Email i am trying to display the data from the table in the method.

     

    Thanks

    Navitha.

  • 03-07-2012 1:34 PM In reply to

    Re: Loop the data in the Email

    Answer

    Hi Navitha,

    In the email template, you can retrieve the data from the Method tables by having merge fields which will allow you to have values from tables appear in your e-mail, such as a customer's name, the total amount due on their account, or the e-mail signature of the user sending the e-mail.

    There are two steps to setting up merge fields:

    Step 1: enter merge fields in your email template

    Type in your merge fields in a TableName.FieldName format.  So if you wanted to have an email start with "Dear Bob," you would type in "Dear Customer.FirstName,".   If you wanted to sign your email with the user's signature, you would finish it with "Users.EmailSignature".

    Step 2: use the 'Replace merge fields' action

    If you are not the designer of your system, this step should already be done for you.  If you are a designer, however, you'll need to do some extra work to make sure that the merge fields actually get replaced with real values.  For every table used in merge fields, you'll need to run a Character Function action, specifically the 'Replace merge fields' command, to replace the merge fields with real values.

    In the body of the e-mail template, in the toolbar,  there is a function called Insert Table right beside Insert Image function. You can implement the Insert Image action in the body of the e-mail template by selecting the arrow pointing down right beside the Insert Table function.This will add a table in the body of the e-mail where you can add the merge fields to populate the correct information.

    I hope that this helps.

    Ronen

  • 05-20-2014 7:20 PM In reply to

    • m.mehr
    • Top 50 Contributor
    • Joined on 06-01-2011
    • Henderson, NV
    • Posts 100

    Re: Loop the data in the Email

    Greetings from Las Vegas and BUMP on an old post which does not appear to have been answered.

    Is there a way to insert a DYNAMIC grid of info into an email template?

    For example, a list of open invoices on an email to a customer or a list of open bills on an email to a vendor?

    Thank you!

    Michael J. Mehr, CPA.CITP
    michael@mehrcpa.com
  • 05-22-2014 8:09 AM In reply to

    Re: Loop the data in the Email

    Hi M Mehr,

    Greetings from Toronto!

    Method has the Mail Merge feature (http://www.methodintegration.com/method/kb.aspx?folder=methodcrm&article=Mail-merge&id=302), however this only replaces placeholders with a single field, rather than adding multiple items which you are trying to achieve.

    Generating an email with a variable number of table rows is possible, however it would take a lot work. To do this, you would have to manually build the HTML for the email body into an Action Result, and using a loop add each row in the table to that HTML. Something like this: http://www.ryerson.ca/JavaScript/lectures/flowControl/loops/writingTables/simpleTable.html, except with Method actions instead of Javascript of course.

    Alternatively, you can use the report designer to dynamically build the list of open invoices, and create a PDF of this report. Then the report can be attached to an email. For more information on the report designer, please see this article: http://www.methodintegration.com/method/kb.aspx?folder=methodcrm&article=Generate-Report&id=151 and these 3 webinars: http://www.methodintegration.com/method/kb.aspx?folder=methodcrm&article=Method-V1&id=369#main12.

    If you have any further questions please let us know.

    -Russell

  • 05-22-2014 11:13 AM In reply to

    • m.mehr
    • Top 50 Contributor
    • Joined on 06-01-2011
    • Henderson, NV
    • Posts 100

    Re: Loop the data in the Email

    Thanks Russell,

    When you say the custom looping HTML for the email body goes into an Action Result, where would that actually be in Method?  On a button or a screen or the HTML code of an email template?  Or somewhere else?  I am not asking you about the custom code itself, but WHERE IN METHOD the custom code would go to achieve the desired result.

    Regards,
    Michael 

    Michael J. Mehr, CPA.CITP
    michael@mehrcpa.com
  • 05-22-2014 11:53 AM In reply to

    Re: Loop the data in the Email

    Hi Michael,

    This would be part of the action set that sends the email, before the Send Email action so that the HTML generated would be up to date. The generated HTML code would be used instead of the template.

    In regards to where you would place these actions, it depends on what event would trigger the email being sent (such as clicking a Send Email button)If you have more than one event that would trigger the email being sent, then you could use the Call Another Action Set action.

    -Russell

  • 05-22-2014 7:47 PM In reply to

    • m.mehr
    • Top 50 Contributor
    • Joined on 06-01-2011
    • Henderson, NV
    • Posts 100

    Re: Loop the data in the Email

    Thanks Russell!

    If I understand correctly, the action result used in the body field in the send email action needs to contain the dynamically generated rowset from the database in HTML format.  But what action type would be used to "accumulate" each row from the loop, which is what ultimately becomes part of the HTML code?

    Michael J. Mehr, CPA.CITP
    michael@mehrcpa.com
  • 05-23-2014 9:36 AM In reply to

    Re: Loop the data in the Email

    Hi Michael,

    Sounds like you understand correctly. At a high level, your entire action set to prepare and send the email would do something like this:

    1. Initialize the action result which will hold the body, with this action result add any static text (before the table) to the body of your email, and initialize the table's HTML.
    2. Loop through a grid/table. In the loop, you can place the field(s) from each row into a temporary action result, along with the HTML for the table's row. Then (while still in the loop), join this temp action result to the end of the body's action result. The body action result is what will accumulate each row, so each time the loop runs, another row of the table will be joined.
    3. After the loop, join more HTML to the body's action result to close the table. Send the email with this action result.
    -Russell
Page 1 of 1 (10 items)