Book a Demo

Author Topic: JScript: Adding method parameter  (Read 3358 times)

David Goshadze

  • EA Novice
  • *
  • Posts: 7
  • Karma: +0/-0
    • View Profile
JScript: Adding method parameter
« on: August 30, 2010, 06:49:26 pm »
Hi all!
I'm writing custom Jscript which has to add some methods and parameters to class.
I am adding methods successfully, but have trouble adding parameters to newly created methots.

the code looks like:
Code: [Select]
var m as EA.Method;
var newParam as EA.Parameter;

...
...

Session.Output("Adding parameter: Name = " + p.Name + " type = " + p.Type);
newParam = m.Parameters.AddNew(p.Name, p.Type);
Session.Output("Created parameter: " + newParam.Name + " of type " + newParam.Type);
if (newParam.Update() == false)
{
      Session.Output(newParam.GetLastError());
}
m.Parameters.Refresh();

Execution gives me the following output:


Adding parameter: Name = SESSIONID type = NUMBER      
Created parameter: SESSIONID of type NUMBER      
DAO.Recordset [3022]      
      
The changes you requested to the table were not successful because they would create duplicate values in the index, primary key, or relationship.  Change the data in the field or fields that contain duplicate data, remove the index, or redefine the index to permit duplicate entries and try again.      


Can anyone help?

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: JScript: Adding method parameter
« Reply #1 on: August 30, 2010, 07:34:03 pm »
David,

Do you update() the new operation before adding the parameter?

Geert

David Goshadze

  • EA Novice
  • *
  • Posts: 7
  • Karma: +0/-0
    • View Profile
Re: JScript: Adding method parameter
« Reply #2 on: August 30, 2010, 08:16:51 pm »
Geert, many thanks to you again.

You're right. That was a problem.
I called new method's Update(), but after adding parameters.

Kind regards,
David.