Issues sending data from Client controller to Server in widget

Bushra Syed
Tera Contributor

Hi!

I want to send some data to the server from the client, and have the server wait until it gets that data. This is the code I am currently trying:

Client Controller:

c.data.abc='Value';
c.func_name= function() {
     c.server.update();
}

Server:

if (input) {
        console.log("input");
        gr.query('mapnumber', input.abc);
} else {
        gr.query();
    }

This code doesn't work, as it never goes into the if statement. Am I doing something wrong?

4 REPLIES 4

Allen Andreas
Administrator
Administrator

Hi,

It looks like you maybe used this post as an example: https://community.servicenow.com/community?id=community_question&sys_id=e901d1afdb0aa7c0afc902d5ca96...

But ideally, you'd want to use ServiceNow documentation, unless the post was actually marked as Correct, then it may have a bit more weight to it.

If that is all you have in your client script, then that won't work. "c" needs to be defined.

Please refer to ServiceNow Developer tutorials, etc. for more assistance: https://developer.servicenow.com/dev.do#!/learn/learning-plans/paris/servicenow_application_develope...

Please mark reply as Helpful/Correct, if applicable. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

Hi! I do have "c" defined, but it still isn't working as expected. I'll look into the documentation as well.

Hi,

Sounds good. Here's an additional resource to help as well with examples: https://docs.servicenow.com/bundle/rome-servicenow-platform/page/build/service-portal/concept/widget...

and

https://docs.servicenow.com/bundle/rome-servicenow-platform/page/build/service-portal/concept/adv-wi...

Please mark reply as Helpful/Correct, if applicable. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

Hi @Bushra Syed 

Thanks for marking my reply as Helpful.

If it also helped guide you Correctly, please also mark as Correct.

Thanks and take care! 🙂


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!