How can I run JavaScript code on the blank Web application?

Hi, all.


How can I run a JavaScript code on the blank Web application which doesn't have the Screens?


What I want to do is using the"md5.js" which is the open source code I can make the String into MD5Hashed String.


I imported  this file from Data > Resources, but couldn't use it well...


Could anyone help me out?


Regards.

Hello Yukiya,

JavaScript is a BROWSER script language.
You can't run it in a Server Action, for example. It needs to be sent back to the browser, where it will be executed.

At the server-side, you can use this API that allows you to encrypt using MD5: https://success.outsystems.com/Documentation/10/Reference/OutSystems_APIs/PlatformPasswordUtils_API

The link is for version 10, but version 11 of the platform also has it.

Hope this helps.

Cheers


Eduardo Jauch wrote:

Hello Yukiya,

JavaScript is a BROWSER script language.
You can't run it in a Server Action, for example. It needs to be sent back to the browser, where it will be executed.

At the server-side, you can use this API that allows you to encrypt using MD5: https://success.outsystems.com/Documentation/10/Reference/OutSystems_APIs/PlatformPasswordUtils_API

The link is for version 10, but version 11 of the platform also has it.

Hope this helps.

Cheers



Thank you for your reply.


Actually, I need to convert the hashed string to the hex String.

I couldn't find the way to convert to hex String.


In this JS code, both things I need to do is already implemented...


Regards.

Hi Yukiya 

You can find a Server Action called "RunJavaScript" within the HTTPRequestHandler application. 

It can be used within a Server Action stream.

Solution

@Roberto,

The RunJavaScript action does not run IN the Server Action. It will deliver the JavaScript to the Browser in the response. The JavaScript will be sent back to the Browser.

So, it is not the solution.

@Yukiya,

Is this the library you are using? https://github.com/blueimp/JavaScript-MD5

Is this the function you are referring?

function rstr2hex(input) {
    var hexTab = '0123456789abcdef'
    var output = ''
    var x
    var i
    for (i = 0; i < input.length; i += 1) {
        x = input.charCodeAt(i)
        output += hexTab.charAt((x >>> 4) & 0x0f) + hexTab.charAt(x & 0x0f)
    }
    return output
  }

You probably can implement it in OutSystems, creating your own function, or in C# (extension).
Not sure if in OutSystems there is something...
Hope this helps...

Cheers

Solution

@Eduardo

>You probably can implement it in OutSystems, creating your own function, or in C# (extension).
>Not sure if in OutSystems there is something...


Thank you for your reply.

Sorry, what do you mean "you cam implement it in OutSystems"?

Not like using the "RunJavaScript" Action?

I can write codes with any other way?


Regards.

Well, 

This JavaScript routine is just an algorithm that gets the character code of the raw string and convert it to an Hexadecumal string representation. 

You can create a Server Action in OutSystems and do the same algorithm. 

Eduardo Jauch wrote:

Well, 

This JavaScript routine is just an algorithm that gets the character code of the raw string and convert it to an Hexadecumal string representation. 

You can create a Server Action in OutSystems and do the same algorithm. 

Thank you for your help.

I managed to implement same function with C#.


Best Regards.