+ Start a Discussion
solsol 

How to add a custom field to standard objects with app exchange

I have an application which requires some custom fields to be there
for the standard objects like Lead,Campaign.
 
So is there any way like, while i package my application i can create some custom fields
so that they get attached to the user environment once they install it.
 
 
adamgadamg
Its not possible to package customizations on standard objects today.
successmansuccessman

Its true you cannot add the field to the app.  However we have included a space for a customization guide on your application listing on the AppExhange web site. (just below the data sheet)

This has been an effective way to communicate additional customizations required and instructions to do so.

Ron HessRon Hess
While Adam is correct, the next best thing is to have/run AJAX code on your About tab which checks for the presence or absence of these fields, and guilds the admin user thru the proper actions to create the fields, and indicate to them when the steps are completed, slick trick if i do say so myself.

This is an entire about tab, with code that checks for one field, and prompts the user to create it, after which it reports that the step is completed.  To try it , create an scontrol, drop in the code, create a webtab which references this scontrol and click on the webtab. Please excuse the poor choice of colors, i'm not really color blind, but you can't tell from this sample.

share and enjoy

Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="https://www.salesforce.com/services/lib/ajax/beta3.3/sforceclient.js" type="text/javascript">
</script>

<title>Service Agreements Splash Page</title>

<!--  Do not edit this section below -->
<style type="text/css" media="all">
.errorStyle, .errorMsg, .importantWarning {
   font-weight: bold;
   color: #C00;
}
.existsMsg, .okMsg {
   font-weight: bold;
   color: #339966;
   background: #ffccff;
}
body#splashBody {
  font-family: arial, helvetica, verdana, sans-serif;
  font-size: 80%;
  margin: 0;
  padding: 0;
  width: 97%;
}
img {
  border: 0;
  margin: 0;
  padding: 0;
}
p {
  margin: 0;
  padding: 0;
}
h1.appName {
  font-weight: bold;
  font-size: 100%;
  color: #FFF;
  background-color: #638658;
  padding: 10px 0 10px 8px;
  margin: 0 0 15px 0;
}
h2 {
  color: #FFF;
  padding: 2px 0 2px 8px;
  margin-top: 0;
  background-color: #638658;
  font-size: 90%;
}
h2.exchangeTitle {
  background-color: #999;
}
#splash {
  margin: 0;
  padding: 0;
  width: 100%;
}
#splash td {
  margin: 0;
  padding: 0;
}
#splash #splashLeft {
  vertical-align: top;
  background-color: #F3F3EC;
  border-bottom: 2px solid #638658;
}
#splash #splashCenter {
  display:block;
  width: 15px;
  background-color: #FFF;
}
#splash #splashRight {
  vertical-align: top;
  background-color: #E8E8E8;
  border-bottom: 2px solid #999;
}
#splash #splashLeft .about, #splash #splashLeft .exchange {
  width: 100%;
}
#splash #splashRight .exchange p {
  font-size: 90%;
  color: #333;
  margin: 0 10px 12px 10px;
  line-height: 1.4em;
}
#splash #splashLeft .about p {
  font-size: 90%;
  color: #333;
  margin: 0 10px 12px 15px;
  line-height: 1.4em;
}
#splash #splashLeft .about fieldset {
  color: #333;
  margin: 0 15px 10px 15px;
  padding: 2px;
}
#splash #splashLeft .about fieldset ul {
  padding: 0;
  margin: .3em 0 .3em 2em;
}
#splash #splashLeft .about fieldset li {
  padding: 0;
  margin: 0;
}
#splash #splashLeft .about legend {
  font-size: 90%;
  color: #333;
  font-weight: bold;
}
.imgDiv {
  text-align: center;
  padding: 0 0 10px 0; 
}

</style>
<!--  Do not edit this section above -->

<script type="text/javascript" language="javascript">
function initPage() {
 sforceClient.init("{!API_Session_ID}", "{!API_Partner_Server_URL_70}");
 var uInfo = sforceClient.GetUserInfo(); 
 if ( uInfo && uInfo.faultcode && uInfo.faultcode.indexOf("API_DISABLED_FOR_ORG")>0) {
  alert( uInfo.faultstring +
   "\nThis custom link utilizes the AppExchange API.\n" +
   "It appears that the Salesforce.com edition you are using does not have this feature enabled."
  );
  return; 
 }
 
 // fill in the table of required fields, check them each
 document.getElementById('Entitled_Close_Date').innerHTML = fieldExistsHTML('Case','Entitled_Close_Date');
}

/* called to see if a field exists in the table */
function fieldExists(table,name) {
 name = name.toLowerCase();
 if( ! /__c/.test(name) ) { name += '__c';}
 var def = sforceClient.DescribeSObject(table); // first see if field exists
 var ret =  def.fieldMap.containsItem(name);
 return ( ret );
}
function fieldExistsHTML(table,name) {
 if ( fieldExists(table,name) ) 
  return "<span class=okMsg>field exists, step completed</b>";
 return "<span class=errorMsg >field not found, please create</span>";
}
</script>
</head>

<body id="splashBody" class="setup  detailPage" onload="initPage();">
<h1 class="appName">Service Agreements from Salesforce.com</h1>
<table id="splash" cellspacing="0"> 
<tr>
<td id="splashLeft" width="100%">
<div class="about">
<h2>About Service Agreements</h2>
<p>
Users can create and track service level agreements 
Link from Case tab
</p>
<p>
<b>Note:</b>
To configure this application feature you will need to perform the following modifications 
to the Case object within your org using the features found in the Setup - App Setup area. 
Please read and follow the instructions outlined below, you may select different 
field labels, however the field names that you enter 
must match those provided below.
In each case a check is performed on this page to indicate if the field is correctly installed.
<p>Simply refresh this page to identify any outstanding issues as you proceed with the modifications.

</p>
<p>
</p>
<fieldset>
<legend>Install and Configuration</legend>
<ol>

<!-- include specific Help and/or Support contact information below -->

<li>Modify the <b>Case</b> page layouts to include the <b>Locate Entitlement </b> 
custom link provided with this AppExchange package</li>


<li>in the Setup area, under App Setup, click the following Customize, Case, Fields<br> 
 Click New to add an <a target="_blank" href="/setup/ui/layoutfieldlist.jsp—type=Case&setupid=CaseFields">
 Case Custom Field</a>
 <ol type=a>
   <li>Create a field of type : <b>Formula</b>
   <li>label : Entitled Close Date </li>
    <li>name : <b>Entitled_Close_Date</b>   
     <br>Field Status:  <span id=Entitled_Close_Date></span> </li>
    <li><i>add this field to case page layouts</i></li> 
 </ol> 
</li>

</ol>
</fieldset>
</div>
</td>

<td><div id="splashCenter">&nbsp;</div></td>

</tr>
</table>

</body>
</html>

 




adamgadamg
Thats a nice hack Ron!
Ron HessRon Hess
Yes, however i forgot to the caution:
 Don't employ this trick unless you can expect your customers to have API Access enabled, Enterprise or Unlimited Edition, or Professional Edition with API add-on.

So, if your app requires API, then this is handy, otherwise it may generate an error message...
SergioARGSergioARG
Hi,
I would like to know if we can do it now (10.0) ? And how to do it?
(want to add a field at Case)

Regards