function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
dandantedandante 

being able to use new custom fields immediately

Hi,

I am building a Java salesforce app for a client. It is designed in such a way that the client can create their own forms, hosted at their own server, and then submit them to my app (which will be hosted elsewhere on their own server).

All the app does is create leads based on form input, it looks at the form items and figures out which fields to populate in the Lead object. So you could have a hundred different forms, all asking for different sets of fields, and the app would figure out how to save the leads. This part is not yet implemented but may use reflection.

We have told the client that it would be no problem for them to create custom fields, but now that I see how this is done, it does pose a problem. They can't just create a custom field and then include it in a form. These manual steps have to take place first:

-They notify me that they have created a new custom field
- I download the wsdl and run Wsdl2Java
- I don't have to change any of my own code because it is smart enough
  to generate method calls by itself based on form item names.
- I recompile the app code, package it into a WAR,
- and redeploy that WAR on the remote server.

This is not really an acceptable solution. I'd like to give them an app that will just work. It looks like in the Ruby API, you can just pass a hash to the create statement, making all of the above steps unnecessary. Is there anything similar in the Java API?

Hope someone can help.
Thanks.

DevAngelDevAngel
You really should take a look at the Partner API.  It was specifically desinged for this type of use case (one where the schema may change or be unknown at development time).  You will basically have the describeSObject call that returns the possible fields on an object (lead) and these are up to date (real time).  Your query will return sobjects with key/value pairs instead of getters and setters for specific lead fields.

When you create an sobject for update or create, you also specify key/value pairs in lieu of getters and setters.

Check out the sample code for the java partner samples.

http://www.sforce.com/us/downloads/PartnerSamples7.0.zip

dandantedandante
Thanks. My client already has an Enterprise account. Do they need a different type of account in order for the app to work with the Partner API?

DevAngelDevAngel
No, please visit the documentation page.