ConcourseSuite Support

Support
Corporate
PUBLIC PROFILE

Back to topics

Discuss Development

Java source API examples

You need to be logged in to post messages

Java source API examples

4/6/2011 11:45 AM EDT
Default user photo

By Matt Rajkowski

Concursive Corporation
Product Design

airplane-icon-100x100.png

There are some Java source API examples that I just ran across if you are interested.

In particular there is SaveAsAccount.java which demonstrates retrieving lookup values from the CRM and using them when inserting a new account. There are some important concepts that demonstrate related data and using default values.

http://code.google.com/p/concourseconnect/source/browse/concourseconnect/trunk#trunk%2Fsrc%2Fmain%2Fjava%2Fcom%2Fconcursive%2Fconnect%2Fworkflow%2Fcomponents%2Fcrm

1. 4/15/2011 10:49 AM EDT

Useful Matt, along with

https://www.concursive.com/show/concoursesuite-support/wiki/Add+Contact+%26+related+information

But I'll admit I'm struggling to get any good results. I am actually trying to add an account and a contact for that account, actually, but I've gone back to running your sample code because I couldn't get that working. I've using the latest concoursesuite tools that you updated recently but even running (almost) exactly your sample code:

int clientId = 1;
boolean result;

CRMConnection crm = new CRMConnection();
crm.setUrl("http://man6:8080/crm");
crm.setId("man6");
crm.setCode("testing");
crm.setClientId(clientId);
crm.setAutoCommit(false);

// connection.setAutoCommit(false);

DataRecord contact = new DataRecord();
contact.setName("contact");
contact.setAction(DataRecord.INSERT);
contact.setShareKey(true);
contact.addField("nameFirst", "1st");
contact.addField("nameLast", "last");
contact.addField("company", "test coname");
contact.addField("title", "test title");
contact.addField("source", "test source");
contact.addField("isLead", "true");
contact.addField("accessType", 2);
contact.addField("leadStatus", 1);
contact.addField("enteredBy", 0);
contact.addField("modifiedBy", 0);
crm.save(contact);

// email
DataRecord email = new DataRecord();
email.setName("contactEmailAddress");
email.setAction(DataRecord.INSERT);
email.addField("email", "test@test.com");
email.addField("contactId", "$C");
email.addField("type", 1);
email.addField("enteredBy", 0);
email.addField("modifiedBy", 0);
crm.save(email);

result = crm.commit();
System.out.println(Boolean.toString(result));

I do not get a contact created that can be seen through the front end web application. I can see the record in the database underneath, however. The response I get on System.out.println is:

true <?xml version="1.0" encoding="UTF-8" standalone="no"?><aspcfs><response id="1"><status>0</status><errorText/><recordSet count="1" name="contact"><record action="processed"><nameFirst>1st</nameFirst><nameLast>last</nameLast><company>test coname</company><title>test title</title><source>-1</source><isLead/><accessType>2</accessType><leadStatus>1</leadStatus><enteredBy>0</enteredBy><modifiedBy>0</modifiedBy></record></recordSet></response></aspcfs>
JSESSIONID=99858BD1915563C449493C2A71FA6E22; Path=/crm

Which looks fine to me. I also get this in catalina.out:

[WARN] com.concursive.crm.indexer.LuceneIndexer - Class Not Found Exception. MESSAGE = com.concursive.crm.web.modules.contacts.dao.ContactEmailAddressIndexer
java.lang.ClassNotFoundException: com.concursive.crm.web.modules.contacts.dao.ContactEmailAddressIndexer
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1516)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1361)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:186)
at com.concursive.crm.indexer.LuceneIndexer.getObjectIndexer(Unknown Source)
at com.concursive.crm.indexer.LuceneIndexer.indexAddItem(Unknown Source)
at com.concursive.crm.indexer.LuceneIndexer.indexAddItem(Unknown Source)
at com.concursive.crm.indexer.LuceneIndexer.indexAddItem(Unknown Source)
at com.concursive.crm.indexer.jobs.IndexerJob.execute(Unknown Source)
at org.quartz.core.JobRunShell.run(JobRunShell.java:206)
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:548)

Twice. Irritating that your stack-traces that fill up catalina.out have no timestamps, btw

Is there any documentation on the variations of that "$C" structure, please? I've seen some variants on the forums.

2. 4/25/2011 11:46 AM EDT
Default user photo

By Matt Rajkowski

Concursive Corporation
Product Design

airplane-icon-100x100.png

Tim,

The API response is good... no error. Contact records must have a specific module accessType (Leads, General Contact, Account Contact, Employee)... can you manually enter a Lead into the app and do a DIFF between the API record in the database? It could be a field value that needs to be set on the import.

The indexer warning about ContactEmailAddressIndexer is ok... it's a general warning generated out of the global indexer (used to index any defined types) and the CRM doesn't have one for that object.

3. 4/25/2011 2:37 PM EDT

As you can see from my (your) code we set

contact.addField("accessType", 2);

That record exists and is not disabled in lookup_access_types. I've tried it with 1 as well. Same failure. Finally got your code working by removing the lines

contact.addField("isLead", "true");
contact.addField("leadStatus", 1);

This record now shows up in the Contacts tab in the web page but when you click on it the following error shows in the web page:

java.sql.SQLException: ID not specified for lookup.
at com.concursive.crm.web.modules.contacts.dao.Contact.checkEnabledOwnerAccount(Unknown Source)
at com.concursive.crm.web.modules.contacts.actions.ExternalContacts.executeCommandContactDetails(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
at com.concursive.crm.web.controller.servlets.ControllerServlet.service(Unknown Source)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:857)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Thread.java:636)

Why does this method of data entry not have some kind of validation?

Also is there any documentation on the variations of that "$C" structure, please? I've seen some variants on the forums.

4. 5/20/2011 9:57 AM EDT

Bump?

4 results found