Skip to Content
author's profile photo
Former Member

KM API: Object for property shortID returns NULL

Hello,

I try to readout properties of a KM object via KM API. It works fine

for System properties like 'created by' or 'modified' but it does not

work for the Access Links property Short ID (Screenshot). For this

property it is always returned NULL.

Coding:

PropertyName pn = new PropertyName

("http://sapportals.com/xmlns/cm/rendering", "shortID");

IProperty property = kmObject.getProperty(pn);

response.write(property.getStringValue());

Best regards,

Markus

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

2 Answers

  • Best Answer
    author's profile photo
    Former Member
    Posted on Aug 10, 2007 at 01:35 PM

    Hi Markus,

    If I understand correctly, this "kmObject" is an IResource, and calling getProperty(pn) returns null. There are two possible reasons for this:

    1) There is a typo in the property namespace or name

    2) The queried property does not exist at the resource

    Assuming that 1) is not the case you should check if the property exists at the resource or not:

    - You could try checking the properties using the brilliant RFExplorer tool: https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/75336f09-0801-0010-4ea6-90ca92e98b28

    - You could write code to print all properties that are present at your resource. For this get all Properties from the resource using kmObject.getProperties:

    IPropertyMap map = kmObject.getProperties();
    IPropertyIterator iterator = map.iterator();
    while (iterator.hasNext()) {
       IProperty nextProp = iterator.next();
       response.write(nextProp.getPropertyName().toString() + ": " + nextProp.getValueAsString() + "<br />");
    }
    

    If you indeed find that the property does not exist at the resource check the property definition in the KM Configuration to see if maybe there are validity patterns or resource type restrictions set which prevent it from getting added to your resource.

    I hope this helps,

    Esther

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Hi Andrei,

      thank you very much, IUriMapperService solved the problem.

      For all others who are watching this thread, I've used the following code:

      IUriMapperService mapperService = (IUriMapperService) ResourceFactory.getInstance().getServiceFactory().getService(IUriMapperService.SERVICE_ID);

      response.write(mapperService.getCreateConstantID(rid));

      Best regards,

      Markus

  • author's profile photo
    Former Member
    Posted on Aug 09, 2007 at 03:00 PM

    Please refer KM library I posted in wiki,

    https://www.sdn.sap.com/irj/sdn/wiki?path=/display/Snippets/KMLibrary-ReusableComponentforWebDynpro+Java&

    Regards,

    Nitin

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi Nitin,

      I had a look at your post in wiki, but I can't identify the problem in my coding. It works for some properties but not for shortID.

      Regards,

      Markus