Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

K4 assign articles

Engaged ,
Aug 23, 2017 Aug 23, 2017

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.

Screen Shot 2017-08-12 at 2.11.44 PM.png

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

-Sumit
TOPICS
Scripting
1.2K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

People's Champ , Aug 29, 2017 Aug 29, 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.

Translate
People's Champ ,
Aug 29, 2017 Aug 29, 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Aug 30, 2017 Aug 30, 2017

Thanks Loic.

-Sumit
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jun 07, 2019 Jun 07, 2019

Hi All,

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

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

Regards,

Praveen

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Aug 20, 2019 Aug 20, 2019

Hi Praveen,

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

Thanks,

Sumit

-Sumit
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 15, 2020 Jan 15, 2020
LATEST

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
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines