Expand my Community achievements bar.

SOLVED

Extending Schema with Field that executes Javascript Tags

Avatar

Level 5

Hi All,

I'm looking to extend the delivery schema.

I've been able to do that fine, but I'd like to be able to add javascript Tags in the input form of the new field and make the tags execute.

E.g. like the subject field supports <%= recipient.firstName %> and replaces the tag with the recipient's first name value.

I've created a new string field on the delivery schema, but when I add a javascript tag like the above, it doesn't execute - it just shows the tag as a string.

Any ideas how to make the js tags execute?

Thanks

David

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi,

The immediate answer is to just use eval(), e.g.:

var s = (@field + '').match(/<%=?(.+?)%>/)[1];

if (s) eval(s);

This isn't quite the same as what deliveries do, as they have a pre-parser which collects db tables and fields and populates data ala active record, to allow for things like <%= recipient.firstName %>. Nor is it similar to Dynamic JavaScript pages, which have a couple web server objects available.

Features can be added as needed though.

Thanks,

-Jon

View solution in original post

3 Replies

Avatar

Community Advisor

Hi,

You can script the field's consumer to parse and render tags found in the fields.

Outside that, delivery and jssp are the only ootb features that render jssp tags afaik.

Thanks,

-Jon

Avatar

Level 5

Thanks Jon, appreciate the response.

Can you give a working example? (with screengrabs would be great) so i can replicate and know where things are to be added.

Avatar

Correct answer by
Community Advisor

Hi,

The immediate answer is to just use eval(), e.g.:

var s = (@field + '').match(/<%=?(.+?)%>/)[1];

if (s) eval(s);

This isn't quite the same as what deliveries do, as they have a pre-parser which collects db tables and fields and populates data ala active record, to allow for things like <%= recipient.firstName %>. Nor is it similar to Dynamic JavaScript pages, which have a couple web server objects available.

Features can be added as needed though.

Thanks,

-Jon