Book a Demo

Author Topic: Custom properties - Update Value  (Read 3001 times)

Dalia

  • EA Novice
  • *
  • Posts: 6
  • Karma: +0/-0
    • View Profile
Custom properties - Update Value
« on: February 20, 2014, 11:46:46 pm »
Hi all,

I've been trying to add parameters to an InfrastructureService.
To do that I've implemented the following function to create the activityParameter and to update the direction property value. direction is an input parameter to this function and can have the values in/out/inout.

function AddParameter (objparent, nome, direction)

      set parm = nothing

      if objparent is nothing then
            set parm = objparent.Elements.AddNew(nome, "ActivityParameter")
            parm.update()

            for each c in parm.customproperties
                  if strcomp(c.name, "direction")=0 then
                              c.value = direction
                  end if
            next
            parm.update()
      end if
      
      set AddParameter = parm
      
end function


What I state calling this function is that the direction parameter always assumes the last set value independently of the ActivityParameter being created/manipulate. For instance, after executing the following code

      set theParameter = AddParameter (root, "teste1", "in")
      set theParameter = AddParameter (root, "teste2", "out")
      set theParameter = AddParameter (root, "teste3", "inout")
      set theParameter = AddParameter (root, "teste4", "inout")

teste1, teste2, teste3 and teste4 all have the "inout" value in the direction parameter.

I've tested this in version 10 and 11.

Can you please help?




Dalia

  • EA Novice
  • *
  • Posts: 6
  • Karma: +0/-0
    • View Profile
Re: Custom properties - Update Value
« Reply #1 on: February 21, 2014, 01:52:30 am »
In the mean time I changed the function to the one below an it is working not being sure why did it start to work.

function AddParameter (objparent, nome, direction)

      set parm = nothing

      if not (objparent is nothing) then
            set parm = objparent.Elements.AddNew(nome, "ActivityParameter")
            parm.update()

            for each c in parm.customproperties
                  if strcomp(c.name, "direction")=0 then
                              c.value = direction
                  end if
            next
            if not(parm.update()) then
                        session.output "error"
            end if
      end if
      
      set AddParameter = parm
      
end function

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Custom properties - Update Value
« Reply #2 on: February 21, 2014, 01:55:23 am »
I just tried it and had no problem. So likely you must be doing something wrong. Likely it's something in that hidden AddParameter method.

q.

P.S. So I was right  ;D
« Last Edit: February 21, 2014, 01:56:15 am by qwerty »