EventCtx()
function EventCtx(): {
RelPath: string;
RelTargetPath: string;
VFSName: string;
};Returns the entire event context as a single object. This is the same information exposed by the individual Ctx* helper functions, delivered in one call:
| Field | Equivalent helper | Meaning |
|---|---|---|
RelPath | CtxRelPath() | VFS-relative path of the file that caused the event; "" when no file applies |
RelTargetPath | CtxRelTargetPath() | VFS-relative target path of a rename or move; "" otherwise |
VFSName | CtxVFSName() | Name of the VFS the event refers to; "" for events that fire before VFS selection |
Like every Ctx* value, the whole object is captured at the moment the event fires and frozen into the script's execution context for its entire lifetime. It never changes while the script runs, regardless of what the client does in the background, so it is always safe to read at any point during execution.
TIP
EventCtx() is also forward compatible: when future versions of Syncplify Server! enrich the event context with new information, the new fields will appear in this object automatically. If you want your scripts to take advantage of upcoming context fields as soon as they ship, read them from EventCtx().
Example
{
var ctx = EventCtx();
Log("Event: " + EventHandler());
Log("File path: " + ctx.RelPath);
Log("Target path: " + ctx.RelTargetPath);
Log("VFS name: " + ctx.VFSName);
if (ctx.VFSName === "Quarantine" && ctx.RelPath !== "") {
Log("File activity on the quarantine VFS: " + ctx.RelPath);
}
}WARNING
EventCtx() is not available prior to v8.0.4. Please upgrade to v8.0.4 or newer to use this function.
See also
CtxRelPath(): the path of the file that triggered the eventCtxRelTargetPath(): the target path of a rename or move operationCtxVFSName(): the name of the VFS the event refers toEventHandler(): returns the name of the event that triggered this script
