Update multiple values from one P2 Multilist field to another multilist field

Hi,

I am trying to update the values of one multilist field to another Multilist field. But it says, can’t update the values.

If I update only single value, it works. However, it replaces the existing value with the new one.

Suggestions would be appreciated.

Thanks!

Agile User Asked on September 17, 2019 in Software Development Kit (API).
Add Comment
2 Answer(s)

Hi Nagma,

Can you elaborate more on the error.  Also as it’s a multi-list value generally appending the value is the right way to go.  Sharing a general flow of how i did earlier.

 

//you want to set/append the multiVal LOV to a multi-list attribute PAGE_TWO.MULTILIST11

public static String multiVal = “Services;Switching;CORP”;

//You can specify your source attribute.

String attributeValue = m_item.getValue(ItemConstants.ATT_PAGE_TWO_MULTILIST11).toString();

//append the desired value to existing value.

String newAttr = attributeValue.concat(“;”).concat(multiVal);

String[] strArr = newAttr.split(“;”);
ArrayList<String> list = new ArrayList<>(Arrays.asList(strArr));
System.out.println(“List: ” + list);

//You can give the desired cell where you want to set the value
ICell m_cell = m_item.getCell(ItemConstants.ATT_PAGE_TWO_MULTILIST11);
appendValuesToMultiListCell(m_cell, list);

 

—-Your append to Multilist method looks something like this

public static void appendValuesToMultiListCell(ICell cell, ArrayList<String> valuesList) {
try {
System.out.println(“List value is “+ valuesList);
System.out.println(“Inside Set Multilist value”);
if (null != valuesList && !valuesList.isEmpty()) {
int valuesListSize = valuesList.size();

String[] attributeValueArray = new String[valuesListSize];
for (int i = 0; i < valuesListSize; i++) {
attributeValueArray[i] = valuesList.get(i);
System.out.println(“Value List is ” + valuesList.get(i));
}
// Set the final list of values
IAgileList agileList = cell.getAvailableValues();
agileList.setSelection(attributeValueArray);
cell.setValue(agileList);
}
System.out.println(“Updated Values are :” + cell.toString());
} catch (Exception e) {
e.printStackTrace();
}

}

 

Regards,

Arif

Agile Angel Answered on September 17, 2019.
Add Comment

Hi Arif,

 

Thank You so much!!! It worked. I was missing to concat them this way.

 

Regards,

Nagma

Agile User Answered on September 18, 2019.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.