Hi,
We have a folder with three categories A, B, C with few Table look up Attributes in them , we need to update category A attribute's value using CWS. we are able to achieve this using the code mentioned below.
However we are facing problem with other categories B and C , its getting corrupted. Attribute Value section is grayed out ,Values are not displaying and Not Editable. [Error screen attached]
Please let me know if needs to be handled in different manner.
Note: We are using CS 10.5
Thanks
//categoryId , node and proCat are input parameter
//GET the category which needs to be updated .
AttributeGroup attrgroup = fDocMan.getCategoryTemplate(categoryId);
String toBeUpdateCatName =attrgroup.getDisplayName();
List <AttributeGroup> nodeattrgroups = new ArrayList<AttributeGroup>();
Node processingNode = node;
Metadata updateMetadata =processingNode.getMetadata();
String currAttributeName ="";
if (updateMetadata!= null ){
nodeattrgroups = updateMetadata.getAttributeGroups();
if (nodeattrgroups.size()>0){
for (AttributeGroup atg:nodeattrgroups){
String currCategoryName =atg.getDisplayName();
if ((currCategoryName.compareToIgnoreCase(toBeUpdateCatName))==0)
{
//Update Existing Category Values
for (DataValue currDataValue:atg.getValues()){
currAttributeName =currDataValue.getDescription();
// Put the currAttribute name in the HashMap to get value
// compare if value is not null and then update Value
for(PAttributes pattr: proCat.getProjectAttributes())
{
if (currAttributeName.compareToIgnoreCase(pattr.getName())==0){
if (currDataValue instanceof StringValue){
StringValue str = (StringValue) currDataValue;
str.getValues().clear();
str.getValues().add(pattr.getVal());
}
}
}
}
}
}
processingNode.setMetadata(updateMetadata);
fDocMan.updateNode(processingNode);
}
}