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 update/Edit an Item property using Server side code (c#) and Client Side

DK@Aras - Wednesday, January 22, 2014 1:44 AM:

Hi,

I am new to Aras..Just started exploring it.

I have created an Item type (XYZ) and created a property called "total_quantity". Now i want to modify value of "total_quantity" of type text/string using custom code.

It would be helpful if anyone can guide me or provide sample code.

Find below same what i have tried after reading couple of document but not worked.

 

            Item item2 = inn.getItemById("XYZ", "1431CE51FB134164B09074CA75D29446");

            string totalvalue = item2.getProperty("total_quantity");

            item2.setProperty("total_quantity", "100");

           // Here 100 is constant value for total_quantity, which i want to update

            item2.setAction("edit");

            item2.apply();

Thanks in advance !!

 



gks - Thursday, January 23, 2014 3:56 AM:

depending on how the code is called, it is different.

 

Your code is right in some cases. however you still have to take care that edit can work (check the lock state)



DK@Aras - Thursday, January 23, 2014 4:26 AM:

Hi Georg,

Thank you for quick reply...

I have tried lock state in code, also manually i am taking care about locking of an item but it is not updating value.

Could you please provide info about different cases you are talking about and in which case above code is going to work.

Thank you again !!

 

 



gks - Thursday, January 23, 2014 8:30 AM:

update in an on beforeUpdate / onBeforeAdd event for that itemtype: this.setProperty("property", "value"); return this;

update in an onAfter event for that itemtype: not recommended to do this here

update in an action for a specific item: this.setProperty("property", "value"); return this;

update in an action for Itemtype: your statement

update in any trigger for a different itemtype: your statement

 

Note: default setting of SQL-Server does not allow to modify a table row within different transactions. Thus your statement can make problems in some cases.



DK@Aras - Friday, January 24, 2014 12:02 AM:

Hi Georg,

Thank you  for detailed explanation. It is really useful.

For an Item type,on "onbeforeUpdate" event , using " this.setProperty("property", "value"); return this;" command is showing "Value" in the grid of the item type but it is not displaying "Value" in the form where we are displaying this property.

Can you please guide me what else i am missing.

Thank you again !!