Lieutenant Commander
Lieutenant Commander
442 views

associate a requirement with a release in ALm using c#

Jump to solution

how can i copy release with it's associate  requirement using c# .i have copied alle Cyles and ScopeItem but i didn#t found out how to copy the associate  requirement fron old release to new one .thanks alot im advance for your help .

 ReleaseFactory relf = conn1.ReleaseFactory;//'ReleaseFactory
            List flist = folderFactory.NewList("");
                foreach (ReleaseFolder releaseFolder in flist)
                {
                    ScopeItemFactory sif,altsif;
                    ContentDefinitionFactory CDF,altCDF;
                    List listRel = (List)RelFact.NewList(RelFact.Filter.Text);
                    foreach (Release rl in listRel)
                        if (rl.Name == ReleasetreeView.SelectedNode.Name) //select old Release

                        {


                            NewORL = rl;
                            sif = NewORL.ScopeItemFactory;
                            altsif = ORL.ScopeItemFactory;
                           
                            NewORL.Post();
                        
                            foreach (ScopeItem si in altsif.NewList(""))
                            {

                                RMSI = sif.AddItem(System.DBNull.Value);



                                RMSI.Name = si.Name;
                                RMSI.Priority = si.Priority;
                                RMSI.AutoPost = si.AutoPost;
                                RMSI.Description = si.Description;
                               
                                RMSI.Post();
                                CDF = RMSI.ContentDefinitionFactory;
                                altCDF = si.ContentDefinitionFactory;
                                ContentPartFactory cpf,ncpf;
                                ContentRootFactory crf,ncrf;
                               
                                foreach (ContentDefinition CD in altCDF.NewList(""))
                                {
                                    string s=CD.Name;
                                    cpf = CD.ContentPartFactory;
                                 
                                    crf = CD.ContentRootFactory;
                                    ncrf = CD.ContentRootFactory;
                                    foreach (ContentRoot CR in crf.NewList(""))
                                    {


                                        ContentRoot = ncrf.AddItem(System.DBNull.Value);
                                        ContentRoot.Name = CR.Name;
                                        ContentRoot.RootEntityId = CR.RootEntityId;
                                        ContentRoot.RootEntityType = CR.RootEntityType;


                                         ContentRoot.Post(); //here i am getting error post key 


                                    }
                             
0 Likes
1 Solution

Accepted Solutions
Lieutenant Commander
Lieutenant Commander

thanks alot i have found my fehler 

 //Copy New ContentDefinition from selected ContentDefinition
                var CDF = RMSI.ContentDefinitionFactory;
                var altCDF = si.ContentDefinitionFactory;
               
                foreach (ContentDefinition CD in altCDF.NewList(""))
                {
                    CDFF= CDF.AddItem(System.DBNull.Value);
                    CDFF.Name = CD.Name;
                    CDFF.AutoCompleteType = CD.AutoCompleteType;
                    CDFF.Post();

                    //Copy New ContentRoot from selected ContentRoot
                    //ContentRoot is requirement
                    var crf = CD.ContentRootFactory;
                    var ncrf = CDFF.ContentRootFactory;
                  

                    foreach (ContentRoot CR in crf.NewList(""))
                    {

                        //Add associate a requirement
                        var ContentRoot = ncrf.AddItem(System.DBNull.Value);
                        ContentRoot.Name = CR.Name;
                        ContentRoot.RootEntityId = CR.RootEntityId;
                        ContentRoot.RootEntityType = CR.RootEntityType;
                        ContentRoot.Post();

                      

                    }
                }

View solution in original post

0 Likes
3 Replies

You can assign the Target release using the below 

https://github.com/sumeet-kushwah/ALM_OTA_Wrapper/blob/master/ALM_Wrapper/Requirements.cs

Look for "SetTargetReleases" Function.

Thanks,

Sumeet Kushwah

0 Likes
Lieutenant Commander
Lieutenant Commander

thanks alot for answering how can i get the associate a requirement from old release and then set it to TargetRelease:

 public TDAPIOLELib.List GetTargetReleases(TDAPIOLELib.Req req) //what should i send here 
        {
            TDAPIOLELib.List listofReleaseIDs = req["RQ_TARGET_REL"];
            return listofReleaseIDs;
        }
0 Likes
Lieutenant Commander
Lieutenant Commander

thanks alot i have found my fehler 

 //Copy New ContentDefinition from selected ContentDefinition
                var CDF = RMSI.ContentDefinitionFactory;
                var altCDF = si.ContentDefinitionFactory;
               
                foreach (ContentDefinition CD in altCDF.NewList(""))
                {
                    CDFF= CDF.AddItem(System.DBNull.Value);
                    CDFF.Name = CD.Name;
                    CDFF.AutoCompleteType = CD.AutoCompleteType;
                    CDFF.Post();

                    //Copy New ContentRoot from selected ContentRoot
                    //ContentRoot is requirement
                    var crf = CD.ContentRootFactory;
                    var ncrf = CDFF.ContentRootFactory;
                  

                    foreach (ContentRoot CR in crf.NewList(""))
                    {

                        //Add associate a requirement
                        var ContentRoot = ncrf.AddItem(System.DBNull.Value);
                        ContentRoot.Name = CR.Name;
                        ContentRoot.RootEntityId = CR.RootEntityId;
                        ContentRoot.RootEntityType = CR.RootEntityType;
                        ContentRoot.Post();

                      

                    }
                }

View solution in original post

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.