ALMOST there and but a little help please.

It's almost perfect.  A few things.  When I save the file it keeps putting the information on the other rather that rewrite.  Which means that if I save at 03:00 and then save again to 301 will keep both and simply place them on another.  How can I keep only the last.  A few other things that you will see when I post the Script.

app.addEventListener( "beforeSave" , doTextFrameOnPageOne );  
   
    function doTextFrameOnPageOne()  
    
 {  
    var columnOneContentsArray = [  
      
         "Document:" ,  
         "User Name:", 
         "Computer Name:",
         "Date Modified:",      
         "Date Output:",
         "Date Created:",
         "Output Date:"  
    ];  
      
    var columnTwoContentsArray = [ 
      
 /*        
         "",
         "",
         ""
*/
    ]; 
    
    var myBlendingSettings = { blendMode : BlendMode.OVERLAY };  
    var myTransparencySettings = { blendingSettings : myBlendingSettings };  
    var doc = app.activeDocument;   
    var tf = doc.textFrames.add({geometricBounds: ['-.75','-4.45in','.75in','-.75in'] });  
    var myTable = tf.texts[0].tables.add  
        (  
        
         {   
             // Number of Rows and Columns.
              bodyRowCount : 6 ,   
              columnCount : 2   
                
             // Use other property/value pairs to define the width of the table, stroke weights, fill color etc.pp.  
        
         }  
    ); 
    
    var R1, R2, R3, R4, R5, R6, ip; 
        ip = tf.insertionPoints;
        myTable.columns[0].contents = columnOneContentsArray;  
        myTable.columns[1].contents = columnTwoContentsArray;  
    var cell0OfColumn2insertionPoint1 = myTable.columns[1].cells[0].insertionPoints[0]; 
    var R1 = cell0OfColumn2insertionPoint1.textVariableInstances.add(LocationOptions.AFTER, cell0OfColumn2insertionPoint1);      
        R1.associatedTextVariable = doc.textVariables.itemByName("File Name"); 
        
//-----------------> CANNOT GET THESE TO RUN R2, R3 <--------------------\\    
   
    var cell1OfColumn2insertionPoint1 = myTable.columns[1].cells[1].insertionPoints[0];
    var R2 = cell1OfColumn2insertionPoint1.textVariableInstances.add(LocationOptions.AFTER, cell1OfColumn2insertionPoint1);      
        R2.associatedTextVariable = doc.textVariables.itemByName("userName"); // Cannot find a text variable for User name.  
    var cell0OfColumn2insertionPoint1 = myTable.columns[1].cells[2].insertionPoints[0];    
    var R3 = cell2OfColumn2insertionPoint1.textVariableInstances.add(LocationOptions.AFTER, cell2OfColumn2insertionPoint1);      
        R3.associatedTextVariable = doc.textVariables.itemByName("Login User Name"); // Same as User name.
        
//------------------------------------------------------------------------------------\\    

    var cell3OfColumn2insertionPoint1 = myTable.columns[1].cells[3].insertionPoints[0];  
    var R4 = cell3OfColumn2insertionPoint1.textVariableInstances.add(LocationOptions.AFTER, cell3OfColumn2insertionPoint1);      
        R4.associatedTextVariable = doc.textVariables.itemByName("Modification Date"); 
    var cell5OfColumn2insertionPoint1 = myTable.columns[1].cells[4].insertionPoints[0]; 
    var R5 = cell5OfColumn2insertionPoint1.textVariableInstances.add(LocationOptions.AFTER, cell5OfColumn2insertionPoint1);      
        R5.associatedTextVariable = doc.textVariables.itemByName("Output Date");  // How can i make this show the date string?  Like The Modification Date!
    var cell6OfColumn2insertionPoint1 = myTable.columns[1].cells[5].insertionPoints[0];
    var R6 = cell6OfColumn2insertionPoint1.textVariableInstances.add(LocationOptions.AFTER, cell6OfColumn2insertionPoint1);      
        R6.associatedTextVariable = doc.textVariables.itemByName("Creation Date");   

    }

I know the user name isn't the right one for the variable username of connection, but I can't find the name of the Variable... Here's how I've done it before if I could add lower to meanings that would be great. or if I see any variables somewhere made me know thank you.

var myBlendingSettings = { blendMode : BlendMode.OVERLAY };  
    var myTransparencySettings = { blendingSettings : myBlendingSettings };   
    var doc, tf, tvINFO, ip;  
        doc = app.activeDocument;  
