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 call Server methods ......

vijayvaradhi - Monday, April 13, 2009 2:10 AM:

Hi All, this is Vijay.

Iam working on Server Side methods, I created one server side method ,it returs a String .
I want to call the returned string value in one of my control let it be in a textbox.

In order to call Server Method, I created one more method in Java Script and it has the following code.

var

 

inn = this.newInnovator();
var  results = inn.applyMethod("mtdChkRanges_Server");
return  results.getResult();

mtdChkRanges_Server  is my server method name.
 

 

Iam calling the Client Side method in a Textbox field event , its showing the below error.

Internal Error: event handler failed.Event handler failed with message: Object doesn't support this property or methodClient Side Error

Can any one please send me the Solution as early as possible.

 



vijayvaradhi - Monday, April 13, 2009 6:24 AM:

 

 

 

 

 

 

 

 

 

 

 

 

Solution for calling the ServerMethods from Aras Innovator.
Dear Friends ... I got the Solution for calling the Server method in a Java Script(Client Side) or from any where outside of Aras Innovator.

This code example is written in Java Script

//mtdChkRanges_Server : This is my method name , it returns a String .
the returned string iam assigning to a TextBox control.

var 

 

myTextField = document.getElementById('txtItemProp');
var  innovator = new Innovator();
var  results = innovator.applyMethod("mtdChkRanges_Server", "<string></string>");
myTextField.value = results.getResult() ;

 

Thanks ,
Vijay Varadhi.



souheil - Friday, February 4, 2011 2:41 PM:

Refer to innovators programmers guide. Page 55.  You can find your solution

7.12 Apply a Generic Method

You want to write Generic Methods that can be used as subroutines for other Methods.

Technique

Use the

 

 

Innovator.applyMethod()

method to apply Generic Methods. The following examples assume a server-side method named "Reverse String" exists, and that it returns a result item containing the reversed contents of the <string> tag.

JavaScript

var inn = this.getInnovator();

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"

C#

Innovator inn = this.getInnovator();

Item results = inn.applyMethod("Reverse String", "<string>abc</string>");

// Return a result item with "cba" as the contents of the Result tag

return inn.newResult(results.getResult());

VB.Net

Dim inn As Innovator = Me.getInnovator()

Dim results As Item = inn.applyMethod("Reverse String", "<string>abc</string>")

' Return a result item With "cba" As the contents of the Result tag

Return inn.newResult(results.getResult())



ashu_vik - Thursday, August 27, 2009 5:31 AM:

Hi Vijay,

You wrote about calling server methods from javascript client. Is it always necessary to call the server methods by using client methods?

For e.g. I am using a PR workflow. I want to call a Server method when ReviewPR activity  occurs. For that what do i need to do? Do i need to write a client method or will events such as 'OnActivate event'/ 'Ondelegate event' itself call the Server methods? 

Thanks,

Ashu



Brian - Saturday, February 5, 2011 12:20 AM:

Please note there is an error in the Documentation (Aras is aware of it) for calling a Client Method from a Client method.

The correct call is:

top.aras.evalMethod("MethodName", this.node.xml);

The second object in evalMethod() is where you can pass the inDom to the second JavaScript method (this.node.xml may not be correct depending on where you are calling the method from)
Cheers,
Brian.


fli - Thursday, February 3, 2011 9:10 AM:

Hi,

Can you tell me how to make Javascript handle collection of Items when returned from a serverside method ?

When I try to .getItemByIndex(x) I get fault that: I am out of bounds of the array.  for every x

When I try to .getProperty("name","")  I get fault : not a single Item

I have written the collection item to a alert and it is a collection af items.

 

What is returned by the serverside is like this. but multiple items.

 

<Result>
<Item type="MAN_Part" typeId="1B1D815590534400B4306B8B9219AA99" id="F71D7FD29D3840B1B0248FA3A48F34BE">
<is_released>0</is_released>
<_augsburg_part_id/>
<_material_alternative/>
<id keyed_name="EN150Y00304472 PREC.STEEL PIPES W.CERT." type="MAN_Part">F71D7FD29D3840B1B0248FA3A48F34BE</id>
<major_rev>1</major_rev>
<tc_rev>0</tc_rev>
<_external_standards/>
<_revision_change/>
<_material>S12R</_material>
<keyed_name>EN150Y00304472 PREC.STEEL PIPES W.CERT.</keyed_name>
<_unit_of_measure/>
<classification>/MAN_Part/Std Part</classification>
<_predecessor/>
<_usability/>
<generation>2</generation>
<modified_by_id keyed_name="Christoffer" type="User">6070188C1EC04331A282A4FDCC72C7CE</modified_by_id>
<new_version>0</new_version>
<not_lockable>0</not_lockable>
<created_by_id keyed_name="Innovator Admin" type="User">30B991F927274FA3829655F50C99472E</created_by_id>
<_component/>
<_group/>
<_remarks/>
<permission_id keyed_name 

thanks,

BR/ Christoffer



Brian - Saturday, February 5, 2011 12:28 AM:

Hi Christoffer,

This code gets a collection of Relationship Item Types and iterates through the collection retrieving some information and calculating a sellPrice. This is a c sharp method but the calls are the same in Javascript

Item chargeRels = this.newItem("Related Type Name", "get");

chargeRels.setProperty("source_id",  stringID );

chargeRels.setAttribute("select", "related_id(price),quantity");

chargeRels = chargeRels.apply();

double sellPrice = 0;

for ( int i = 0; i < chargeRels.getItemCount(); i++)

{

 

Item chargeRel = chargeRels.getItemByIndex(i);

Item charge = chargeRel.getItemsByXPath("./related_id/Item");

Item chg = charge.getItemByIndex(0);

double cost = Convert.ToDouble(chg.getProperty("price","0"));

double qty = Convert.ToDouble(chargeRel.getProperty("quantity","0"));

sellPrice += ( cost * qty );

}

Hope this helps

Cheers,

Brian.



fli - Tuesday, February 8, 2011 10:44 AM:

Hi,

Ok thanks, this was helpfull

 

BR/ Christoffer