We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 7455
    • 2,204 Posts
    I like to make a plugin that sends out a mail when a new document is created.

    I think I can use OnDocFormSave, but how do I get the insert id? I like to get the id so that I can generate a link to put in the mail.
    all the availible fields for plugin creation are hard to find what you can use.

    is there a posibility to get the inserd id from the db when using OnDocFormSave or is this event to soon and is the id not given to the document yet?

    there is no AfterDocFormSave event.

    does anyone know a way to do this?

    dimmy
      follow me on twitter: @dimmy01
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      Looks to me like the new doc’s ID is available:
      		// invoke OnDocFormSave event
      		$modx->invokeEvent("OnDocFormSave", array (
      			"mode" => "new",
      			"id" => $key
      		));
      

      Although how you would access that in a plugin is more than I know tongue
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 7455
        • 2,204 Posts
        ok I got the id thank you so much:

        $mailid = $modx->event->params[’id’];

        now connecting it to the mailing list.

        greets Dimmy
          follow me on twitter: @dimmy01
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          Well, now I know! Thank YOU grin
            Studying MODX in the desert - http://sottwell.com
            Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
            Join the Slack Community - http://modx.org
            • 7455
            • 2,204 Posts
            mm what i realy miss in developing plugins are error messages, now I just get a white screen so somthing goes wrong but nothing is logged or displayed on screen.
            verry frustrating changing stuf and then save and test if not working change again save again test again etc etc.

            I feel that I am close to get this plugin working.

            will try more and see if it works.
              follow me on twitter: @dimmy01
              • 7455
              • 2,204 Posts
              mm I could take alook but I am just a beginner and not that good (yet)

              would be good to extent this so building plugins wil be much more easy.

              Dimmy
                follow me on twitter: @dimmy01
                • 7455
                • 2,204 Posts
                Ok I got the plugin working.
                now I would like a popup to that asks if this page needs to be send with yes or no.
                is this posible in a plugin?

                I tryed javascript but that did not work and the modx->alert() only gives alerd bit no yes or no.

                Dimmy
                  follow me on twitter: @dimmy01