🚀 Welcome to MDriven Learn –  MDriven is now on Discord!  Don’t miss the latest Release Notes.
ClientScriptExecute
This page was created by Hans.karlsen on 2025-07-30. Last edited by Edgar on 2025-08-31.

When for example tracking conversions on your site with Google analytics you may be required to execute a small google provided script on certain actions.

If your are in Blazor or AngularJS rendering we know that you have a browser in the user end.

If you assign an existing js-function name (that you provide with a js file and include in component or global scripts) in this fomat:

FunctionName(argument)

The client (both blazor and angularJS) will detect and call this pre existing function by assigning a special string variable named vClientScriptExecute :

vClientScriptExecute:='MDrivenClientScriptExecute("Some string arg")' -- argument double quotate

We will try and match with: thescriptref.match(/^(\w+)\s*\(\s*"([^"]*)"\s*\)$/); - so you must include a param in double quotes

Once the vClientScriptExecute has a new value - the client will try and call it.

Do you need more arguments you need to encode them in the one argument available.

How to test:

  1. In EXT_Scripts/AppWideAngularScriptIncludes.htm put this line: <script src='EXT_Scripts/MyThings.js'></script>
  2. Create new file in EXT_Scripts/MyThings.js
  3. In MyThings.js add: function ThisIsMyFunction(param1){window.alert('This is my function alert('+param1+')')}
  4. In viewModel add Action with expression: vClientScriptExecute:='ThisIsMyFunction("hello man")'

Expected outcome: When you click the action - alert is showing like this:

Documentation ClientScriptExecute 1754929026208.png