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 On Button .

Sachin - Monday, November 28, 2011 5:19 AM:

Hi All, this is Sachin.

I am working on Server Side methods, I created one server side method ,it returs a Item .

I am calling the Server SIde method on a Button Field (OnClick 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.

 

Thanks 

SACHIN G.



Brian - Monday, November 28, 2011 6:59 AM:

Hi Sachin,

You can't call server side methods directly from a button.

You need to call a Client Side method and then call the server side method as a Generic Method from the Client method.

See the Programmers handbook for generic methods.

Cheers,

Brian.



Sachin - Tuesday, November 29, 2011 1:59 AM:

Thanks for the reply.

its working now ....

now i'm working on client side method .

through the client side method i want to rename  document file name  at the time of file creation .

 

  var filePath = top.aras.vault.SelectFile();

  if (filePath === undefined || filePath === '')

      return this;

 

 var fileName = filePathRev.Substring(filePathRev.LastIndexOf('\') + 1);

 var ext = filePathRev.Substring(filePathRev.LastIndexOf('.') + 1);

 

// Add file

           var fileItem = inn.newItem("File", "add");

           fileItem.setProperty("filename", RevmyDocCoItem.getProperty("item_number") + "_" + revision + "." + ext);

           fileItem.attachPhysicalFile(filePathRev);

           var fileItem2 = fileItem.apply();

 

 

Above code is not working well , it shows me two times file selection dialog box .. 

Could you please point out whats going wrong and any modifications if required....

Thank you,

Sachin



Brian - Tuesday, November 29, 2011 4:29 PM:

HI Sachin,

Not sure exactly why you are getting two file dialog boxes however the following code works and does not bring up the second dialog box.

var ctx = document.thisItem;
var inn = ctx.getInnovator();

var filePath = top.aras.vault.SelectFile();
  if (filePath === undefined || filePath === ''){
      return false;
 }
 var pth = filePath.substring(0,filePath.lastIndexOf('\') + 1);
 var fileName = filePath.substring(filePath.lastIndexOf('\') + 1);
 var ext = filePath.substring(filePath.lastIndexOf('.') + 1);

// Add file
           var fileItem = inn.newItem("File", "add");

           fileItem.setFileName(filePath);
           fileItem.attachPhysicalFile(filePath);
           fileItem = fileItem.apply();

Your code also had some issues with the "Filename" property. This has to have the path in it and is the name of the existing file not a new name for the file.

Hope this helps,

Brian.



Sachin - Thursday, December 1, 2011 7:15 AM:

Thanks for the reply.

Can we popup dialog box from server side code (C#) i'm using following code for that..

 

DialogResult reply = MessageBox.Show("Question?",
            "Yes or No Demo",MessageBoxButtons.YesNo,MessageBoxIcon.Question);
      
            if (reply == DialogResult.Yes){
               MessageBox.Show("Yes");
            else {
               MessageBox.Show("No");
            }

 

 But above code  gives error  "Identifier Expected" ..

can we popup dialog box ? How? If not .. Then Any another alternative for that ??




Brian - Thursday, December 1, 2011 4:33 PM:

Hi Sachin,

No you can't pop up a dialog box from the server side. It has no windows context to display to the user.

If you want dialog boxes you have to do it on the Client Side using Javascript. You can use the Javascript "alert", "confirm" and "prompt" pop up boxes or build your own with HTML.

All user interface interactions happen from the Client Side.

Cheers,

Brian.



Sachin - Saturday, December 3, 2011 1:14 AM:

Thanks,

 

I want to add some references in to the Aras,,

can we do this? if yes then how? OR any another alternative for that ?

 

Sachin

 



Brian - Sunday, December 4, 2011 12:01 AM:

Hi Sachin,

You need to edit the "method-config.xml" under ./innovator/server/ directory

Here you can add references for VB and C# packages.

See the "Programmers Guide" downloadable from the Aras website.

Cheers,

Brian.



Sachin - Monday, December 5, 2011 6:00 AM:

Thanks Brian,

I want to use variable which is accessible in client side OR server side  methods.

I add some tag in the "web.config" file 

       <appSettings>

        <add key="CoDocFilePath" value="D:\ArasFile\Comall.xls"/>

      </appSettings>

 

and for accessing this variable from server side method ,I wrote following code 

 

   System.Configuration.ConfigurationManager.AppSettings.Get("CoDocFilePath");

 

but give error to me ...

Could you please point out whats going wrong in that code..

 

 

 

 



Brian - Monday, December 5, 2011 6:07 AM:

Hi Sachin,

Why don't you use the Variables item type under the Administrators Table of Contents (TOC).

You can define a new variable here and then use standard code to access it from client or server side.

client:

var myVariable = this.newItem("Variable","get");
myVariable.setProperty("name","CoDocFilePath");
myVariable = myVariable.apply();
var varValue = myVariable.getProperty("value","");

server:

Item myVariable = this.newItem("Variable","get");
myVariable.setProperty("name","CoDocFilePath)";
myVariable = myVariable.apply();
string varValue = myVariable.getProperty("value","");

Cheers,

Brian.



Sachin - Friday, December 9, 2011 2:53 AM:

Hey Brian,

Just wanted to drop a Big Thank You for u r help through out. 

Appreciate ur patient hearing of my problems and replying 'em.

Looking forward to many such educative interactions with you in future.

Keep Rocking,

Cheers!

Sachin