70000525 We would like to be able to add Xproperties using the vdWeb library

Article 70000525
Type Wish
Product WebJS
Date Added 8/11/2015 12:00:00 AM
Fixed 7.7006.0.1 (8/20/2015 12:00:00 AM)
Submitted by Iland Sandor

Summary

We would like to be able to add Xproperties using the vdWeb library.

Solution

In version 7006.0.1 two new functions were added in web library, AddXProperty() and GetXProperty().

AddXProperty(object entity, string name, object propValue)

Adds a new XProperty to the passed entity.

The function takes the following parameters
  • entity: The entity to add the new XProperty. It should be a valid vdraw object added in the document.
  • name: A string representing the name of the XProperty.
  • propValue: The value of the XProperty. Valid values for this are of Boolean, Number or String type. Also one lever arrays(not arrays withing arrays) of these types.

GetXProperty(object entity, string name)

Returns the first XProperty by the given name to be found in the passed entity. Null if none is found.

The function takes the following parameters
  • entity: The entity from which the XProperty is to be taken.
  • name: The name of the XProperty to be found.

Example

Add this function to the vddblclick event and double click on an entity.
function _vddblclick(e) {
    var entity = e.target.GetEntityFromPoint(e.xPix, e.yPix);
    if (entity != null && entity._t != undefined) {
        if (entity.XProperties && entity.XProperties.Items.length > 0){
            var prop = e.target.GetXProperty(entity, "testProp");
            alert("Got " + prop.PropValue.toString());
        }
        else{
            var prop = e.target.AddXProperty(entity, "testProp", ["1", "2", "3"]);
            alert("Stored " + prop.PropValue.toString());
        }

    }
}

Send comments on this topic.