// TEXT FRAME PROPERTIES
                
        tf = doc.pages[0].textFrames.add({ fillColor :"Yellow", fillTint: 20, transparencySettings : myTransparencySettings, geometricBounds: ['-.75','-4.45in','1.5in','-.75in'] });

// Text frame information
        ip = tf.insertionPoints;
        ip[-1].contents = "Document:"+"\t "+ doc.name  +'\r'; 
        ip[-1].contents = "User Name:" +"\t"+ getAppUserName() +'\r';
        ip[-1].contents = "Computer Name:" +"\t"+ getLogInUserName()+'\r';
        tvINFO = ip[-1].textVariableInstances.add(LocationOptions.AFTER, ip[-1]);  
        "Date Modified:" +'\t'; tvINFO.associatedTextVariable = doc.textVariables.itemByName("Modification Date");  
        ip[-1].contents = '\r';
        tvINFO = ip[-1].textVariableInstances.add(LocationOptions.AFTER, ip[-1]);  
        tvINFO.associatedTextVariable = doc.textVariables.itemByName("Output Date");  
        ip[-1].contents = '\r';  
        tvINFO = ip[-1].textVariableInstances.add(LocationOptions.AFTER, ip[-1]);  
        tvINFO.associatedTextVariable = "Date Created:" +'\t'; doc.textVariables.itemByName("Creation Date");  
        tf.texts[0].convertToTable();

    }  
      
    function getLogInUserName()  
 {  
//  Computer User Name
     var userNameOSX = $.getenv("USER");  
     var userNameWindows = $.getenv("USERNAME");  
      
        if(userNameWindows == null){return userNameOSX}  
        else{return userNameWindows};  
      
    }  
      
    function getAppUserName()  
 {  
        return app.userName;  
    }

Thank you again...

Hi ceveque,

It seems that your question is not yet resolved and time consuming...

I looked at your code and made changes. I think I've addressed your questions. See the comments.

Comments

1. now the code addresses the issue of multiple blocks of text being created with SaveInfo details.

2. the text with details SaveInfo actually block now will be added in the layer named SaveInfo. I think that it was not reached in your code.

3. you can now approach any number of documents. I managed it in the eventlistener to capture the target document. It's simple.

4 naming the textframe issue is also fixed. Simple approach. You can check the code.

Let me know if all is well.

#targetengine "AutoStartScript"  

app.addEventListener( "beforeSave" , doTextFrameOnPageOne );      

function addLayer(doc, name) {
try{
        var layer = doc.layers.itemByName(name);
        if(layer && layer.isValid) {
                 return layer;
            } else {
        var myLayer = doc.layers.add();
        myLayer.name = name;
            return myLayer;
    }
    } catch(e) {
        }
}

function addTextFrame(doc, layer, name) {
    var myBlendingSettings = { blendMode : BlendMode.OVERLAY };
    var myTransparencySettings = { blendingSettings : myBlendingSettings };   

    var tf = doc.textFrames.itemByName(name);
    if(tf && tf.isValid) {
        tf.remove();
    }
    tf = doc.textFrames.add(layer, LocationOptions.UNKNOWN, {name: name, fillColor :"Yellow", fillTint: 20, transparencySettings : myTransparencySettings, geometricBounds: ['-.75in','-4.45in','1.0in','-.75in'] });
          return tf;
}

function addTable(tf) {
    var myTable = tf.texts[0].tables.add
        (
           {
             // Number of Rows and Columns.
              bodyRowCount : 6 ,
              columnCount : 2       

             // Use other property/value pairs to define the width of the table, stroke weights, fill color etc.pp.
         }
    );     

return myTable;
    }

function addVariable(doc, name, value) {
    var v = doc.textVariables.itemByName(name);
    if(v && v.isValid)
        return;

    v = doc.textVariables.add({name:name, variableType:VariableTypes.CUSTOM_TEXT_TYPE});
    v.variableOptions.contents =  value;
}

