- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-27-2022 03:04 PM
Is it possible to use a script include in the client controller of a SP widget? If so, can I see an example?
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-27-2022 03:14 PM
Hello Bushra,
If you want to execute a script include, do it in the server side and then exchange the result with the client controller. That should be the way to do it.
In the client controller, set the variable "input" and use the server.get:
var input = {};
input.action = "your_action";
c.server.get(input).then(function(ans){
c.data.msg = ans.data.msg;
}
Then, in the server script, you need to have something like this:
if(input && input.action=="your_Action"){
var x = new your_script_include().your_method();
data.msg = x;
}
with this, you pass the result of your script include execution to data.msg and consume that in the client controller.
Hope this helps!
Please, don't forget to mark my answer as correct if it solves your issue or mark it as helpful if it is relevant for you!
Best Regards,
Filipe Cruz

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-27-2022 03:14 PM
Hello Bushra,
If you want to execute a script include, do it in the server side and then exchange the result with the client controller. That should be the way to do it.
In the client controller, set the variable "input" and use the server.get:
var input = {};
input.action = "your_action";
c.server.get(input).then(function(ans){
c.data.msg = ans.data.msg;
}
Then, in the server script, you need to have something like this:
if(input && input.action=="your_Action"){
var x = new your_script_include().your_method();
data.msg = x;
}
with this, you pass the result of your script include execution to data.msg and consume that in the client controller.
Hope this helps!
Please, don't forget to mark my answer as correct if it solves your issue or mark it as helpful if it is relevant for you!
Best Regards,
Filipe Cruz
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-27-2022 03:26 PM
Hi, How do I send in parameters to the script include in the server side?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-27-2022 03:48 PM
Hi Bushra,
You need to do like this: (picking the example I have before)
var input = {};
input.action = "your_action";
input.result = "input string for your script";
c.server.get(input).then(function(ans){
c.data.msg = ans.data.msg;
}
And then in the server side:
if(input && input.action=="your_Action"){
var x = new your_script_include().your_method(input.result);
data.msg = x;
}
Hope this helps!
Please, don't forget to mark my answer as correct if it solves your issue or mark it as helpful if it is relevant for you!
Best Regards,
Filipe Cruz