In this item you mention The page will have access to the authentication-cookies of the GUI and therefore can make use of all of Indicium's functionalities.
This only works if the preview column is of the controltype URL. Furthermore, it's only possible to make requests to Indicium from a same origin HTML page. It isn't possible to get the contents of the cookie yourself, as the cookie is a HttpOnly cookie (as it should be, due to security concerns), so the browser will automatically send it along with requests to Indicium, but won't be able to read it from JavaScript.
Same origin means that when your Universal is located at “server.domain.com/universal”, your HTML page needs to be under “server.domain.com/” as well, so for example “server.domain.com/page.html”. It also needs to be on the same port. (so Universal on “server.domain.com:8080/universal” and the HTML page on “server.domain.com/page.html” won't work)
When these conditions are met, you can fetch Indicium API routes with a HTML file like this:
(I'm using fetch here as an example, it might be better to use an abstraction library instead, depending on your needs)
Then, when opening the Preview component, it will look like this:
Kind regards, Leroy Witteveen
@Leroy Witteveen is there also a way to find out the context the iframe of the previewer is loaded in?
@Leroy Witteveen is there also a way to find out the context the iframe of the previewer is loaded in?
Hi Freddy,
What kind of context do you want to access exactly?
Kind regards, Leroy Witteveen
@Leroy Witteveen is there also a way to find out the context the iframe of the previewer is loaded in?
Hi Freddy,
What kind of context do you want to access exactly?
Kind regards, Leroy Witteveen
For example, I'm adding the URL for the previewer with the custom page in a certain table.. in our case a service.. Is there a way to query the context or does the url need something like page.html?var1=bla&var2=aat ?
Hi @Freddy,
You could achieve this by creating an expression field which appends e.g. ?subject=employee&primary_keys=employee_id eq 1 You then need to let the previewer use this expression field and parse the URL from the HTML file. You can access this part of the URL using window.location.search in the HTML file, this would contain “?subject=employee&primary_keys=employee%20id%20eq%201” in the example above.
Kind regards, Leroy Witteveen
Thanks @Leroy Witteveen That is quite easy once you know it :-)