This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

DEVELOPERS FORUM - How to get parameter in Server Method

rootkiter - Friday, December 3, 2010 10:15 PM:

In Aras Innovator Guid have simple code to demo applyMethod() like this:

var inn = this.newInnovator();
var results = inn.applyMethod("Reverse String", "<string>abc</string>");
// You can also apply a generic client method but only from another client-side method
// var results = inn.applyMethod("Reverse String JS","<string>abc</string>","client");
return results.getResult(); // returns "cba"

So, how to get 'abc' parameter in method "Reverse String"?



Brian - Saturday, December 4, 2010 7:02 AM:

When you are in the method "Reverse String" the passed in parameters are just Properties.

so: var str = this.getProperty("string");

will give you str = "abc"

Cheers,

Brian.



rootkiter - Saturday, December 4, 2010 8:57 AM:

Thank you Brian, it's run ok now. But when i get the result in javascript

results.getResult();

it's show error message. What's my wrong?



Brian - Saturday, December 4, 2010 8:59 AM:

What's the error message?



rootkiter - Saturday, December 4, 2010 9:24 AM:

My server's code is like this:

....

string val = this.getProperty("string");

Item res = inno.newResult(val);

return res;

My client's code is like this:

.....

var results = inn.applyMethod("Method Name","<string>abc</string>","client"); 

alert('test') /////here is ok

alert(results.getResult());  ///Error here

The error message is only "Method Test throw exception". But if i replace the last client's code by 

alert(results.getResult);  ///Error here

The message box show 'undefine'

Plz tell me what is my wrong?