Jump to content

Set Document Property through JavaScript

Govindaraj Sanjeevi

Recommended Posts

You cannot use the API like you do in IronPython, so instead you need to have an Input Field property control which you update, and that in turn updates the document property value.


See this KB for an example:


How to automatically set a property value to the current date/time with a Text Area JavaScript.



In your text area, wrap your Input Field property control, which is based on the document property you want to update, in a div with id:




Then in your JavaScript you can set the value of that element which will in turn update the document property value:



// Set an Input field value to the current date/time



// Get Input field property control by its ID

var elem = document.getElementById("myInputField");


//Get currentdate

var currentdate = new Date();


//Format time parts to 2 digits

currentHours = currentdate.getHours();

currentHours = ("0" + currentHours).slice(-2);

currentMinutes = currentdate.getMinutes();

currentMinutes = ("0" + currentMinutes).slice(-2);

currentSeconds = currentdate.getSeconds();

currentSeconds = ("0" + currentSeconds).slice(-2);


//Create final date time format

var datetime = (currentdate.getMonth()+1) + "/"

+ currentdate.getDate() + "/"

+ currentdate.getFullYear() + " "

+ currentHours + ":"

+ currentMinutes + ":"

+ currentSeconds;


//Set the element value with the datetime

elem.childNodes[1].value = datetime;

Link to comment
Share on other sites

  • 5 months later...
  • 2 years later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...