LESS Function -evo-widgetfile-url does not work as expected in Verint 12

I'm using a similar template to generate CSS from LESS styles as in the Site Theme (variables.less => variables.vm), to define styles for the widget based on some environment conditions and configuration settings.

I found that "-evo-widgetfile-url" does not work as expected in Verint 12.0.3.17950. But this function working well in Verint 11.1.x versions.

Sample code to reproduce this issue:

Widget Content component code:

$core_v2_page.AddLink('stylesheet', $core_v2_widget.GetExecutedFileUrl('render-styles.less'), "%{ Position = 'AfterTheme' }")

<div class="unique-wrapper">
</div>

Widget "render-styles.less" code:

@import "-evo-widgetfile-url('variables.vm')";

Widget "variables.vm" code:

#if ($core_v2_user.Accessing.Username == $core_v2_user.AnonymousUserName)
    .unique-wrapper {
        height: 100px;
        background: blue;
    }
#else
    .unique-wrapper {
        height: 100px;
        background: green;
    }
#end

On the page where this widget placed I see the following output in the network tab for my widget style file:
@import "-evo-widgetfile-url('variables.vm')";

Parents Reply Children
  • Yeah, I know about these techniques to use dynamic velocity styling or importing variables to styles.less with -evo-widgetconfig-x functions.

    But, I’m trying to resolve more complex task.

    I have custom configuration template with JSON object, that already contains LESS styles to render (configurable by admins) and additional values to configure LESS variables on the configuration panel side.

    So I’m not able to use less functions like -evo-widgetconfig-x in style.less attachments.

    For versions 11.1.x I found solution to execute custom dynamic vm/jsm files that generates LESS output to render into CSS with AddLink (for performance/caching reasons).

    For this case I used the function -evo-widgetfile-url to execute vm/jsm files. In v12 this solution doesn’t work for widgets.

    But after some attempts, I found that the “-evo-themefile-url” function does the same for v12 widgets and works like “-evo-widgetfile-url” in v11.

    Short summary:

    v11: “-evo-widgetfile-url” dynamically generates CSS styles in widgets

    v12: “-evo-themefile-url” dynamically generates CSS styles in widgets

    This finding is confusing.

    I guess, I can proceed with “-evo-themefile-url” for v12 widget, but is there any potential issue in the future?

  • I would still recommend against implementing this behavior in this way. Processed LESS files are processed and cached in a way that is only unique for the context/configuration of the page (basically the URL and page revision). Both authenticated and unauthenticated users will receive the same processed file and the IF statement in the embedded VM file will not change as expected when different users access the page with this widget.

    Instead, any logic that must rely on non-URL data (including the accessing user) should be rendered inline from the widget and not from within a LESS file.

    While I will log a bug to allow -evo-widgetfile-url to work in this situation, the behavior will not be as you expect because the file is cached without regard to the accessing user. VM/JSM files embedded in LESS files should be used with extreme care.

    The bug for the resolution to the underlying issue (but not the behavior your sample seeks):

    TE-17507: Cannot import -evo-widgetfile-url in LESS

    Completed for 12.1.2, 12.0.6

  •  , as always, thank you very much for your attention and suggestion!

    The conditional expression was a simple example to illustrate a problem when working with API. In my case, no sensitive data is used in solving the problem.

  • In my case, no sensitive data is used in solving the problem.

    Oh, good. Then this bug should/will address your concern.

  • I guess, I can proceed with “-evo-themefile-url” for v12 widget, but is there any potential issue in the future?

    Note that the resolution to the issue will make the correct/expected function work (for widgets, the -evo-widgetfile-url function will work and the -evo-themefile-url will not).