Skip to main content
SumitKumar
Inspiring
August 23, 2017
Answered

K4 assign articles

  • August 23, 2017
  • 2 replies
  • 1322 views

Hi All,

I want to assign articles to multiple files, I am able to do it, but not able to change user color to yellow. I am not able to find Hereproperties for color information.

Here is my code.

  1. myFolder = Folder.selectDialog ("Select folder with indd..."); 
  2. if(myFolder != null){ 
  3.   batch_process (myFolder); 
  4. function batch_process (theFolder) { 
  5.   var myFileList = theFolder.getFiles(); 
  6.   for(var i=0; i<myFileList.length; i++){ 
  7.   var myFile = myFileList
  8.   if(myFile instanceof File && myFile.name.match(/\.indd$/i)){ 
  9.   try
  10.   var doc = app.open (myFile, true); 
  11.   }catch (e) { 
  12.   alert("Please open in upper version..."); 
  13.   exit(); 
  14.   } 
  15.   //insert function here 
  16.   add_article (doc); 
  17.   try
  18.   doc.close(SaveOptions.YES); 
  19.   }catch (e) { 
  20.   alert("InDesign file is converted..."); 
  21.   exit(); 
  22.   } 
  23.   }else if(myFile instanceof Folder){ 
  24.   batch_process (myFile); 
  25.   } 
  26.   } 
  27.  
  28. function add_article (myDocument) { 
  29.   var myArticleName = myDocument.name.slice(0, -5); 
  30.   if(myDocument.k4Articles.length == 0){ 
  31.   var myArticle = myDocument.k4Articles.add({k4Name: myArticleName, articleColor: UIColors.YELLOW}); 
  32. //~ myArticle.label = UIColors.YELLOW; 
  33.   }else
  34.   alert("Already, articles created in this document..."); 
  35.   exit(0); 
  36.   } 
  37.   for(i=0; i<myDocument.stories.length; i++){ 
  38.   myArticle.k4AttachObjectInDocument(myDocument.stories); 
  39.  
  40.   } 

Could anyone help me?

Sumit

This topic has been closed for replies.
Correct answer Loic.Aigon

According to K4 documentation, there is no articleColor property. So you attempt may just fall into water.

Class: K4Article | K4 InDesign Javascript API Documentation

However, setting a non defined property normally ends with an execution error inside InDesign, I am presuming K4 plugin catches it before InDesign gets concerned.

2 replies

praveenkumare90474043
Participant
June 7, 2019

Hi All,

     var myArticle = myDocument.k4Articles.add({k4Name: myArticleName, articleColor: UIColors.YELLOW}); 

      How to create article only for "All Text Objects".

Regards,

Praveen

SumitKumar
Inspiring
August 20, 2019

Hi Praveen,

You can use "doc.stories.everyItem()".

Thanks,

Sumit

-Sumit
Participant
January 16, 2020

Hi all,

 

Can you anyone please help how to assign layout output channel name to article output channel, 

function startArticleWorkflow(pub) {

    
    var myWFChannel = null;
    for(i = 0i < pub.k4Workflows.length++i) {
        for(j = 0j < pub.k4Workflows[i].k4WorkflowChannels.length++j) {
            var wfChan = pub.k4Workflows[i].k4WorkflowChannels[j];
            for(k = 0k < wfChan.k4FileExtensions.length++k) {
                if(wfChan.k4FileExtensions[k== "icml") {
                    myWFChannel = wfChan;
                    break;
                }
            }
            if(myWFChannel != null)
            break;
        }
        if(myWFChannel != null)
        break;
     }
    
    var doc = app.documents[0];
if(myWFChannel != null) {   
        forvar i = 0i < doc.k4Articles.lengthi++ ) {
            //Define article
            var article = doc.k4Articles[i];
            
            //Start workflow object for article
            var myStartWFObject = myWFChannel.k4GetStartWfObjectForObject(article);
                 
            //Get the layout issue and assign the article to the same issue
            var docIssue = doc.k4GetServerData().k4IssueId;
            myStartWFObject.k4IssueId = docIssue;

            //Get the layout section and assign the article to the same section
            var docSection = doc.k4GetServerData().k4SectionId;
            myStartWFObject.k4SectionId = docSection;
            
            

            //Set Article name from function parameter
            myStartWFObject.k4Name = article.k4Name;
            //myStartWFObject.k4VersionNote = "Auto-start Article Workflow from InDesign Script";
            
            //Begin workflow
            myStartWFObject.k4BeginStartWorkflow();
            myStartWFObject.k4EndStartWorkflow(); // Done
 
Thanks
Naveen
Loic.Aigon
Loic.AigonCorrect answer
Legend
August 30, 2017

According to K4 documentation, there is no articleColor property. So you attempt may just fall into water.

Class: K4Article | K4 InDesign Javascript API Documentation

However, setting a non defined property normally ends with an execution error inside InDesign, I am presuming K4 plugin catches it before InDesign gets concerned.

SumitKumar
Inspiring
August 30, 2017

Thanks Loic.

-Sumit