function doTextFrameOnPageOne(event)
 {
    var doc = event.target;
    if(!(doc && doc.constructor.name == "Document")) {
        return;
    }

    // Create New Layer
    var myLayer = addLayer(doc, "SaveInfo");

    var columnOneContentsArray = [
         "Document:" ,
         "User Name:",
         "Computer Name:",
         "Date Modified:",
         "Date Output:",
         "Date Created:",
         "Output Date:"
    ];      

    var columnTwoContentsArray = [
 /*
         "",
         "",
         ""
*/
    ];   

     var tf = addTextFrame(doc, myLayer, "SaveInfo");
     var myTable = addTable(tf);

      // Create New Text Variables
      addVariable(doc, "Users Name", getAppUserName());
      addVariable(doc, "CLN", getLogInUserName());

    // Placing information in tables
    var R1, R2, R3, R4, R5, R6;     

        myTable.columns[0].contents = columnOneContentsArray;
        myTable.columns[1].contents = columnTwoContentsArray;
    var cell0OfColumn2insertionPoint1 = myTable.columns[1].cells[0].insertionPoints[0];
    var R1 = cell0OfColumn2insertionPoint1.textVariableInstances.add(LocationOptions.AFTER, cell0OfColumn2insertionPoint1);
        R1.associatedTextVariable = doc.textVariables.itemByName("File Name");
    var cell1OfColumn2insertionPoint1 = myTable.columns[1].cells[1].insertionPoints[0];
    var R2 = cell1OfColumn2insertionPoint1.textVariableInstances.add(LocationOptions.AFTER, cell1OfColumn2insertionPoint1);
        R2.associatedTextVariable = doc.textVariables.itemByName("Users Name")
    var cell2OfColumn2insertionPoint1 = myTable.columns[1].cells[2].insertionPoints[0];
    var R3 = cell2OfColumn2insertionPoint1.textVariableInstances.add(LocationOptions.AFTER, cell2OfColumn2insertionPoint1);
        R3.associatedTextVariable = doc.textVariables.itemByName("CLN");
    var cell3OfColumn2insertionPoint1 = myTable.columns[1].cells[3].insertionPoints[0];
    var R4 = cell3OfColumn2insertionPoint1.textVariableInstances.add(LocationOptions.AFTER, cell3OfColumn2insertionPoint1);
        R4.associatedTextVariable = doc.textVariables.itemByName("Modification Date");
    var cell4OfColumn2insertionPoint1 = myTable.columns[1].cells[4].insertionPoints[0];
    var R5 = cell4OfColumn2insertionPoint1.textVariableInstances.add(LocationOptions.AFTER, cell4OfColumn2insertionPoint1);
        R5.associatedTextVariable = doc.textVariables.itemByName("Output Date");  // How can i make this show the date string?  Like The Modification Date!
    var cell5OfColumn2insertionPoint1 = myTable.columns[1].cells[5].insertionPoints[0];
    var R6 = cell5OfColumn2insertionPoint1.textVariableInstances.add(LocationOptions.AFTER, cell5OfColumn2insertionPoint1);
        R6.associatedTextVariable = doc.textVariables.itemByName("Creation Date");
    }      

//  Computer User Name
    function getLogInUserName()
 {      

     var userNameOSX = $.getenv("USER");
     var userNameWindows = $.getenv("USERNAME");      

        if(userNameWindows == null){return userNameOSX}
        else{return userNameWindows};      

    }
 // Application Name
    function getAppUserName() {
        return app.userName;
}

Tags: InDesign

