The CreatorCon Call for Content is officially open! Get started here.

Can we call script include ( GlideAjax) from client controller ?

String
Kilo Sage

Hi Team ,

We using client controller to call the script include 

String_0-1678208182395.png

 

but we are enable to invoke the script include 

String_1-1678208234363.png

Please guide me where it went wrong 

 

1 ACCEPTED SOLUTION

Prince Arora
Tera Sage

@String ,

 

Can you please try this method:

PRINCE_ARORA_0-1678211003369.png

 

 

Client Code:

$scope.myFunc = function(){

c.data.shipto = $scope.page.g_form.getValue('shipto');
c.data.billto = $scope.page.g_form.getValue('billto')
c.server.update();
}

 

Server Code:

if (input && input.shipto && input.billto) {

//you can call script include here

var scriptInclude = new scriptIncludeName();

scriptInclude.functionName( input.shipto, input.billto);

 

If my answer solved your issue, please mark my answer as Correct & 👍Helpful based on the Impact!

View solution in original post

5 REPLIES 5

Hendrik Odendaa
ServiceNow Employee
ServiceNow Employee

Hi @String 

If you are using it in a widget: Unfortunately GlideAjax is not supported in the Client Controller of a Widget in Service Portal.
See support article: https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0691908

However, you can explore the use of c.server.get as explained in: https://community.servicenow.com/community?id=community_question&sys_id=28e38fa5dbd8dbc01dcaf3231f96...

Thanks @Hendrik Odendaa  for your quick response 

So any other way is there to call script include because we need to trigger an outbound soap using widget (client controller)

Hendrik Odendaa
ServiceNow Employee
ServiceNow Employee

Yes @String 

 

You can try and see if using c.server.get instead of GlideAjax in your widget's client script. Like brian_corpuz did in (look for the post at ‎07-10-2017 10:43 GMT): 

https://www.servicenow.com/community/developer-forum/glideajax-is-not-working-in-service-portal-widg...

Let me know if this resolved your issue, or if you need more clarification.

Prince Arora
Tera Sage

@String ,

 

Can you please try this method:

PRINCE_ARORA_0-1678211003369.png

 

 

Client Code:

$scope.myFunc = function(){

c.data.shipto = $scope.page.g_form.getValue('shipto');
c.data.billto = $scope.page.g_form.getValue('billto')
c.server.update();
}

 

Server Code:

if (input && input.shipto && input.billto) {

//you can call script include here

var scriptInclude = new scriptIncludeName();

scriptInclude.functionName( input.shipto, input.billto);

 

If my answer solved your issue, please mark my answer as Correct & 👍Helpful based on the Impact!