4 Replies Latest reply on May 18, 2016 3:44 PM by Ben-Berkadia

    Move unassigned story to an assignment (for InCopy)

    LeonardoAgosti Level 1

      I want to add a stroy to a new assignment with javascript.

      I found out how to create an assignment, and how to make a icml and icma document

      However it comes in unassigned incopy items, and I can't find a way to place it into my new assignment.

       

      To create an assignment I use:
      var myAssignment = myDoc.assignments.add(...);

       

      And to create an icml file I use:
      myStory.exportFile(ExportFormat.INCOPY_MARKUP, File(myFileIcml));

       

      Both work, but now I need a way to place the icml into myAssignment. How can this be done?

       

      Thanks!

        • 1. Re: Move unassigned story to an assignment (for InCopy)
          Kasyan Servetsky Level 5

          In my opinion this is one of those rare occasions when functionality available in UI is unavailable to script.

          But I think it's possible to workaround this isue like so:

           

          var doc = app.activeDocument;
          if (app.selection.length == 0 || app.selection[0].constructor.name != "TextFrame") exit();
          var textFrame = app.selection[0];
          var assignmentFile = new File("~/Desktop/Test.inca");
          var incopyFile = new File("~/Desktop/Test.incx");
          var assignment = doc.assignments.add("Test", assignmentFile, {name:"Test"});
          var unassignedContent = doc.assignments.item("Unassigned InCopy Content");
          textFrame.texts[0].exportFile(ExportFormat.INCOPY_DOCUMENT, incopyFile);
          unassignedContent.assignedStories[0].move(LocationOptions.AT_END, assignment);
          assignment.update();
          

           

          P.S. I assume that a single text frame is selected

           

          Kasyan

          • 2. Re: Move unassigned story to an assignment (for InCopy)
            S Hopkins Adobe Community Professional

            No more workarounds. The problem with the code in ExtendScript has been solved for InDesign CC (and maybe for CS6). For sample code, see my blog for June 25, 2013: www.yourscriptdoctor.com/blogs.

            • 3. Re: Move unassigned story to an assignment (for InCopy)
              LeoMari Level 2

              @S Hopkins, I'm trying to create a new assignments through your code but is giving error in CS6.

              What am I doing wrong?

               

              var myUserName = "Leonardo";  
              var asgnName = "editoracao";  
              var baseName = "Features_inside";  
              var userColor = InCopyUIColors.GOLD;  
              var storyRef = app.selection[0];//assumes selection is text frame  
              var docRef = app.documents.item(0);  
              var docPath = docRef.filePath.absoluteURI;  
              var storyPath = "/xTransporte/EDITORACAO/Leonardo/rede/ICML"; //docPath + Folder.desktop + "/Users/leonardo.mari/Desktop/InCopy/"; 
              
              
              var asgnPath = docPath + asgnName + ".icma";  
              if (!docRef.assignments.itemByName(asgnName).isValid) {
                  var asgnRef = docRef.assignments.add({name:asgnName, userName:myUserName, frameColor:userColor, exportOption:AssignmentExportOptions.ASSIGNED_SPREADS, 
                  filePath:asgnPath});
              } else {
                  var asgnRef = docRef.assignments.itemByName(asgnName);
              }
              

               

              Thanks for helping.

              Leonardo