how to send dynamic fields in custom email from ACS?

You must Login before you can answer or comment on any questions.

Hi,

I am new to ACS. I'd like to send email with my custom email. so I created email template as follow:

Name    Subject Body    
first    judul  isi nya {{isi}}
the i use the js sdk as follow:
var data = {
      recipients: 'maul_firdaus@yahoo.com',
      template: 'first',
      dynamic_fields: {'isi':'asik'}
    };
    sdk.sendRequest('custom_mailer/email_from_template.json', 'POST', data, callback);
And the logs shows:
Request Time    2012-09-01 00:47:20 UTC
Request Name    POST /v1/custom_mailer/email_from_template.json
Response Status 200
Parameters   { "recipients" => "maul_firdaus@yahoo.com", "template" => "first", "dynamic_fields" => "{"isi"=>"asik"}", "suppress_response_codes" => "true", "key" => "mD3EaYzwvrw5fxitZDPqtil6zgF8lLpu", "_session_id" => "NyvTEU4yvsIqiOBUEUeDetAQa1A", "controller" => "custom_mailer", "action" => "email_from_template", "version" => "v1", "format" => "json" }
User Agent  Mozilla/5.0 (iPhone; CPU iPhone OS 5_0 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9A334 Safari/7534.48.3
But I still failed to fill my dynamic_fields, which in my case called 'isi' with my desired value.

Could someone please show me what I did wrong?

Thank you, Fajar

4 Answers

have you tried

var data = {
      recipients: 'maul_firdaus@yahoo.com',
      template: 'first',
      dynamic_fields: JSON.stringify({'isi':'asik'})
};

goto acs webconsole, there is tab called email template, you can create a template in xml then save it. then in your email api, pass the email template name.

i tried this way and it works for me, the point is don't include them in dynamic_fields:

var data = {
      recipients: 'maul_firdaus@yahoo.com',
      template: 'first',
      isi:'asik'
    };
    sdk.sendRequest('custom_mailer/email_from_template.json', 'POST', data, callback);

— answered 9 months ago by kent hao
answer permalink
1 Comment
  • This also worked for me(tested from node.acs though it should work on titanium as well) my code:

    ACS.Emails.send({
        template : 'test',
        recipients : 'ins429@gmail.com',
        isi:'asik'
    }, function(e) {
        if (e.success) {
            console.log("success");
        } else {
            console.log("fail");
        }
    }, req, res);

    — commented 6 months ago by Peter Lee

Fajar,

This code works fine for me. The log shows dinamic_fields populated:

Cloud.Emails.send({
            template : 'your_template_name',
            recipients : 'email@mail.com',
            "dynamic fields" : "name=joe"
        }, function(e) {
            if (e.success) {
                alert('Cadastro efetuado com sucesso!');
            } else {
                alert('Error:\\n' + ((e.error && e.message) || JSON.stringify(e)));
            }
        });

— answered 7 months ago by Philipe Steiff
answer permalink
8 Comments
  • I have a problem that the ACS says "Cant find template name" even if its the right one. Anyone had the same problem?

    — commented 6 months ago by Daniel Hansson

  • how did you pass in template name?

    — commented 6 months ago by Wei Kong

  • HereĀ“s the code. The Email template name is "project" in ACS.


    btn_Share.addEventListener('click', function(e) { alert('Button : '+e.source.btnno); Cloud.Emails.send({ template: "project", recipients: 'createdbydaniel@gmail.com' }, function (e) { if (e.success) { alert('Success'); } else { alert('Error:\\n' + ((e.error && e.message) || JSON.stringify(e))); } });

    });

    — commented 6 months ago by Daniel Hansson

  • Show 5 more comments

Your Answer

Think you can help? Login to answer this question!