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 - Attaching files to a Relationship item type

sachin_71032 - Monday, February 27, 2012 2:23 AM:

I have a main Item type called Run and have defined a relationship Item type called "Run Input" which defines relation with item type File.

What I want to do is instantiate the Run item type and attach a file to the Relationship item through a method.

                 Item myRun = inn.newItem("Run", "add");
                myRun.setProperty("runno", "123");

                string vault =login_result.getProperty("default_vault");        
                               
                string pathname= @"D:output.txt";
               
                Item myRel = myRun.fetchRelationships("Run Input");
                Item myfile = inn.newItem("File", "add");
                myfile.setProperty("filename", "output.txt");
                myfile.setProperty("actual_filename",pathname );
                myfile.setProperty("checkedout_path", "D:");
                myfile.attachPhysicalFile(pathname, vault);

                myRel.apply();
                myRun.apply();

The above code is not working. Plz help me in this regard.

Thanks.



Boro - Wednesday, February 29, 2012 8:08 PM:

Hello

I usually add items like below.

--------------------------

Item myRun = inn.newItem("Run", "add");

myRun.setProperty("runno", "123");

string vault =login_result.getProperty("default_vault");

string pathname= @"D:output.txt";

Item myRel = inn.newItem("Run Input","add");

Item myfile = inn.newItem("File", "add");

myfile.setProperty("filename", "output.txt");

myfile.setProperty("actual_filename",pathname );

myfile.setProperty("checkedout_path", "D:");

myfile.attachPhysicalFile(pathname, vault);

 

myRel.setRelatedItem(myfile):

myRun.addRelationship(myRel);

 

myRun.apply();

--------------

Sorry, but I didn't check this code. My points is that you should call "setRelatedItem" and "addRelationship" method if you want to add relationship items.

Thanks