Skip to Content
author's profile photo Former Member
Former Member

Remove a Custom Property

Hi all,

I created a custom property via KM API. I need to delete it from a specific resource.

When I try to delete it via IResource.deleteProperty() method, I get an exception (PropertyMandatoryException).

I think the exception is caused by the PropertyDef flag: isRequired = true.

I didn't find any method to modify an existing propertyDef associated to the my Property instance in order to turn isRequired flag false.

Any idea to solve this problem?

Thanks

Marco

Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • author's profile photo Former Member
    Former Member
    Posted on Jan 12, 2004 at 05:25 PM

    Hi Marco,

    please try the following:

    create a new property with the name of the custom property and property def isRequired = false:

    PropertyName name = ...

    Property oldProp = resource.getProperty(name);

    PropertyDef oldDef = oldProp.getPropertyDef();

    PropertyDef def = new PropertyDef(oldDef.getType(), oldDef.isMultivalued(), false, ....);

    Property prop = new Property(name, def, oldProp.getValue());

    set this property to the resource in question

    resource.setProperty(prop);

    and afterwards delete the property from the resource

    resource.deleteProperty(name);

    If this may not work you have to delete the entire resource an create a new one except this property.

    Regards, Klaus

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.