Getting “invalid parameter” while setting multilist

My code looks like this(Reading data from excel) :

while (cellIterator.hasNext())
{
Cell cell = cellIterator.next();
if (cell.getColumnIndex()== 0)
{
cellValue = dataFormatter.formatCellValue(cell);
System.out.print(cellValue + “n”);

}
else
{
cellValue2 = dataFormatter.formatCellValue(cell);
System.out.print(cellValue2 + “n”);

}

}
List<Object> myList = new ArrayList<Object>(Arrays.asList(cellValue2.split(“,”)));
System.out.println(myList);
Map params = new HashMap();
params.put(ChangeConstants.ATT_COVER_PAGE_NUMBER, cellValue);
IChange change = (IChange)m_session.getObject(IChange.OBJECT_TYPE, params);
System.out.println(“Change is :”+change.getName());

ICell changecell = change.getCell(ChangeConstants.ATT_PAGE_TWO_MULTILIST01);
IAgileList value = changecell.getAvailableValues();
Object[] objectCommList = myList.toArray();
value.setSelection(objectCommList );
changecell.setValue(value);
System.out.println(“Done”);

Reading attached excel.

Getting below mentioned error. 

Exception in thread “main” Error code : 60018
Error message : Invalid parameter.

at com.agile.api.pc.Session.createError(Session.java:2039)
at com.agile.api.pc.APIObject.createError(APIObject.java:76)
at com.agile.api.pc.CascadeList.setSelection(CascadeList.java:1560)
at com.cisco.Agile.visibility_subho.main(visibility_subho.java:93)

Add Comment
1 Answer(s)

Hi Karan,

I have shared a sample code that i implemented just now, go through it and let me know in case it works.

General flow is :

1. Take the existing value in a string.
2. Concatenate the values you want to append to string.
3. Create an Array List from the string array(obtained after splitting the string based on the regular exp. using to split. )
4. Iterate through the Array List and set the array as selection.

Regards,
Arif

Agile Angel Answered on July 19, 2018.

Hi Arif,
Can you share your code to me also.
I am facing same issue.

my code is :-
Map parms1 = new HashMap();

parms1.clear();
parms1.put(UserConstants.ATT_GENERAL_INFO_USER_ID, “3505”);
IUser user1 =
(IUser)AgileUtility.iAgileSession.getObject(IUser.OBJECT_TYPE, parms1);
IAgileList setlist = null;
//setlist.setSelection(new Object []{“Pranod Kumar Bokil”});

try {

// Get the Subscription table
ITable tblSubscriptions =
user1.getTable(UserConstants.TABLE_ESCALATIONS);
Iterator i = tblSubscriptions.iterator();
// Stop subscribing to part 1000-02
while (i.hasNext()) {
IRow row = (IRow)i.next();
IAgileList clistt=(IAgileList)row.getValue(UserConstants.ATT_ESCALATIONS_NOTIFY_USERS);

System.out.print(“get value “+clistt.toString());
ICell cell = row.getCell(UserConstants.ATT_ESCALATIONS_NOTIFY_USERS);
System.out.print(“get value “+cell.toString());
setlist = cell.getAvailableValues();
System.out.print(“get value “+setlist.toString());
//IAgileList continent = (IAgileList)setlist.getChildNode(“Priyanka Mehta”);
setlist.setSelection(new Object[] {“Priyanka Mehta”});
System.out.print(“get value “+setlist.toString());
cell.setValue(setlist);

}
} catch (APIException ex) {
System.out.println(ex);
}

When it comes to 
setlist.setSelection(new Object[] {“Priyanka Mehta”}); then throw the exception of invalid parameters.

I have read agile doc but all the steps is same in my case.
Can you help me to come out from this issue.

Thanks
Priyanka

on September 12, 2018.

Hi Priya,

You want to replace the existing value or you want to append to it ??

For replacing with a new value use the below code. Modify as per your business requirement:

—–Begin ——-

package arif.practice.examples;
 
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
import com.agile.api.*;
 
/*@author
arifkhan
*/
public class MultilistValue {
 
public static final String url = “http://t-agile-app-aws.jnpr.net:7001/Agile/“;
public static final String pxuser = “admin1”;
public static final String password = “integra”;
public static IAgileSession m_session = null;
public static AgileSessionFactory m_factory = null;
public static String item_Number = “711-060435”;
public static ArrayList<String> itemsList = new ArrayList<String>();
public static long startTime = System.currentTimeMillis();
public static String singleVal=”Security”;
 
/*
 * @author : Arif
 * @Case : Setting a new List value to a multilist
 * Algorithm: 
 *  1. Fetch the Current selected value from UI using ICell method. 
 *  2. Get the list values using IAgileList
 *  3. Set the selection of IAgileList with Preferred value
 *  4. Set the Attribute Cell value with List
 * @param args
 */
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println(“Inside Code. “);
try {
m_session = connectAgile();
System.out.println(“Start time of the code is ” + startTime);
if (m_session != null) {
IItem m_item = (IItem) m_session.getObject(IItem.OBJECT_TYPE, item_Number);
if (m_item != null) {
System.out.println(“Iem is loaded. “);
//Step-1 : I am fetching multilist value of a cell
ICell attributeValue = m_item.getCell(ItemConstants.ATT_PAGE_TWO_MULTILIST11);
System.out.println(“Selected cell value is “+ attributeValue); 
IAgileList agileList = attributeValue.getAvailableValues();
System.out.println(“Selected cell value is “+ agileList);
agileList.setSelection(new Object[] {singleVal});
System.out.println(“The Single Value i want to set is :”+ singleVal);
attributeValue.setValue(agileList);
System.out.println(“The new values set are “+ m_item.getCell(ItemConstants.ATT_PAGE_TWO_MULTILIST11));
 
} else {
System.out.println(“Item doesn’t exists in Agile. “);
}
}
 
else {
System.out.println(“Session couldn’t connect. “);
}
 
} catch (APIException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally {
System.out.println(“In finally method. “);
m_session.close();
System.out.println(“Session is closed. “);
}
 
}
 
private static IAgileSession connectAgile() throws APIException {
// TODO Auto-generated method stub
try {
 
System.out.println(url + ” ” + pxuser + ” ” + password);
m_factory = AgileSessionFactory.refreshInstance(url);
HashMap<Integer, String> params = new HashMap<Integer, String>();
params.put(AgileSessionFactory.USERNAME, pxuser);
params.put(AgileSessionFactory.PASSWORD, password);
m_session = m_factory.createSession(params);
System.out.println(“Session created”);
 
} catch (Exception e) {
// TODO: handle exception
}
return m_session;
}
 
}
on September 14, 2018.

In Groovy, this code will not compile.  How would this be written in Groovy?  It fails on this line:

agileList.setSelection(new Object[] {singleVal});

 

on February 10, 2021.
Add Comment

Your Answer

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