1008
Views
16
Comments
Solved
Add Script to Outsystems Mobile
Question

Hi.

I was wondering if it was possible to add a script like this --> <script type="text/javascript" data-app-id="YOUR-APP-CLIENT-ID" src="https://c64.assets-yammer.com/assets/platform_js_sdk.js"></script>

to your mobile application.

2020-02-28 09-46-54
Eduardo Jauch
Solution

Hi Saurav,

Suraj is right when he pointed you in the direction of using a JavaScript in the OnReady.
But you need to add it to the DOM. Here is a code that should work.

var script_src = 'https://c64.assets-yammer.com/assets/platform_js_sdk.js';
var head = document.getElementsByTagName('head')[0];
var new_script = document.createElement('script');
new_script.type = 'text/javascript';
new_script.src= script_src;
new_script.setAttribute('data-app-id', 'YOUR-APP-CLIENT-ID');
head.appendChild(new_script);

Remember that in yammer your domain must be whitelisted in the configuration:

https://developer.yammer.com/docs/js-sdk

Cheers,
Eduardo Jauch

UserImage.jpg
Saurav Sircar

Eduardo Jauch wrote:

Hi Saurav,

Suraj is right when he pointed you in the direction of using a JavaScript in the OnReady.
But you need to add it to the DOM. Here is a code that should work.

var script_src = 'https://c64.assets-yammer.com/assets/platform_js_sdk.js';
var head = document.getElementsByTagName('head')[0];
var new_script = document.createElement('script');
new_script.type = 'text/javascript';
new_script.src= script_src;
new_script.setAttribute('data-app-id', 'YOUR-APP-CLIENT-ID');
head.appendChild(new_script);

Remember that in yammer your domain must be whitelisted in the configuration:

https://developer.yammer.com/docs/js-sdk

Cheers,
Eduardo Jauch

Thank you Eduardo. Worked fine, but I'm getting a new error: "XMLHttpRequest cannot load https://www.yammer.com/platform/login_status.json?client_id=wZuyoeLNhd1SR6pF5faXUg. The value of the 'Access-Control-Allow-Origin' header in the response must not be the wildcard '*' when the request's credentials mode is 'include'. Origin 'https://saurav-sircar.outsystemscloud.com' is therefore not allowed access. The credentials mode of requests initiated by the XMLHttpRequest is controlled by the withCredentials attribute."


I'm not sure how to add a header. Any idea how to fix this?


2020-02-28 09-46-54
Eduardo Jauch

Saurav Sircar wrote:

Eduardo Jauch wrote:

Hi Saurav,

Suraj is right when he pointed you in the direction of using a JavaScript in the OnReady.
But you need to add it to the DOM. Here is a code that should work.

var script_src = 'https://c64.assets-yammer.com/assets/platform_js_sdk.js';
var head = document.getElementsByTagName('head')[0];
var new_script = document.createElement('script');
new_script.type = 'text/javascript';
new_script.src= script_src;
new_script.setAttribute('data-app-id', 'YOUR-APP-CLIENT-ID');
head.appendChild(new_script);

Remember that in yammer your domain must be whitelisted in the configuration:

https://developer.yammer.com/docs/js-sdk

Cheers,
Eduardo Jauch

Thank you Eduardo. Worked fine, but I'm getting a new error: "XMLHttpRequest cannot load https://www.yammer.com/platform/login_status.json?client_id=wZuyoeLNhd1SR6pF5faXUg. The value of the 'Access-Control-Allow-Origin' header in the response must not be the wildcard '*' when the request's credentials mode is 'include'. Origin 'https://saurav-sircar.outsystemscloud.com' is therefore not allowed access. The credentials mode of requests initiated by the XMLHttpRequest is controlled by the withCredentials attribute."


I'm not sure how to add a header. Any idea how to fix this?


Hello Saurav,

Have you included your site in the list of the site?

Your application must be set in there, so the Yammer accepts the XMLHttpRequest.
This is always done in the side that will receive the request, not in your application

Cheers,
Eduardo Jauch


UserImage.jpg
Saurav Sircar

Eduardo Jauch wrote:

Saurav Sircar wrote:

Eduardo Jauch wrote:

Hi Saurav,

Suraj is right when he pointed you in the direction of using a JavaScript in the OnReady.
But you need to add it to the DOM. Here is a code that should work.

var script_src = 'https://c64.assets-yammer.com/assets/platform_js_sdk.js';
var head = document.getElementsByTagName('head')[0];
var new_script = document.createElement('script');
new_script.type = 'text/javascript';
new_script.src= script_src;
new_script.setAttribute('data-app-id', 'YOUR-APP-CLIENT-ID');
head.appendChild(new_script);

