1 Reply · Latest reply on Dec 14, 2017 10:05 AM by Sean Witt

    Unable to copy related list from Demand to Project

      Hi All,

       

      I have created a custom related list for Demand similar to the one which is already available OOTB e.g. requirement, Risk etc.

      Now, when Project is created from Demand, I want to copy record in my custom related list to Project as well.

      I have tried looking into BR configured OOTB Create Strategic Type on Approve (false by default) but it's not working for me.

       

      Also tried creating BR on project table but I couldn't find Demand reference on the project.

       

      var dec = new GlideRecord("u_dmn_scope");

      dec.addQuery("parent", current.sys_id);

      dec.query();

      while(dec.next()){

      dec.parent = current.getUniqueValue();

      dec.update();

      gs.log("Scope created for Project " + project.number);

      }

       

      Please advice.

       

      Thanks in advance

        • Re: Unable to copy related list from Demand to Project
          Sean Witt

          You may want to take a look at the Script Include named "DemandToProjectCreationHelper".

           

          When you create a project from a Demand form, you do it using the "Create Project" UI Action. The code for that UI Action calls the "AjaxCreateRelatedEntityFromDemand" Script Include, which calls the "DemandToProjectCreationHelper".

           

          Starting at line 88 of that script, you will see examples of how the Out of Box code moves records/related lists like risks and decisions from a demand to a project. So you could copy/add the same approach for your newly created list. 

           

          I did a quick test for a Time Card, and it worked. So you can probably try and test the same approach for your desired related list. The outcome is that when the project gets created from the demand, these related list records are moved from the demand to the new project. Here's what I used to add this logic for Time Cards, or you can look at the OOB examples that begin at line 88:

           

          Move_related_records_to_project.PNG

           

           

          Sean

          Sean Witt
          Engagement Manager
          CareWorks Tech