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

Custom properties in KM

Hi!

I created a few custom properties in KM but now when I want to set values in the properties using the following code, I always get an error:

IPropertyName propertyName = new PropertyName("namespace", "property");

IProperty property = resource.getProperty(propertyName);

IMutableProperty mutableProperty = property.getMutable();

mutableProperty.setStringValue("08/15");

Although the property exists I get a NullPointerException after the getProperty-method. I found out when I change the property manually, after that the setStringValue works.

Do I have to initialize the custom property somehow? If yes, how can I do that programatically?

Thanks in advance.

Timo

Add a comment
10|10000 characters needed characters exceeded

Related questions

3 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Oct 18, 2005 at 04:33 AM

    Hi,

    could you post your new coding?

    Regards,

    Achim

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Oct 17, 2005 at 11:49 AM

    Hi,

    if your coding is as you described

    if (property == null) {

    resource.setProperty(IProperty property)

    }

    then property is null and you call

    resource.setProperty(null)

    Can you probably post the complete property setting.

    Regards,

    Achim

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Hi Achim,

      yeah, there was a syntax error in my coding a posted. You're right, it should be.

      resource.setProperty(propertysalesorg);

      Well, but it still doesn't work. I also get a NullPointerException using setProperty() :O(

      Bye,

      Timo

  • author's profile photo Former Member
    Former Member
    Posted on Oct 17, 2005 at 11:41 AM

    Hi,

    have you already set a property with that name at the resource using

    resource.setProperty(IProperty property)?

    You can also fetch all properties

    resource.getProperties() and check if the property is really available at the resource.

    Regards,

    Achim

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi Achim,

      what I already tried is, after calling the getProperty-method:

      if (property == null) {

      resource.setProperty(IProperty property)

      }

      I also get a NullPointerException for the setProperty-method then.

      Bye,

      Timo

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.