Remember that in yammer your domain must be whitelisted in the configuration:

https://developer.yammer.com/docs/js-sdk

Cheers,
Eduardo Jauch

Thank you Eduardo. Worked fine, but I'm getting a new error: "XMLHttpRequest cannot load https://www.yammer.com/platform/login_status.json?client_id=wZuyoeLNhd1SR6pF5faXUg. The value of the 'Access-Control-Allow-Origin' header in the response must not be the wildcard '*' when the request's credentials mode is 'include'. Origin 'https://saurav-sircar.outsystemscloud.com' is therefore not allowed access. The credentials mode of requests initiated by the XMLHttpRequest is controlled by the withCredentials attribute."


I'm not sure how to add a header. Any idea how to fix this?


Hello Saurav,

Have you included your site in the list of the site?

Your application must be set in there, so the Yammer accepts the XMLHttpRequest.
This is always done in the side that will receive the request, not in your application

Cheers,
Eduardo Jauch


Hi Eduardo.

Yes, I have included then under the Javascript Origins section.


2018-11-06 14-26-44
Suraj Borade

Hi Saurav

You can do this.

Go to page and go to OnReady action and this Javascript block.

In that Javascript block, you can add your Javascript code.

Thanks and Regards,

Suraj Borade

UserImage.jpg
Saurav Sircar

Suraj Borade wrote:

Hi Saurav

You can do this.

Go to page and go to OnReady action and this Javascript block.

In that Javascript block, you can add your Javascript code.

Thanks and Regards,

Suraj Borade

Getting this error on Chrome: Uncaught SyntaxError: Unexpected token <


2018-11-06 14-26-44
Suraj Borade

Check how you have typed your javascript code and google it out what that error means.

Also please go to debugger tool and check is there any details present.

UserImage.jpg
Saurav Sircar

Suraj Borade wrote:

Check how you have typed your javascript code and google it out what that error means.

Also please go to debugger tool and check is there any details present.

I googled the error. Most of them refer to upper case issues. I don't have those errors. And this was the error I got from debugging on Chrome. How else can I debug?


2020-07-16 17-08-27
user

Hello saurav,

No need to add <script> </script>

Outsystems already know you are adding js here.

2020-07-16 17-08-27
user

Hi Saurav,

Where you add JavaScript?

on page Javascript Property, Add javascript in preparation or else..



2020-07-16 17-08-27
user

Hi, I found solution.

The problem is, You added <script></script> tag into your js.

I did the same for testing and get following output



But when I remove the <script></script> tag JS working good



Let me know your problem solved or not.

2018-11-06 14-26-44
Suraj Borade

Gopal,

Great example but he is doing that for mobile application. So maybe from that Javascript block, he needs to remove <script> tag.

2020-07-16 17-08-27
user

Yes Suraj, I tested on mobile also and the problems because of <script> tag

2018-11-06 14-26-44
Suraj Borade

Yes since this is a javascript block, there is no need to mention script tag explicitly.

Saurav: Your problem should be solved just writing javascript code in the block.

2020-02-28 09-46-54
Eduardo Jauch
Solution

Hi Saurav,

Suraj is right when he pointed you in the direction of using a JavaScript in the OnReady.
But you need to add it to the DOM. Here is a code that should work.

var script_src = 'https://c64.assets-yammer.com/assets/platform_js_sdk.js';
var head = document.getElementsByTagName('head')[0];
var new_script = document.createElement('script');
new_script.type = 'text/javascript';
new_script.src= script_src;
new_script.setAttribute('data-app-id', 'YOUR-APP-CLIENT-ID');
head.appendChild(new_script);

Remember that in yammer your domain must be whitelisted in the configuration:

https://developer.yammer.com/docs/js-sdk

Cheers,
Eduardo Jauch

UserImage.jpg
Saurav Sircar

Eduardo Jauch wrote:

Hi Saurav,

Suraj is right when he pointed you in the direction of using a JavaScript in the OnReady.
But you need to add it to the DOM. Here is a code that should work.

var script_src = 'https://c64.assets-yammer.com/assets/platform_js_sdk.js';
var head = document.getElementsByTagName('head')[0];
var new_script = document.createElement('script');
new_script.type = 'text/javascript';
new_script.src= script_src;
new_script.setAttribute('data-app-id', 'YOUR-APP-CLIENT-ID');
head.appendChild(new_script);

