mendenaresh1357 - Sunday, August 14, 2011 10:13 PM:
Hi Members,
On Version of a Item I need to set values on both source Item and the Versioned Item. I am able to set value on the Source Item. but not able to set value on the newly Versioned Item.
I used the method item.setAttribute("action","edit") and got error Saying 'Item is already in Locked State'.
I used the method item.setAttribute("action","update") and got error Saying 'Item is not Locked by you'.
so finally i was forced to use applySQL(sqlQry). The Query executed fine but the value is not set on the newly Versioned Item.
my SQL Query is
"update itemtype set x='abc' where id = 'itemID'". but the value did not set on the Item.
Should i try the AML Query.. ? Any Suggestions?
Thanks,
Naresh Mende.
chado - Thursday, September 1, 2011 9:56 PM:
"edit" actions follow the "lock, update, unlock" pattern, so you must control lock state accordingly. Same goes for update, which assumes the item is locked.
The only way I was able to work with the newly versioned object was to query like:
<Item... action="get">
<config_id>this.getProperty("config_id","")</config_id>
....
AFAIK, this causes the framework to return the latest version of the item (meaning that having is_current=1).
You might also want to look at the versioned item in the database itself.. the returned context item onAfterVersion is not seemingly what it should be.
(take this with a grain of salt; I am just dealing with this in the last week or two, and the learning is ongoing.)
chado - Sunday, September 4, 2011 12:20 AM:
After further work I can be more clear:
what i've found is that if you change data on the newly versioned through code item it persists to the database but you cannot get a reference to the proper object until the onAfter stuff completes. I got tired of trying and ended up writing a generic method that versions the item through code (custom onClick) then updates it's state. After which I immediately proceed to work with it as needed.
mendenaresh1357 - Thursday, September 8, 2011 5:45 PM:
Hi Chado,
Thanks for the reply and sorry for late reply late reply from me.
even i used the AML (by passing only config_id) query to get the latest version on Item. but it returns all the versions.
to get the latest versioned item, we need to pass the id of the latest version or the the generation/version number of the latest version's item.
One strange issue i found is, i sometimes able to update the item(latest version) and sometimes the same code fails. below copied the code.
string amlQry = "<AML><Item type = 'itemtype' id = '"+temp2.getID()+"' action = 'update'>" +
"<propName>propValue</propName>"+
"</Item></AML>";
Item temp3 = inno.applyAML(amlQry);
No error was returned when this code fails to update.
I was not able to understand the reason for not updating. i will look further into it and will post u if any updates.
Thanks,
Naresh Mende.