Voting: 
Vote up!
0 Votes
2 Replies
Answered

kony.contact.add

Question asked by Arjun Sharma on Feb 21, 2017 05:25 EST

I am trying to add a contact using kony.contact.add for the first time but I am getting this error. var ob = {firstname:"John",phone:[{Mobile:["+919999999999"]}],postal:[{Work:[""]}]}; var res = kony.contact.add(ob); Error is: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.lang.String.intern()' on a null object reference, Name : Unknown Error, stack

Kony Answered Certificate
Vote up!
1 votes
Vote down!

Hi Arjun,

Can you please try the below code and check in your application.

var mycontact = { firstname : "John", lastname : "XYZ", phone : [{name:"mobile", number:"9999999999"}, {name:"home", number:"888888888"}], "email" : [{name:"work",id:"Abc@kony.com"}], postal : [{name:"work",street:"ABC",city:"hyderabad",state:"AP",zipcode:"500084"}] }; var arrSting = kony.contact.add(mycontact);

We are suspecting that, in your code you are passing the work with null-value. All the contain details should be in the key:value format and we are expecting value should not be null.

Thanks

Answered by: Feb 23, 2017 02:04 EST
Bronze
Vote up!
0 votes
Vote down!

Worked. Thanks! The issue as I suspect was in the format of my table as I had even tried removing the work part and testing earlier. Even though it was explained in the documentation, I couldn't find any example on actual format. Please see below:

My table:

var myTable = { firstname : "John", phone : [ { Mobile : [ "+919999999999" ] } ] };

Expected:

var myTable = { firstname : "John", phone : [ { name : "mobile", number : "9999999999"} ] };

Replied by: Feb 23, 2017 04:09 EST