GetProperty on the form Javascript/html

How can i get a property in an item type to be displayed on a form using html tag

  • Hello,

    There's a couple different ways to go about this, but please note that it's recommended that you use one of the standard field types for displaying property data instead of an HTML field. If you choose to use an HTML field, you will need to write functionality to both retrieve and display the property data as well as handle the change to the item if the user edits the value. Using a standard field type like a Text field will automatically handle both of those things.

    With that being said, the first thing that you need to do is define an HTML element to hold the value of your property. For simplicity, let's make this a simple span element. Note that we need some way to retrieve this element later, so we can actually write our property data. Most commonly, this will be done with an id attribute like the element below.

    <span id="my_property_holder"/>

    Once we have an element that can display our data, we now need to retrieve the data and write it to this element. We have two main ways of doing this: inline in the HTML of the field or through a Form Event like onLoad or onFormPopulated. Regardless of where we write our JavaScript, it will look mostly the same. We can retrieve the property data by getting it from the parent document, and then we can then write that data to our span element by setting the innerText like the code sample below.

    // document.thisItem stores the item that's loaded into the form
    var myProp = document.thisItem.getProperty("myProp", "");
    document.getElementById("my_property_holder").innerText = myProp;

    Once we load our form, we'll see that the span element we've added is holding the value of myProp


    Christopher Gillis

    Aras Labs Software Engineer

  • thanks Chris,

    We are trying to build a printable form that's why we need HTML properties, hence is it possible if we can also get the relationship to a particular item type using JavaScript?

Reply Children
No Data