Rally Software

  • 1.  Help with Portfolio Item Copy

    Posted May 16, 2019 02:16 AM

    Does anyone have expertise with the Portfolio Item Copy app?

     

    I'm trying to modify it to add the following functionality: is it possible to identify the Portfolio Item Type and append to the name in the new copy?

     

    For example, in the createItem function:

    • If the item being copied is Feature - rec.set("Name","THIS TEXT") for the new copy
    • If the item being copied is a Team Feature - rec.set("Name","THAT TEXT") for the new copy
    • if the item being copied is a User Story - rec.set("Name","SOME OTHER TEXT") for the new copy

     

    Thank you!!

    Attachment(s)



  • 2.  Re: Help with Portfolio Item Copy
    Best Answer

    Broadcom Employee
    Posted May 16, 2019 09:31 AM

    Hi Mir.

    Essentially this is a community app, these apps are provided as-is, we're not supporting them and we expect the community to maintain and possibly extend/update them. With that said, I believe I can help you. 
    Attached you find a HTML file. Please check out lines: 268-288. These lines were added to the original file. All else is same. In these lines you can see a code that's essentially appends text to the 3 item types you had mentioned ('Feature', 'TeamFeature' and 'hierarchicalrequirement' - which is a user-story). lines 275,279 and 284 are where you can replace the text you need for each case. The code essentially finds the type of the portflio item and will concatenate different text based if that type is 'Feature' or 'TeamFeature' - these are supposed to be actual types in your portfolio item hierarchy.
    I tested this code and it works.
    What you can/should do is backup your current app file so that you have a copy of your current app. Then, replace the app with the file attached here. Then replace these lines with the text you need for these cases and test it. Also, make sure the portfolio item types as written in lines 274/ and 278 (Feature and TeamFeature) are the exact names of these types in your hierarchy. These are case sensitive so if your casing is different, then please edit these lines.
    Let me know if that worked. If it didn't then I would hope I can still help, but as said earlier, this isn't formally supported.
    Thanks,
    Sagi


  • 3.  Re: Help with Portfolio Item Copy

    Posted May 17, 2019 01:54 AM

    Sagi,  Thank you so much!  That worked like a charm!!

     

    I was trying to further extend the functionality further and select a color for all new items that are being created.  I tried using if (field === 'DisplayColor') but doesn't quite work.  I'll try and attach a copy of my code.

     

    Please note, this modification ignores the "Project" field.  The idea is to keep the Project field the same between the source and target.



  • 4.  Re: Help with Portfolio Item Copy

    Posted May 17, 2019 01:55 AM

    Hmm...doesn't look like I can add an attachment.



  • 5.  Re: Help with Portfolio Item Copy

    Broadcom Employee
    Posted May 17, 2019 01:16 PM

    Hi Mir,

    I'm glad it works and helped

     

    I don't see an attachment from you. Can you edit the entire post thread, are you able to then include an attachment?

     

    Sagi



  • 6.  Re: Help with Portfolio Item Copy

    Posted May 18, 2019 05:40 PM

    Hi Sagi,

     

    Thank you, that worked!  I've attached a copy of the code.



  • 7.  Re: Help with Portfolio Item Copy

    Broadcom Employee
    Posted May 19, 2019 10:18 PM

    Hi Mir,

     

    Thanks for your file. I included a 2nd version of my file, please find it attached (file name has 'v2'). Please look at lines 291-301. You shall see that I included an 'if' clause for the DisplayColor field. I tested it and it's working. I realize in your code you also condition based on 'BU', so my suggestion, take my skeleton code, apply it to yours as-is, test and see it's working (regardless of BU), then create your further conditions based on the BU. This way you'll know this is working to begin with and if stops once you add your BU conditions then you shall know where to troubleshoot. Also, remember to choose the 'Color' field in the app's settings when you use this code, otherwise the DisplayColor is not part of that array of fields.

     

    Lastly, just as a recommendation:

    If/when you get this to work and if you have more intentions to continue extending this code for even additional fields and their use-cases, then instead continuing to next all of these if-else clauses I'd recommend you consider changing the structure to something like this:  This some pseudo-code just to give you the idea of what I mean:

     

    if (field === 'field1') {

    }

     

    if (field === 'field2') {

    }

     

    if (field === 'field3') {

    }

    ..

    ..

    if (field === 'fieldX') {

    }

     

    else {

    }

     

    this way would be more readable for each field name, in this way the 'else' is the one final case which is not any of the fields handled earlier. I hope it makes sense.

     

    Let me know if all that helped.

     

    Sagi