Similar Questions

  • I tried to erase and reset my iphone 6 s. But why is it taking so long? For more than 24 hours. Is this normal? The phone displays just the apple logo and wont open. Help, please. Thank you in advance.

    I tried to erase and reset my iphone 6 s. But why is it taking so long? For more than 24 hours. Is this normal? The phone displays just the apple logo and wont open. Help, please. Thank you in advance.

    Hello

    Follow the instructions here:

    If you are unable to update or restore your iPhone, iPad or iPod touch - Apple supports

  • install windows xp pro-1pk-sp3 cd. But there is no sound. Help, please.

    I installed windows xp pro, but when I got to run that there was no noise. Help, please.

    More that likely you need to install a driver for
    your sound card:

    See the following links:

    (307918) how to troubleshoot sound problems in Windows XP
    http://support.Microsoft.com/kb/307918/en-GB

    No sound in Windows
    http://Windows.Microsoft.com/en-us/Windows/help/no-sound-in-Windows
    (Win XP / Vista / 7)

  • Firefox suddenly stopped from asking me if I want my user name and saved passwords. Help, please!

    Firefox suddenly stopped from asking me if I want my user name and saved passwords. Help, please!

    Make sure that you are not Firefox running in permanent private browsing mode.

    To view the history settings and cookies, choose:

    • Tools > Options > privacy, choose the setting Firefox will: use the custom settings for the story of
    • Uncheck the box: [] "always use the navigation mode private.
  • to refine my question. The Lasso tool does not work.  When I select the content aware lasso shrinks and nothing changes.  Help please.

    to refine my question. The Lasso tool does not work.  When I select the content aware lasso shrinks and nothing changes.  Help please.

    A simple reset will often be the case if a tool becomes awkward. Go to this link, then select the lasso tool:

    Difficulty of tool

  • Hi, I have cs6. I bought a picture on adobe stock to use in a design. I don't know how to remove it from my library and use effectively? Help please

    Hi, I have cs6. I bought a picture on adobe stock to use in a design. I don't know how to remove it from my library and use effectively? Help please

    Go to stock.adobe.com and log in with the user ID Adobe that you purchased the image.

    Click on the Images link at the top right of the page to go to your history of license

    Click on the thumbnail of the image of the image you want to use to access the page of image details

    In the center of the details page, you will see a big blue to choose link where you want to save the image to

  • I posted a question can not find the question and or response. Help, please

    I posted a question can not find the question and or response. Help, please

    AFAIK, you can't share a catalog like this.

    The only recommended method is to store your images and catalogue on an external drive, you can alternatively plug in both computers.

    With today the external USB drives, the speed is still correct, and many users are satisfied with this solution.

  • I have many PDF files on my PC which one cannot remove, it becomes very messy and very annoying. Help, please?

    I have many PDF files on my PC which one cannot remove, it becomes very messy and very annoying. Help, please?

    In Windows Explorer click the icon "show preview pane" on the right side of the toolbar. Whenever a PDF file is opened in the preview pane, Windows treats as "in use" and will not allow that it be modified or deleted.

  • New computer with Win 7 and I'm drowned in ads, pop ups and constant redirects. Help, please!

    I just got a new computer with Windows 7, and I had nothing else that problems with redirections constants, pop up windows, ads pasted on top of advertising.  It's really driving me crazy.  Any time I click on what (in Facebook, or my website, or Twitter or whatever it is!) I am redirected to a new tab with an advertisement trying to make me spend it, or download that.

    When I'm on Facebook, I brilliantly flashing ads covering my groups and pages.  When I opened my site, I have flashing ads to the bottom of the left and the right of my blog and all my pages.

    I tried everything I know to stop this, and nothing works.  I ran Malwarebytes, and they found pieces of adware 2029!  I quarantined and deleted and ran two additional scans that came clean, but ads and redirects are always there, drive me to madness.

    Then someone please help me, I can't use this computer as it is, it takes twice as much time to my work, and that rebounds, flashing ads are too distracting for me to even write in my blog.

    Help, please

    Check out this free removal guide: http://malwaretips.com/blogs/remove-adware-popup-ads/

  • Windows 8 and first 11?  Help, please

    Hello

    I'm on windows 8 (64-bit) and PE11.  Today, I lost all my work, even though I had saved regularly and I have to redo the rendering very often.  Tonight because I'm redoing my work day, I lose sync and keep clips integers disappear.  It seems to be becoming more and more unstable.  I don't really know if I'm doing something wrong or, possibly, Windows 8 and 11 elements first are not the best fit.  I noticed a few other post mentioning window 8 problems even if they seem to be different from mine.

    The head of it at my company wants to remove windows 8 and install windows 7 on my computer (especially because of a VPN issue), but I fear that I will lose all my work.

    Can anyone suggest a way, or a number to call and tell me how I can save my work, get rid of windows 8 and then re-import my work in a Windows 7?  I fear only 2 weeks of my work is going up in smoke.

    PS I posted earlier, I am also having more frequent crashes.

    Help, please

    Thank you

    1. I would advise to do a full backup of the system before your machine for installation of the OS. I use Macrium Reflect product. There is a paid version I have, but there is also a free version.
    2. Note the path to your project's resources and the .prel file.
    3. Make sure that all the assets of the project (pictures, videos, sounds) and the project .prel file are saved on another disc or flash drive. Disable PRE11 on your computer before handing over the installation of W7.
    4. After the installation of W7 copy these assets of the project and the .prel file in the same folder on the hard drive of machines (2) above.
    5. Install PRE11 and activate it.
    6. Open the project file.

    See you soon,.
    --
    Neale
    Insanity is hereditary, get you your children

  • Simple but important question, help please!

    Hello

    Recently, I went to Windows and was looking for a similar to Garageband software.

    Adobe Audition, I found and I am ready to buy it, but I was wondering something...


    I used to plug my guitar on garageband and use the pre-installed guitar effects they had there and have little my laptop as an amp + effects.

    Is this possible using Adobe Audition? Can you just plug in your guitar and jam with the help of distorting and the sound comes out of your speakers?

    Thank you in advance!

    Yes, for tracking you can, but you can not save the results unless you loop the signal of monitor in a spare of entry (if you have a)-simply because it's a bad business.

    All you need to do is select hearing Mix in MV, and everything that you put in the channel strip you will get out of the system of monitoring as long as the output of the channel is fed directly to it. You can choose where the channel is fed in by clicking on the output in the channel indicator, or LHS of the track itself.

  • Cannot open videos from youtube and other sites. Help, please

    I cant buffering or see any video content on the Web like you tube. tube you it just says: an error has occurred and refreshing didn't work. in other sites the large sign for the video showed not just upward. its just empty. Help, please. I am trying to install adobe flash video and still does not

    Hello

    I noticed that you use Firefox (released almost two years 17 July 2012) 14. Why are you on this bass a version, even the 28 version is more up-to-date than that. You should check update to update to the latest version of Firefox.

    Flash is even enabled?

  • Hi, new to the ambient light.  A little help please...

    Hi, new to the ambient light.  I downloaded the software and photos imported into the library.  I then went to develop and the captain is displayed in the browser screen, but does not appear in the work screen.  The screen of work remains a solid blue.  Any help please?

    You will need to open Lightroom preferences, go to the performance tab and uncheck the GPU.

  • Problem of connector 4-pin Corsair 600 CX-600 PS and P7-1137. Help, please!

    The forum recommended that I get a block of power supply Corsair CX - 500 or CX-600 ay P7 - 1137c PC (to upgrade the video card).

    I got a Corsair CX-600, but I noticed he didn't have a 4 pin power to connect a connector with 4 pins on the motherboard (labeled ATX CPU).

    What should I do? Y at - it an adapter that I'm supposed to do?  Help, please!

    I assume you found that the connector is a 4 + 4 split

    1 x main connector (20 + 4 pins)
    1 x 4 +4-pin ATX 12V
    1 x EPS 12V
    2 x PCI-E
    6 x SATA
    4 x peripheral
    1 x floppy

  • use restart from scratch using the option "ALT F10" and lose everything. Help, please!

    Whenever I try to connect my laptop, a screen invites me to do a repair of launch set-up. It goes through the motions for ten minutes and the screen turns white. The only way I can get at all is to restart all from scratch using the option "ALT F10" and lose everything. Any advice I would really appreciate.

    Hello

    1. Since when are you facing this problem?
    2. You did any recent changes?
    3. What version of Windows is installed on the computer?

    I suggest that you go into recovery options and try to perform system restore and see if it helps:
    http://Windows.Microsoft.com/en-us/Windows7/what-are-the-system-recovery-options-in-Windows-7
    http://Windows.Microsoft.com/en-us/Windows-Vista/what-are-the-system-recovery-options-in-Windows-Vista

    Otherwise, I suggest you to give us more information, so that we can better help you.

    It will be useful.

Maybe you are looking for

  • Cancle my purchase

    I can't update my apps on the app store because he wants the audit. When I check my account using my phone number, he said the purchase of my latest product has not been successful because of my low balance, but did not buy anythin. Now I suppose to

  • Satellite has been close but lights LEDs

    I remove the power jack on my laptop but its power light is still on can you please tell me why is it so? A few times it recharges the battery sometimes it isn't. Please help me

  • session active ftp for bluetooth problem

    Hello I recently bought a Moto X 1 st Gen and so far everything has been great, but I noticed recently that I can't receive files via bluetooth. I can connect and pair my device and I can send files to my computer but I can't receive files. Whenever

  • Crash when you press the [...]

    I got various random crashes when you press the button [...] in the various 9.0.1, CVI function panels but I have not found a model so far. 1. open Control Panel function for SetCtrlAttribute2. for "Attribute of control", press the button [...] and s

  • How to change from black and white to color

    I forgot how to go back to color printing. When I go into the Advanced preferences I don't know what to click. That's what I should do or there at - there a simpler way?