I'm trying to make a call to Http.post() in a Maestro Button on click rule with the code below: 

var dataObj = {
  sfmOperationName: "backgroundSave",
  xml_data: null
dataObj.sendEmail = true;
dataObj.backgroundSave = false;
Http.post(url, dataObj); // Make request TM to send email for background save

but when I test clicking of the button when I render it, I get the following error:

ReferenceError: Http is not defined
at Rules.click_continuar_1 (app.js:sourcemap:5095)
at fn (eval at compile (app.js:sourcemap:793), <anonymous>:4:685)
at b (app.js:sourcemap:684)
at e (app.js:sourcemap:838)
at m.$eval (app.js:sourcemap:703)
at m.$apply (app.js:sourcemap:704)
at HTMLButtonElement.<anonymous> (app.js:sourcemap:838)
at HTMLButtonElement.dispatch (app.js:sourcemap:4)
at HTMLButtonElement.q.handle (app.js:sourcemap:4)

What am I doing wrong and could someone provide me with a working example?



    CommentAdd your comment...

    1 answer


      Why do you need to make a Http call directly? Looks like what you want is to do a save, submit or similar TM operation. There are higher-level APIs for that. (Form.submit, Form.backgroundSave etc.) If you tell us what you are trying to achieve we can assist.

      1. Blake Hunter

        Hi Tim,

        We have a requirement from the client to click, save the form and send an email but not to drop the user out of the session. Unfortunately Form.submit would drop us out of the session unless there is some way to call Form.submit to save and send the resume email without exiting the session.

      2. Tim Stewart

        You should be able to use Form.submit for this. Check the parameters for skipPostSubmit, sendEmail and backgroundSave. So your call would look like:

        Form.submit("Saved', false, true, null, true, true)

        I guess it is a little unintuitive that Saves (and indeed Abandons) also go through Form.submit, maybe we should add some convenient wrapper methods for those actions too.

      3. Blake Hunter

        I tried calling Form.submit('Saved', false, true, null, true, true) and it does save the form but I have not received an email and it usually sends them within a minute or two of saving.

        The http request in the browser shows the following parameters being requested to TM


        Is there a place in the TM logs to check if TM has sent the email?

      4. Tim Stewart

        Looks like you've got the Maestro side right, try adding the TM label to this question so that team can assist with the email log question.

      5. Glenn Crook

        Hi Blake, I have talked to Stuart about the TM side and came up with a couple of things to check. The TM server log will have warnings if there is incorrect data passed through to the email service and errors if it fails to send. Successful email logging is under the debug status so you would need the TM Log4J settings to be updated if level is not being logged.

        In addition, there is a condition that the email is only sent if the form is in a saved status and it wasn't clear as to whether a background save qualifies in this case. Try setting the background save parameter to false and see if the email is sent.

        If none of this works then please provide support with a sample of what you are trying to do and we can see if this is working as designed or whether there is an issue.

      6. Blake Hunter

        Hi Glen,

        I have checked the error logs from before and did not see any errors. I tried changing the background save parameter to false and while it did save the form when I now check the error logs I am seeing the following error:

        It looks like there is a syntax issue parsing the email template but I'm now sure why. Is there a way to check what template has the error and if it has been modified somehow?

        Something to keep in mind, I tried a different approach at sending a saved reminder email from the maestro form via a Javascript API call and received the same type of error. See the following KB question for more details: A working example for Form.emailOperation(emailSavedForm) in a Maestro rule



      7. Tim Stewart

        Hi Blake, yes perhaps something is wrong with your email template, as both this approach and your the one from your other question both give similar errors. Could you file a JIRA with the full details including your email template, form details, steps to replicate, expected and actual outcomes? Thanks.

      8. Blake Hunter

        Hi Tim,

        It turns out that there was a syntax error with the template that someone had made to the subject line. We fixed it and it is sending the email corrrectly now. Thanks

      9. Tim Stewart

        Glad to hear it thanks Blake.

      CommentAdd your comment...