Page 1 of 1
setting properties null exception
PostPosted:Tue Aug 05, 2014 6:38 pm
by monisha3107
I am having problems using set properties for a particular document using the OpenKM web service.
So when I do webservice.setPropeties(path, groupname, PropertiesMap)
I get the exception "object reference not set to an instance of an object" although the PropertiesMap (an OKMFormElementBean[] object) is not null.
Really appreciate any help I can get. Kinda stuck on this from weeks.
Thanks
Re: setting properties null exception
PostPosted:Wed Aug 06, 2014 5:59 pm
by jllort
You're using c# no ? can you paste here some code ( sample ) to see what and how are you trying ?
Re: setting properties null exception
PostPosted:Thu Aug 07, 2014 12:56 am
by monisha3107
Yes c#. Pasted below.
Code: Select allOKMWebservice ws = OKMWebServiceFactory.getInstance(host, username, password, OKMWebServiceFactory.PROFESSIONAL_6_4_9);
String uuid = ws.getNodeUuid(defaultdirectory + filename);
String path = ws.getNodePath(uuid);
String grpname = refname;
Dictionary<String,String> metadata = new Dictionary<String,String>();
OKMFormElementBean[] propertiesMap = ws.getProperties(path, grpname);
String[] lines = System.IO.File.ReadAllLines( "metadata.txt");
foreach (String line in lines)
{
string[] parts = line.Split(',');
metadata.Add(parts[0],parts[parts.Length-1]);
}
for(int i =0; i < propertiesMap.Length; i++)
{
String type = propertiesMap[i].getType();
switch (type)
{
case "text":
propertiesMap[i].setValue(metadata[propertiesMap[i].getName()]);
break;
case "multiple":
OKMOptionBean[] option = propertiesMap[i].getOptions();
String[] multiple = metadata[propertiesMap[i].getName()].Split(' ');
for (int j = 0; j < multiple.Length; j++)
{
if (values.ContainsKey(multiple[j]))
{
option[j].setLabel(multiple[j]);
option[j].setValue(values[multiple[j]]);
}
}
propertiesMap[i].setOptions(option);
break;
}
}
ws.addGroup(path, grpname);
ws.setProperties(path, grpname, propertiesMap); --------------------------> here's where I get the exception
}
Re: setting properties null exception
PostPosted:Fri Aug 08, 2014 8:01 am
by jllort
What openkm version are you using ? 6.4.X trial version, professional version or community version ?
I suggest use setPropertiesSimple
Code: Select allvoid setPropertiesSimple(String nodePath, String grpName, Dictionary<String, String> propertiesMap);
void setPropertiesSimple(String token, String nodePath, String grpName, Dictionary<String, String> propertiesMap);
You'll get less problems with it
Re: setting properties null exception
PostPosted:Fri Aug 08, 2014 4:40 pm
by monisha3107
I am using OpenKM 6.4 professional
I did use setPropertiesSimple and it works only for "TEXT" field. If I have a control of type "Select" (listbox or combobox - where i can select multiple or single values) , it doesn't work with setPropertiesSimple.
Do you know how I can handle that?
Re: setting properties null exception
PostPosted:Sat Aug 09, 2014 10:14 am
by jllort
If you are OpenKM customer you must do this kind of questions from OpenKM customer website. I've send you a private message.
In case multiple, you must pass values separated by ";". I revised the source code and I think could be a bug when you're doing the call from soap and rest services. Seems was wrong in soap and when we had done with rest we propagated the bug also. Anyway contact us as a customer in our support customer website.