Javascript Code in KB Articles

Is there a way to put JavaScript code into an article (any article type as long as it works consistently)?

for example:

TIA,
Tom

To include Javascript code in article content, the Rich Text Content Policy (RTCP) needs to be updated to explicitly allow that. The Partition Administrator access is required to update the RTCP.

Including Javascript code is not recommended because it could constitute a security issue that could be exploited. Updating the RTCP to allow Javascript code in article content is at your own risk.

security was my suspicion - there has got to be a way somewhat dynamic code could be added to articles, such as the current date plus 30, 60, 90 days.
any suggestions?

If what you want is to insert the current date plus or minus some number of days, you can use a JDBC data adapter and include the macro for that data adapter in your articles. The attached screenshots show how to configure this type of data adapter.

There is one issue with this approach, and that is that JDBC data adapters are no longer supported in R21, meaning that you could use this approach now in v17, but it will not work once you upgrade to R21.

1 Like

I ended up using the JDBC macro approach for my test. Hopefully R21 will make it easier to create custom, dynamic content.

Do we know what a workaround will be for this with r21? I mean is there a way to display dynamic content? If only dates +/- days I’d be thrilled.

To be clear on your requirements, you want to put the dynamic dates at arbitrary locations in the article content, and you want the author to be able to specify the number of dates + or - for each instance of a dynamic date. Is that correct?
If these are your requirements, the only solution currently available in R21 would be to replace the JDBC data adapter with a REST API data adapter, where the REST API performs the necessary relative date operations. If there is no public API that provides this functionality, then you would be in a position of having to provide that yourself, which seems worse than the current solution to me.
I would be happy to create a feature enhancement request for you to add dynamic dates in the article content, but unfortunately, I cannot provide a date or a release where this would be implemented.

@rreich thank you for the responses. I’ve been unable to access the community for a few weeks…
In the meantime though I have been exploring the RESTful API’s on eGain Solve 17.

To be honest, I’m a little embarrased that I have struggled so much with getting/setting the X-egain-session.

The URL parameter __eg_request_token __ (the space between n and _ is intentional) seems to be the magic value through the console.

When I hardcode the X-egain-session header the API call is successful on the article, but I cannot get/set the value dynamically.

Using <% __eg_request_token __ %> will prompt for the value in the console but I can’t seem to get and set the correct parameters at runtime.

I’ve tried the composite API as well, but I cannot seem to get the required value.

What am I missing?

Thanks,
Tom

Sorry, but it is not clear to me what you are trying to do. It would appear that you are trying to call some eGain API using a data adapter, and that this API requires some headers, and you are having trouble assigning values to those that are acceptable. While I did recommend using a data adapter to call a REST API to obtain the date value you are wanting to dynamically insert in article content, I meant some public REST API because there is not an API with that functionality in the eGain APIs. Therefore, I am assuming that the current post has to with a different issue. Is that correct? If it is, you should start a new thread and provide more context for what you are trying to do. It would be helpful to know the specific API you are calling and what is triggering the execution of the data adapter.

1 Like