Remember that in yammer your domain must be whitelisted in the configuration:

https://developer.yammer.com/docs/js-sdk

Cheers,
Eduardo Jauch

Thank you Eduardo. Worked fine, but I'm getting a new error: "XMLHttpRequest cannot load https://www.yammer.com/platform/login_status.json?client_id=wZuyoeLNhd1SR6pF5faXUg. The value of the 'Access-Control-Allow-Origin' header in the response must not be the wildcard '*' when the request's credentials mode is 'include'. Origin 'https://saurav-sircar.outsystemscloud.com' is therefore not allowed access. The credentials mode of requests initiated by the XMLHttpRequest is controlled by the withCredentials attribute."


I'm not sure how to add a header. Any idea how to fix this?


2020-02-28 09-46-54
Eduardo Jauch

Saurav Sircar wrote:

Eduardo Jauch wrote:

Hi Saurav,

Suraj is right when he pointed you in the direction of using a JavaScript in the OnReady.
But you need to add it to the DOM. Here is a code that should work.

var script_src = 'https://c64.assets-yammer.com/assets/platform_js_sdk.js';
var head = document.getElementsByTagName('head')[0];
var new_script = document.createElement('script');
new_script.type = 'text/javascript';
new_script.src= script_src;
new_script.setAttribute('data-app-id', 'YOUR-APP-CLIENT-ID');
head.appendChild(new_script);

Remember that in yammer your domain must be whitelisted in the configuration:

https://developer.yammer.com/docs/js-sdk

Cheers,
Eduardo Jauch

Thank you Eduardo. Worked fine, but I'm getting a new error: "XMLHttpRequest cannot load https://www.yammer.com/platform/login_status.json?client_id=wZuyoeLNhd1SR6pF5faXUg. The value of the 'Access-Control-Allow-Origin' header in the response must not be the wildcard '*' when the request's credentials mode is 'include'. Origin 'https://saurav-sircar.outsystemscloud.com' is therefore not allowed access. The credentials mode of requests initiated by the XMLHttpRequest is controlled by the withCredentials attribute."


I'm not sure how to add a header. Any idea how to fix this?


Hello Saurav,

Have you included your site in the list of the site?

Your application must be set in there, so the Yammer accepts the XMLHttpRequest.
This is always done in the side that will receive the request, not in your application

Cheers,
Eduardo Jauch


UserImage.jpg
Saurav Sircar

Eduardo Jauch wrote:

Saurav Sircar wrote:

Eduardo Jauch wrote:

Hi Saurav,

Suraj is right when he pointed you in the direction of using a JavaScript in the OnReady.
But you need to add it to the DOM. Here is a code that should work.

var script_src = 'https://c64.assets-yammer.com/assets/platform_js_sdk.js';
var head = document.getElementsByTagName('head')[0];
var new_script = document.createElement('script');
new_script.type = 'text/javascript';
new_script.src= script_src;
new_script.setAttribute('data-app-id', 'YOUR-APP-CLIENT-ID');
head.appendChild(new_script);

Remember that in yammer your domain must be whitelisted in the configuration:

https://developer.yammer.com/docs/js-sdk

Cheers,
Eduardo Jauch

Thank you Eduardo. Worked fine, but I'm getting a new error: "XMLHttpRequest cannot load https://www.yammer.com/platform/login_status.json?client_id=wZuyoeLNhd1SR6pF5faXUg. The value of the 'Access-Control-Allow-Origin' header in the response must not be the wildcard '*' when the request's credentials mode is 'include'. Origin 'https://saurav-sircar.outsystemscloud.com' is therefore not allowed access. The credentials mode of requests initiated by the XMLHttpRequest is controlled by the withCredentials attribute."


I'm not sure how to add a header. Any idea how to fix this?


Hello Saurav,

Have you included your site in the list of the site?

Your application must be set in there, so the Yammer accepts the XMLHttpRequest.
This is always done in the side that will receive the request, not in your application

Cheers,
Eduardo Jauch


Hi Eduardo.

Yes, I have included then under the Javascript Origins section.


2018-11-06 14-26-44
Suraj Borade

Hi Eduardo,

Thanks for the further help.

You are a real Javascript master.

Thanks and Regards,

Suraj Borade

2020-02-28 09-46-54
Eduardo Jauch

Hello Saurav,

Have you found a solution to this error?
I think that maybe you will have to do a "preauthorization": https://blogs.technet.microsoft.com/askyammer/2016/11/04/preauthorizing-the-yammer-js-sdk/

But I'm not sure.

Cheers,
Eduardo Jauch

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.