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 - New Action , works similar to Check-in

Vardhan - Tuesday, April 30, 2013 2:09 AM:

Hi,

I have created a new Action for my ItemType to replace the old file with new  file, which should work similar to Check-in action of the Documents.   Please help me with some sample code how Check in works.

Thank you, Vardh. 



newcomer - Tuesday, April 30, 2013 4:38 AM:

Example from the developer docu:

var itm = this.newItem("File", "get");

itm.setAttribute("where", "[file].filename='customers.txt'");

itm.setAttribute("select", "id");

itm = itm.apply();

//item needs to be locked to attach file

itm.setAction("lock");

itm.attachPhysicalFile("c:\customers.txt");

itm = itm.apply();

//now save the changes to File Item

itm.setAction("update");

itm = itm.apply();

return itm;

 



Vardhan - Tuesday, April 30, 2013 6:25 AM:

Thank you,  I have tried this already, this is just locking the file not updating the file 

But I' m trying to do both the actions Lock and replacing the file with new one at a time. 



Vardhan - Tuesday, May 14, 2013 4:25 AM:

The example code is not replacing the file with new one. It is just locking the file related to my Item type. The code I am using is(VB):

 

Dim rel_files As Item  = Me.newItem("Tooling Files","get")  

rel_files.setProperty("source_id",Me.getID())

rel_files = rel_files.apply()

Dim results As Item = rel_files.getItemsByXPath("//Item[@type='File']")

Dim cnt As Integer = results.getItemCount() - 1

 Dim i As Integer  

  For i = 0 To cnt

    Dim file_item As Item = results.getItemByIndex(i)

     file_item.setAction("lock")

     file_item.attachPhysicalFile("D:\2.txt")

     file_item = file_item.Apply()

     file_item.setAction("update")

     file_item = file_item.Apply()

     Next i

Return Me    

 

Any changes to the code required? Please help me.