Add field Last released version

Hi, 

I want to show the last Revision Released in the document form .

I added a text field in the form and a methode on the event onformPopulated of the form .

The code of this method is actualy :

    if (propName == "last_major_rev_released") {
        elements[i].value ="The last rev. released"

     //code to get the last revision released
  }

So the text The last rev. released is showed in the field.

Can you help me to write  the code (javascript) to get the last revision released ?

Top Replies

Parents
  • Hi Jeromecha

    You can use below javascript method to achieve this

    var configId = document.thisItem.getProperty("config_id");
    var releasedItem = new Item('Document', 'get');
    releasedItem.setAttribute('select', 'major_rev');
    releasedItem.setProperty('config_id', configId);
    releasedItem.setProperty('is_released', '1');
    releasedItem.setProperty('is_current', '1');
    releasedItem = releasedItem.apply();
    if(releasedItem.isError())
    {
    return;
    }
    var allElement = document.getElementsByTagName("input");
    for (var i=0; i<allElement.length; i++)
    {
    var property = allElement[i].name;
    if (property == "last_major_rev_released")
    {
    allElement[i].value = releasedItem.getProperty('major_rev');
    }
    }

    Thank You

    Gopikrishnan R

  • Hi 

    Thanks for your reply.

    Your code doesn't answer exactly my question by was very helpfull.

    The JS code to show the last major revision released is : 

    var releasedItem = new Item('Document', 'get');
    releasedItem.setAttribute('select', 'major_rev');
    //aras.AlertSuccess (document.thisItem.getProperty("item_number"));
    releasedItem.setProperty("item_number", document.thisItem.getProperty("item_number"));

    releasedItem.setProperty("generation", "*");
    releasedItem.setPropertyCondition("generation", "like");
    releasedItem.setAttribute("orderBy", "generation desc");


    releasedItem.setProperty('is_released', '1');

    releasedItem = releasedItem.apply();
    //aras.AlertSuccess("nb" + releasedItem.getItemCount());
    last_rev="";
    if (releasedItem.getItemCount() > 0) {
    item =releasedItem.getItemByIndex(0);
    last_rev = item.getProperty("major_rev");
    }
    else {
    last_rev="";
    }

  • Glad to hear that my answer provided some inputs to you. 

Reply Children
No Data