cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with adding allowed values to the property

former_member188498
Active Participant
0 Kudos

Hello,

I have a problem with adding allowed values to the property from code.

The problem is that the values are being added (they can

be seen for example on the miscellaneous tab of the

details of a text file), but they are not visible in

properties (Global services...PropertyStructures etc).

Regards,

Ladislav

PS. Below is the code which I use.

  public void AddValueToAllowedList( java.lang.String propValue )
  {
    //@@begin AddPropertyToAllowedList()

    try
    {
    	IPropertyConfigurationService propConfigService =
          (IPropertyConfigurationService) ResourceFactory.getInstance().getServiceFactory().
               getService("PropertyConfigurationService");

			
	IMetaModel metaModel = propConfigService.getMetaModel();
	
        // property namespace	
	String namespace = wdContext.currentPropertiesElement().getPropertyNamespace();
        // property name
	String name = wdContext.currentPropertiesElement().getPropertyName();
		
	IPropertyName propertyName = new PropertyName(namespace, name);
		
	IMetaName metaName = metaModel.searchByPropertyName(propertyName);

        // new value
	IMetaValue metaValue = metaModel.createMetaValue(metaModel, metaName, 
		new DefaultMetadataExtension(metaModel), propValue);
		
	IMetaValueListIterator iterator = metaName.allowedValueIterator();
        // add to the end of the list
	while (iterator.hasNext()) 
	{
	     IMetaValue m = iterator.next();
	}
		
	iterator.add( metaValue );
    }
    catch (ResourceException e) 
    {
		
    }
    catch (PropertyConfigurationServiceException e)
    {
		
    }
    
    //@@end
  }

Accepted Solutions (0)

Answers (1)

Answers (1)

former_member188498
Active Participant
0 Kudos

Solved long ago, just closing this thread

iker_espinosa
Participant
0 Kudos

Hello,

I am writing to you because I have just read these 2 threads in SDN from you:

https://www.sdn.sap.com/irj/scn/thread?threadID=196580&tstart=255&messageID=6074857

https://www.sdn.sap.com/irj/scn/thread?threadID=198035&tstart=-1

I am a Portal developer and I have two problems:

1.- I have a problem with adding allowed values to the property from code.

The problem is that the values are being added (they can be seen for example on the miscellaneous tab of the details of a text file), but they are not visible in properties (Global services...PropertyStructures etc).

2.- When we deploy a PAR, we can add values that are not visible in properties (problem 1) but the application recognizes them and the values are added correctly. But if we redeply the PAR, all de values added previously disappear.

As I have read, you two have solved the problems, haven´t you? How can I solve them?

Regards,

Iker Espinosa