Extending Schema with Field that executes Javascript Tags | Community
Skip to main content
davidh2892249
Level 5
Apr 17, 2019 11:24 AM UTC
Solved

Extending Schema with Field that executes Javascript Tags

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

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Jonathon_wodnicki
Jonathon_wodnickiAccepted solution
New Participant
Apr 23, 2019 8:19 PM UTC

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

3 replies

Jonathon_wodnicki
Jonathon_wodnickiAccepted solution
New Participant
Apr 23, 2019 8:19 PM UTC

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

Translate
davidh2892249
Level 5
Apr 18, 2019 10:17 AM UTC

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.

Translate
Jonathon_wodnicki
New Participant
Apr 17, 2019 8:22 PM UTC

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

Translate