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
REIFREIF 

Brand new to custom work, need big push in the right direction

Hoping I can get some guidance on a scenario.  Current company web site has a catalog of items (not a store front or shopping application).  I have created a custom object in SalesForce that echos the fields that are displayed on the site and obviously in the database.  I want to have an action button on the web page that when clicked, will add an object instance to Salesforce. 

 

For example, lets say the custom object is named Widget.  I want to create a new widget instance from the web site and hence database in Salesforce.  I need to put some code in the web site to do this, and I am at a total loss wher to begin.  I am hoping someone might help me with some code snippets that I can extend to cover all the fields.

 

Okay, object is widget and let's assume widget has a custom field called name.  Given that, what are the steps and code example that would:

 

  1. Set up for initiating the API to start a session.
  2. Logon
  3. Query widget to see if the name field is already in existence.
  4. If not, create the new widget instance.  create() I guess or ???
  5. Update the field name.
  6. Commit all the field updates, as in Post or something similar.
  7. Validate the create was successful.
  8. Logoff
  9. End the session

Quickly trying for cookbook hints, browsing AJAX documentation, etc. exposed a number of things that raised questions to me:  .net, php, java, .....  Is this going to be all over the place depending on how the existing web site is constructed?

 

Forewarned that I am a bit of a hack, at best, in this world, although a former developer but not a contemporary one, so what may be completely obvious to you is probably a fog for me.

 

Thanks in advance, and if snippets are not your thing per se perhaps pointing me to the right KB or documenation would help.  So far, the documentation I have whacked at has done me little good.

 

And maybe someone could explain why the simple code in web->lead isn't available for other objects?  It would make such sense.

vhanson222vhanson222

You should look in to salesforce sites.

 

at a high level, here is what you have to do:

 

Create a visualforce page with a custom controller for you widget object.  Make sure the Custom controller has 'without sharing' specified .  The custom controller is what will handle the querying of the database for existing records and creating a new record if one does not already exist.

 

Create a 'Site' by going to Setup | Develop | Sites

 

Use your custom visualforce page (that uses your custom controller) as the main page on your 'site'.

 

if you want, you can send me a private message and i'll work with you to get some code hashed out.

 

Victor