Jump to content

Plugin Call within PSoS Breaks from WebDirect


Chuck

This topic is 3001 days old. Please don't post here. Open a new topic instead.

Recommended Posts

I'm publishing a small portion of a larger system via WebDirect. It's a form that visitors fill in, the submit button of which executes a script that creates a few records based on the form contents and sends an email to the visitor.

We started with the email being plain text using FileMaker's built-in Send Mail script step. The client asked for the additional feature that the emails be HTML instead. So, while retaining the plain text version sent to actual visitors, I added the ability for HTML email to be sent to some testing email addresses. Actual visitors don't yet see the HTML email.

Everything works perfectly in FileMaker Pro. If I go to the layout, fill in the form, and click the button, the visitor email address gets the plain text version and the testing email address gets the HTML version.

From WebDirect, however, the testing email address gets nothing (although the visitor email address still gets the text only version, as expected). And I don't understand why.

The script that does this is meant to be executed on the server, and it takes care of that direction itself. It looks something like this:

If [ ShouldPerformOnServer // This script should execute on the server ]
  Perform Script on Server [ Wait for completion ; "Send Email" ; Parameter: Get ( ScriptParameter ) ]
  Set Variable [ $_result ; Get ( ScriptResult ) ]

  If [ Get ( LastError ) = HostExceedsCapacity ]
    Set Variable [ $? ; TurnOverrideOn // Overrides that this script should execute on the server ]
    Perform Script [ "Send Email" ; Parameter: Get ( ScriptParameter ) ]
    Set Variable [ $_result ; Get ( ScriptResult ) ]
    Set Variable [ $? ; TurnOverrideOff ]
  End If

  Exit Script [ Result: $_result ]

Else

  // Send the email using ScriptMaster
  Exit Script [ Result: SMLastError ]

End If

As far as I can tell, by placing Show Custom Dialogs throughout the script, this is executing on the server, but the HTML email that's supposed to be sent with ScriptMaster isn't actually sent. The only difference when it doesn't work is that the Perform Script on Server is being executed from WebDirect, for the plugin doesn't seem to work, even though the actual plugin execution only takes place on the server (the HostExceedsCapacity isn't generated).

Should I just look into other ways to send HTML email from a script executing in WebDirect, or am I missing something obvious here?

Thanks,
Chuck

Link to comment
Share on other sites

A couple of things missing: are you saying that when you fire PSoS from FMP it does work?  Or do you not use PSoS when the user is on FMP?

Have you configured FMS to allow server-side plugins (and the installation of them) and does your PSoS script test for the plugin and installs when necessary?

Also remember that any PSoS script will fire the file's OnOpen script and if you don't check for incompatible script steps and branch around them there, your actual target PSoS script may never run.

Link to comment
Share on other sites

Wim,

From FMP, everything works fine.

I did, early in the development of this feature, test that the plugin was installed by simply calling a PSoS that returned the ScriptMaster version to the script result, so I know that the plugin is installed and enabled. But I tried the same sort of test from WebDirect and got a permissions error.

I created two scripts and gave them both full access privileges. "Return plugin version" which looks like this:

Exit Script [ Result: SMVersion ]

"Test Plugin" looks like this:

Show Custom Dialog [ "test plugin" ]
Perform Script on Server [ Wait for completion ; "Return plugin version" ]
Show Custom Dialgo [ Get ( ScriptResult ) ]

I placed a button on the WebDirect layout and linked it to "Test Plugin". Clicking it results in a "Your access privileges do not allow you to perform this action." message. I don't even get the first dialog box. But the script is set to execute with full access privileges, so what am I missing?

WebDirect is set up for guest access only. The file is set to log in using the guest account and the only extended privilege the guest privilege set has turned on is fmwebdirect. So when users connect via FileMaker Pro they get the credentials dialog box.

At least I think I'm on the right track to figuring this out with this new bit of information.

Thanks,
Chuck

Edited by Chuck
Link to comment
Share on other sites

That was it. PSoS uses the calling script's logged in user, and that logged in user didn't have fmpapp privileges, which is, apparently, what server scripts need. I was actually a little surprised that there's no extended privilege dedicated to that.

Thanks for the assistance.

Link to comment
Share on other sites

  • 1 month later...

Yeah, this one is complicated.   Giving [Guest] access to server-side scripts seems like a non-trivial security hole.  I agree it would be really nice to have a "PSOS-Only" fmapp privilege set.     For now, you can work around this by using Get(ApplicationVersion) and distinguishing between PSOS calls and FileMaker Pro calls, depending on whether the ApplicationVersion contains "Pro" or "Server".

Link to comment
Share on other sites

This topic is 3001 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.