Extending Schema with Field that executes Javascript Tags | Community
Skip to main content
davidh2892249
Level 5
April 17, 2019
Solved

Extending Schema with Field that executes Javascript Tags

  • April 17, 2019
  • 3 replies
  • 4447 views

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.
Best answer by Jonathon_wodnicki

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
Community Advisor
Community Advisor
April 17, 2019

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

davidh2892249
Level 5
April 18, 2019

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.

Jonathon_wodnicki
Community Advisor
Jonathon_wodnickiCommunity AdvisorAccepted solution
Community Advisor
April 23, 2019

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