Send email in Javascript

Sort:
You are not authorized to post a reply.
Author
Messages
Terry P
Veteran Member
Posts: 234
Veteran Member

    Has anyone sent an email using script from within a form? I know the code for normally sending an email would be something like:

    document.forms[0].action = "mailto:" +document.forms[0].recipient.value +"?subject=" +document.forms[0].subject.value;

    But can I do that in a form?

     

    John Henley
    Senior Member
    Posts: 3348
    Senior Member

      You *should* be able to do that, adding document.forms[0].submit() to actually submit the form.  Remember, though, that since Javascript is a client-side app, what's really going to happen is that it will launch the user's email app, not send the email via the server.  To do that is a whole different story.

      Thanks for using the LawsonGuru.com forums!
      John
      Terry P
      Veteran Member
      Posts: 234
      Veteran Member
        I was afraid of that. Yeah, I'm looking for the "whole different story". We don't use RQ10, but only PO20. PO20 does not come with a trigger or process flow for PO's > $5k so I was going to check and send an email when that happened. Guess I'll wait until CUE next month and ask about how to create custom triggers for that.

        Thanks!
        John Henley
        Senior Member
        Posts: 3348
        Senior Member
          Since you have Design Studio, you can also trigger a flow from PO20 that will send an email. Not hard to do...
          Thanks for using the LawsonGuru.com forums!
          John
          Terry P
          Veteran Member
          Posts: 234
          Veteran Member
            John - I've never anything with process flows or triggers. Do you have an example to get me started.

            Thanks!
            John Henley
            Senior Member
            Posts: 3348
            Senior Member
              Here's a slide you can use to get started: https://www.lawsonguru.co...G-StudioTrigger.pdf. Note that WF05 (Service Definition) no longer exists if you're using LSF9--it has been replaced by the /bpm/menu.do ProcessFlow Admin module.
              Thanks for using the LawsonGuru.com forums!
              John
              Terry P
              Veteran Member
              Posts: 234
              Veteran Member
                Thanks - I understand now how they are done using Design Studio. My problem is we don't use requisitions, only Purchase Orders. The PO application does not come with a standard service that I can use. If we were using RQ10 instead of PO20 I suspect we could, but it appears I need a custom trigger. Since, I don't have the ability to write custom RPG code (we're on an AS400), that possibility is out.

                I'm surprised Lawson doesn't provide more standard triggers with PO. Guess I just have to live with that.
                jojo.serquina
                Veteran Member
                Posts: 63
                Veteran Member
                  ... someone correct/add to this.

                  create your process (using processflow of course) to reflect the process you want to happen if PO > 5K (that will send email notifications as well) so you don't have to fool with JavaScripts within the lawson form.

                  then using Design Studio, customize PO20 to create a trigger when the user do an add.

                  To do this, open Design Studio and do a quick paint of PO20. Go to the "More Document Properties" and select the "Actions" properties. Select "Add" and click Properties - there should be a place where you can define "Work Flow Trigger:" - browse to where you saved the processflow - save the custom PO20 form and make it the default presentation.

                  I hope that make sense...
                  John Henley
                  Senior Member
                  Posts: 3348
                  Senior Member

                    Terry, you can add a service yourself to do this...

                    Thanks for using the LawsonGuru.com forums!
                    John
                    John Henley
                    Senior Member
                    Posts: 3348
                    Senior Member

                      Jojo, that is correct.  The only thing that needs to be added is that you have to create a service to which the Design Studio trigger gets connected.

                      Thanks for using the LawsonGuru.com forums!
                      John
                      Terry P
                      Veteran Member
                      Posts: 234
                      Veteran Member
                        Showing my ignorance here - if a "service" means writing custom code, ie COBOL or in our case RPG, then the short answer is no. I'm limited to only the tools Lawson gives.
                        John Henley
                        Senior Member
                        Posts: 3348
                        Senior Member
                          Not ignorance...just "lack of experience":)
                          A service doesn't involve code...it's just a matter of setting up some data...using WF05 (if pre-LSF9) or /bpm/menu.do (if LSF9).
                          Thanks for using the LawsonGuru.com forums!
                          John
                          jojo.serquina
                          Veteran Member
                          Posts: 63
                          Veteran Member
                            a small tip as to what John's saying about the services... (processflow)

                            I don't have any formal training on processflow nor design studio. what helped me set up the services properly is by looking at those 'delivered' services and following them, step by step... after looking at a few of those services, you'll understand how to set one up.

                            we're on LSF9, btw - which I've 'heard' is a lot easier than previous releases...
                            Terry P
                            Veteran Member
                            Posts: 234
                            Veteran Member

                              Ok - to get my feet wet, I did the following:

                              1. Created a simple process flow that would send an email using PF Designer. I tested it out by doing a "run" and it sent the email just fine. I named it "test1".
                              2. I then went to WF05.1 and created a service and named it "testpflow" making sure it was enabled.
                              3. I then went to WF07.1 for the service just created and clicked the "Process" link on the right which took me to WF07.2 where I added a record and selected the process name test1 and made the event type "EVT_PFLOW".
                              4. I went back to PF Designer and in the Process Properties, assigned the testpflow service name.
                              5. I uploaded the process flow to the server.
                              6. Then in Design Studio, I created a quick paint of PO20.1. On the Action for Inquire, I selected the Work Flow Trigger/service "testpflow" I created in WF05.

                              What I expect to happen is when ever I do an inquire on the screen it will also send an email. It doesn't. All it does is retrieve the data and say "inquiry complete".

                              Did I forget a step or what? Is there some way to trace or see that it is trying to run the service?

                              Sam Simpson
                              Veteran Member
                              Posts: 239
                              Veteran Member
                                In PO20 did you setup all your triggers that will initiate your workflow? If not then see the ProcessFlow Administration Guide.
                                John Henley
                                Senior Member
                                Posts: 3348
                                Senior Member
                                  Terry, sounds like you're on the right path. Did you upload the 'test1' process to the server? You should be able to look at the PF event management console and get some idea as to why the event didn't work....assuming you are running LSF9, you can turn on trace/logging for the flows, etc. using 'pfserv config', and then you should see logs/traces in the $LAWDIR/bpm/wf* folders...
                                  Thanks for using the LawsonGuru.com forums!
                                  John
                                  Brianf
                                  New Member
                                  Posts: 3
                                  New Member

                                    John -

                                    I did a similar setup and I'm unsuccessful in kicking off my flow from the trigger.

                                    • Created a service on WF05 for pa26 and named it PA26.1_A
                                    • Created a flow and tied to service from above in process properties.
                                    • Mapped the service to my simple flow with WF07.
                                    • Created a custom pa26 form.
                                    • Assigned the service to add action properties for workflow trigger.

                                    Nothing shows in PF Admistrator when triggered from the custom page.  I was able to start the flow from the service using wfwk so I think my problem is the trigger itself.  We are on 8.0.3.  Could this be the issue?  

                                    Terry P
                                    Veteran Member
                                    Posts: 234
                                    Veteran Member

                                      Brian - make sure on the "Actions" tab of the document properties (the one where you assigned it to the Add action) that you click the "Work Flow Enabled" box.

                                      Terry P
                                      Veteran Member
                                      Posts: 234
                                      Veteran Member
                                        BTW - I was able to get mine original problem resolved. It was the format of the custom javascript call I was doing. I was not able to attach the service to the "Release" button, because if they exceeded their buying limit, the release failed. If the action does not complete, the flow is not triggered. So I wrote custom code to look for the error message when they "tried to release", and kicked off the flow myself.
                                        Brianf
                                        New Member
                                        Posts: 3
                                        New Member

                                          Thanks Terry - I verified the checkbox but it was checked.  I have not added additional code in the form so I don't think I'm experiencing what you did.  Any other ideas?

                                          Terry P
                                          Veteran Member
                                          Posts: 234
                                          Veteran Member

                                            Did you check to see if a work unit was created in WF20.1? Email me at pickering@4j.lane.edu

                                            You are not authorized to post a reply.