So here are the goods. Please refer to @klincecum 's Safe Harbor notice earlier in the thread.
The zip contains a kinetic app, I used to tune the logic, and the Epicor Functions. There are notes on the UI Functions libraries that explain what should set for the condition expression (that does the magic). Be sure to give your company access to the UI functions before running the kinetic app.
The UI libraries are split between JS and CSS that call unpublished internal functions.
For using CSS, you can approach it a couple of ways.
-
Call the Epicor Function and then the condition element to either load or unload the CSS. This is a simpler approach if the CSS isn’t going to be toggle often. Like if you just want to give the option to toggle required fields.
-
Store the loading and unloading logic in TransView fields and then use those fields in the condition element. This would just save on making server calls if the CSS will be added/removed often. Like if you need to toggle CSS based on a field/row change.
This is the basic routine to Load CSS:
This is the basic routine to Remove CSS:
This is the basic routine to Load JS:
This is the basic routine to Run JS:
Once JS is loaded into the page, it can’t be removed (until the page is refreshed). So there is no unloading function.
The expression to load JS is a bit different because I couldn’t find a way make the condition like the syntax when it all came back in one string, like the css loader does.
The JS can be a bit tricking to both write and store in a function. When using a verbatim string, it doesn’t like the JS key words (let or var) sometimes.
Also when trying to use the condition to load the JS, it doesn’t like double quotes in the code, it throws a syntax error. It must do some quote escaping. So you will notice I used backticks instead.
Both CSS and JS doesn’t have to be stored in a function. You could create a different function, similar to the StyleLoader, that inserts a style or script tag that points to a url. I just didn’t make it that far. Storing it in Epicor can make it easier to use in test/dev environments without having to be dependent on another server.
KineticCSSJS.zip (13.6 KB)