vinmore - Wednesday, May 8, 2013 7:54 AM:
Hi ,
I have an action(Client), click on the Action first opens 'User' Search Dialog. Select an User and get the selected user' s name and E-mail id. The code I' m using is:
alert("Please select an User as Recipient");
var param = { aras: top.aras, itemtypeName: 'User', multiselect: false };
var dlgRes = showModalDialog('searchDialog.html', param, 'dialogHeight:450px; dialogWidth:700px; status:0; help:0; resizable:1;');
if(!dlgRes) { return; }
var searchedItem = dlgRes.item;
top.aras.applyMethod("ServerMethod");
1) How can I get the selected User' s properties here? searchedItem.getProperty("") will work?
Server Method(C#) is having the following code:
string username = "";
string e-mail ="";
// Code to send an E-mail to the selected User //
2)How to pass the Javascript variables to the Server method which gets called from Javascript. Consider If I have var e-mail="get from selected user" in the above Javascript , then Is it possible to pass the same value to the variable in server method?
Thank you, Vin
Brian - Friday, May 10, 2013 6:39 AM:
See Generic methods in the programmer's refernce for how to call server methods from client methods and pass variables.
You should also have a look at setting up debugging so you can see what the variables are and that they are what you expect.
Hope this helps,
Brian
vinmore - Friday, May 10, 2013 7:15 AM:
Thanks Brian,
Yeah I have read that and I' m using the 'applyMethod' in my code as well(Mentioned above). But in the programmers Guide I did' t find anything about using the Javascript variables in the Server Method. applyMethod() is only to run the Server Method from JS. Is' t It?
And Did you check my first question?
newcomer - Friday, May 10, 2013 8:59 AM:
As brain said there is an example in the programmers guid with the information you need...
you can do something like this:
top.aras.applyMethod("ServerMethod","<userid>"+searchedItem.getProperty("id","")+"</userid><email>"+searchedItem.getProperty("email","")+"</email>")
in the server method you can access the passed parameters with this.getProperty("email","") and this.getProperty("userid","")... I hope that answers your questions.
Greets
Brian - Friday, May 10, 2013 4:28 PM:
HI Vinmore,
The thing you seem to be missing is that applyMethod(..) takes two parameters. The name of the server method to call and a "body" string that can be anything you want. Usually this is well formed xml that can be used to pass values from the client method to the server method.
In the client method:
var inn = this.getInnovator();
var body = "<myTag1>SomeValue</myTag1><myTag2>AnotherValue</myTag2>";
var result = inn.applyMethod(serverMethodName,body);
// do something with the result.
In the server method:
Innovator inn = this.getInnovator();
string myTag1Value = this.getProperty("myTag1","");
string myTag2Value = this.getProperty("myTag2","");
// do something with these values.
return inn.newResult("OK"); // or you could return this;
Hope this makes it clear.
Brian.