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 - Creation of an item and uiShowItemEx

daniele_scattaglia - Thursday, May 12, 2011 4:27 AM:

Hi

this is my problem: I use this piece of code that is connected to onChange event of a field of type 'item'

var  valve_serial_number = top.aras.newItem("Valve Serial Number","add");
top.aras.setItemProperty(valve_serial_number,"serial_number",this.value);
top.aras.saveItemEx(valve_serial_number,false);
top.aras.uiShowItemEx(valve_serial_number);

to create and display a new item, but when I try to unlock the item (by clicking on save,unlock and close in the opened window), I receive an error message (item already exists). The property valve_serial_number is marked as 'unique'.

There is a way to tell the new window that the item has already been saved?

Thanks



Brian - Thursday, May 12, 2011 8:26 AM:

Hi Daniele,

I think you want run a method on the onBeforeAdd and onBeforeUpdate Item Type Server events.

You can look for the attribute:

"isNew" and remove it or set set it = "0"

and

"action" set to "update" - it is probably set to "add" when you first go in.

I'm not sure why you are creating the Item the way that you are. Have you tried not calling the Save method and just calling the ShowItem?

Hope this helps,

Brian.



daniele_scattaglia - Thursday, May 12, 2011 11:53 AM:

Hi

This is what i'm doing:

I have a field of type 'item' in the parent window where i specify the serial number. If that serial number doesn't exist, then I create a new item of type  'serial number' and show the window where the user can specify the other property of itemtype 'serial number'. The new window is populated with the value of the field of parent window(that's why i'm using onChange event). What I want to do is save the 'serial number' with all the property and return to parent window, but saving the item I get the message error.

Daniele