• gokubi
  • NEWBIE
  • 55 Points
  • Member since 2005

  • Chatter
    Feed
  • 1
    Best Answers
  • 4
    Likes Received
  • 0
    Likes Given
  • 45
    Questions
  • 69
    Replies
Has anyone needed to convert a string variable to integer? I need to code a verification digit function, and I am getting the digits from a string with the substring function. Next to that, I need to convert each 'text' number to integer for multiplication.
 
Here is a sample of what I need...
 
Code:
public static boolean CUITVerification(String cuit)
{
       if(cuit.length() != 11)
          return false;
       
       String xx1 = cuit.substring(1,1);
       Integer x1 = xx1;
       x1 = x1 * 5;

       if(x1 == 10)
          return true;

}

 to anyone who can help me...thanks
I want to create a global action that is a way for staff to Chatter a simple weekly update about what they've been working on and what they're going to work on next week. Basically, all I want is to have a chatter publisher window prefilled with some template text:

What did you do?


What are you going to do?
*

If I do a global action, I can create a VF form and generate a Chatter post with the update text, but I lose the abilty to create @mentions, which are really helpful in updates.

The simplest thing would be to generate a standard chatter publisher and prefill it with text, then let the user start modifying. I don't think there is any way to do that on the platform. I suspect the best thing I could do is create a Google Chrome extension that allows the user to prefill the publisher, but that's less than ideal.

Any suggestions for how I might give the user some text in the publisher so they're not starting from scratch and don't lose all the good stuff of the standard Chatter publisher?

I have a component I use on a VF page in a Site with a prefix--http://mysite.force.com/events. I create a relative link to a VF page that is part of the site like this:

 

 

<a href="Event?id={!event.Id}">{!event.Name}</a>

 

 

The link the component creates drops the prefix, however, and looks like this: http://mysite.force.com/Event?id=00dhwhegdhewy

 

What's the best way to preserve the site prefix in this case without hard-coding it into the component?

 

Thanks,

Steve

I posted a short movie of Campaign Membership calculations I'm running and rolling up to the Contact record. The movie shows how I modeled this to support community organizing by environmental groups:

My post

I would love this to be Apex, but I can't trigger on CampaignMember, so I wrote an S-Control that the user has to click when they want to recalc camapaign memberships for all Contacts. In the comments of my post, Tom Tobin had the idea of firing a trigger on a change to the Campaign's NumberOfResponses field.

However, it appears that changes to this rollup field are not considered database updates--my trigger isn't firing. Is that correct? Is there any way to fire a trigger based on a change to Campaign Membership? Any novel ideas out there?

Thanks,
Steve
  • November 29, 2007
  • Like
  • 0
I am a heavy Eclipse for Apex user, but didn't use Eclipse before I started working with Salesforce.com code.

Can I turn on autocomplete for common Apex structures? I'm finding I wish I had autocomplete and I want to make sure I'm not just missing some setting somewhere in Eclipse.

Thanks,
Steve
  • November 29, 2007
  • Like
  • 0
I'm working on converting a lot of S-Control functionality to Apex. We're trying to keep triggers as simple as possible and move logic to classes to facilitate code reuse.

There seem to be two ways to reference code in classes. One is to instantiate the object and then use it:

        DefaultAccount defAccount = new DefaultAccount();
        Id DefaultAccountId = defAccount.getDefaultAccountId();

The other is to make the methods Static and call them without instantiating the object:

        list<Account> AcctsToUpdate = MembershipRollup.RollupToAccounts (AcctsToProcess, mbrRTids);

By using Static, do we risk problems if two processes access that class at the same time? My understanding of Static is that multiple use of those resources will share the same memory location, which would be bad. Is that the case, and should we go to instantiating the objects?

Or is it just a preference issue and either way will provide similar results?

Thanks,
Steve
  • October 30, 2007
  • Like
  • 0
I have successfully deployed Apex code from a Dev instance to a production instance. I noticed that when I go to the classes and triggers in the admin interface of my production instance, there are no delete buttons, and I can't deactivate the trigger.

Let's say that I don't want the Apex in my instance any more. If I wanted to "undeploy" this code, that is remove it or inactivate the triggers, what's the best way to do that?

In the deploy wizard in Eclipse, my triggers and classes are recognized, but I can't take any action with ones that are currently already deployed since I haven't changed the files. I see the triggers and classes in Eclipse of my production org, and there is a delete option in the context menu, but I'm afraid to attempt that for screwing things up royally.

Any guidance on undeploying would be appreciated.

Thanks!

Steve
  • October 21, 2007
  • Like
  • 0
To write nice UI in S-Controls, we've all gotten good at faking UI elements like object lookup fields, date pickers, etc. In summer '07 there is a new date picker, as well as field hover flyouts, field help text, and more.

I'm starting the process of reverse engineering how to do these in my S-Controls. It sure would be a boon if an SF.com employee would write up a couple examples of how to fake these things. It would save us all a ton of time!

I'm looing at the new datepicker right now and I'm getting there, and will post when I figure it out, but it would be eaiser if we all didn't have to reinvent the wheel.

Thanks as always,
Steve
  • August 12, 2007
  • Like
  • 0
I was thwarted at the check-in counter by Alaska Airlines in my attempt to go to the developer conference yesterday. I'm bummed I missed it. Were any of these questions answered?

* When will Apex be availabe in General release?
* Will it have additional cost or will it be included in specific editions of Salesforce.com?
* Will there be an SOA preview program? How would one get in on that?

Thanks!

Steve
I can get an array of all fields on an object, but I cannot see the Id of each field. Why would I want the Id of a field? The create/edit forms in the sf.com web interface use these field Ids to pass data on the querystring to custom fields. To see this in action, go to a custom object you have and click new from any of the related lists. On the querystring you'll see lots of Id gibberish. It's that gibberish that sets the custom object reference on the edit page that pops up.

Without access to the field Id from a describe call, I have to manually discover and hardcode the Ids of fields that I want to prepopulate automatically in this way.

Give me the Id in the fields array in the describeSObjects call and I wouldn't have to hard code those custom field Ids.

Thanks!
Steve
I wrote up a simple technique for getting Apex code to fire daily without user intervention and without any code outside Salesforce.

Enjoy!

Steve
  • April 18, 2007
  • Like
  • 0
I love Eclipse. I use it on multiple machines and connect to 16 different instances of sf.com. I use it for S-Controls and Apex code development. Thanks so much for this tool, it is an incredible time saver.

About a week ago, I got an error when synching my s-control folder on one instance. Since then, I have been unable to connect to that instance. Of the 16 instances I connect to, this is the only one on na4. Looks like it is timing out:

Here is the error I get in Eclipse 3.2.2 with the latest Apex add on:

Failed to send request to https://na4-api.salesforce.com/services/Soap/u/8.0
  com.appexchange.plugin.wizards.ConnectionPage.applySettings (ConnectionPage.java 191)
  com.appexchange.plugin.wizards.AppExchangeProjectWizard.performFinish (AppExchangeProjectWizard.java 60)
  org.eclipse.jface.wizard.WizardDialog.finishPressed (WizardDialog.java 680)
  org.eclipse.jface.wizard.WizardDialog.buttonPressed (WizardDialog.java 355)
  org.eclipse.jface.dialogs.Dialog$3.widgetSelected (Dialog.java 660)
  org.eclipse.swt.widgets.TypedListener.handleEvent (TypedListener.java 90)
  org.eclipse.swt.widgets.EventTable.sendEvent (EventTable.java 66)
  org.eclipse.swt.widgets.Widget.sendEvent (Widget.java 928)
  org.eclipse.swt.widgets.Display.runDeferredEvents (Display.java 3348)
  org.eclipse.swt.widgets.Display.readAndDispatch (Display.java 2968)
  org.eclipse.jface.window.Window.runEventLoop (Window.java 820)
  org.eclipse.jface.window.Window.open (Window.java 796)
  org.eclipse.ui.actions.NewProjectAction.run (NewProjectAction.java 116)
  org.eclipse.jface.action.Action.runWithEvent (Action.java 499)
  org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection (ActionContributionItem.java 539)
  org.eclipse.jface.action.ActionContributionItem.access$2 (ActionContributionItem.java 488)
  org.eclipse.jface.action.ActionContributionItem$5.handleEvent (ActionContributionItem.java 400)
  org.eclipse.swt.widgets.EventTable.sendEvent (EventTable.java 66)
  org.eclipse.swt.widgets.Widget.sendEvent (Widget.java 928)
  org.eclipse.swt.widgets.Display.runDeferredEvents (Display.java 3348)
  org.eclipse.swt.widgets.Display.readAndDispatch (Display.java 2968)
  org.eclipse.ui.internal.Workbench.runEventLoop (Workbench.java 1930)
  org.eclipse.ui.internal.Workbench.runUI (Workbench.java 1894)
  org.eclipse.ui.internal.Workbench.createAndRunWorkbench (Workbench.java 422)
  org.eclipse.ui.PlatformUI.createAndRunWorkbench (PlatformUI.java 149)
  org.eclipse.ui.internal.ide.IDEApplication.run (IDEApplication.java 95)
  org.eclipse.core.internal.runtime.PlatformActivator$1.run (PlatformActivator.java 78)
  org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication (EclipseAppLauncher.java 92)
  org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start (EclipseAppLauncher.java 68)
  org.eclipse.core.runtime.adaptor.EclipseStarter.run (EclipseStarter.java 400)
  org.eclipse.core.runtime.adaptor.EclipseStarter.run (EclipseStarter.java 177)
  sun.reflect.NativeMethodAccessorImpl.invoke0 (null -2)
  sun.reflect.NativeMethodAccessorImpl.invoke (null -1)
  sun.reflect.DelegatingMethodAccessorImpl.invoke (null -1)
  java.lang.reflect.Method.invoke (null -1)
  org.eclipse.core.launcher.Main.invokeFramework (Main.java 336)
  org.eclipse.core.launcher.Main.basicRun (Main.java 280)
  org.eclipse.core.launcher.Main.run (Main.java 977)
  org.eclipse.core.launcher.Main.main (Main.java 952)

Anything up with na4? This happens to be the instance of my employer, so I'd love some help troubleshooting so I can get working on our code again!

Thanks again for the great tool and any help you could provide tracking this error down.

Steve
  • April 11, 2007
  • Like
  • 0
Before a Contact is created I want to see if it has been related to an existing Custom Object called "ONEN_Household__C". If it hasn't, I want to create that Custom Object, then get the id of the new object, creating the Contact with that reference recorded.

Here's what I've got so far:
Code:
trigger HouseholdCheck on Contact bulk (before insert) {
         
  for (Contact c : Trigger.new) {
    if (c.ONEN_Household__c == NULL) {
      c.Description='No Household';
      insert new ONEN_Household__c (Name=c.firstname + ' ' + c.lastname + ' Household');
    }
  }
}
After I do the insert new ONEN_Household__C, how do I get that new object's Id?

Thanks!

Steve
 

  • March 29, 2007
  • Like
  • 0
Winter '07 added some validation on the upload of Appexchange packages that affected some of my code. Any S-Controls that had explicit references to Record Type Ids wouldn't load to the Appexchange. I would often write code like this:

var PurchaseRecordTypeId = "0000000000fff55";

When I needed this code in another instance, I would Appexchange it, install it, and then change the hard-coded reference.

Here's more elegant code that gets Record Type Ids dynamically, and doesn't trip the Appexchange validator:
var oOppRecordTypes = getRecrodTypesforObjects("Opportunity");

var DonationLabel = "Gift";
var MembershipLabel = "Membership";
var DonationRecordType = oOppRecordTypes[DonationLabel].Id;
var MembershipRecordType = oOppRecordTypes[MembershipLabel].Id;

function getRecrodTypesforObjects(ObjectName) {
 var RecordTypesArray = new Array();
 sfc = sforce.connection;

 var result = sfc.query("Select r.Id, r.Name, r.SobjectType from
 RecordType r where r.IsActive=true and r.SobjectType='"+ ObjectName +"'");

 var RecordTypesArray = result.getArray("records");
 oRecordTypes = new Object();
 for (var i=0;i<RecordTypesArray.length;i++) {
  var oSingleRecordType = new Object();
  oSingleRecordType.Name=RecordTypesArray[i].Name;
  oSingleRecordType.Id=RecordTypesArray[i].Id;
  oRecordTypes[RecordTypesArray[i].Name]=oSingleRecordType;
 }
 return oRecordTypes;
}

 I'd love to hear feedback if you have suggestions on how this code could do the job better.

Enjoy!

  • March 13, 2007
  • Like
  • 0
I've got working code to give me all Opp stagenames. I would like to narrow that list to values appropriate to one record type. I wasn't able to find a path to that in the documentation about the describeSObjects call.

Here's the working code:

Code:
function generateStageNamePicklist(picklistid) {
 var objects = sforce.connection.describeSObjects(["Opportunity"]);
 var OppObject = objects[0];
 var OppSourcePicklistValues = new Array();
   
 for (var i=0; i<OppObject.fields.length; i++) {
  if(OppObject.fields[i].name=="StageName") {
   var StageNameField = OppObject.fields[i];
   StageNameFieldPicklistValues = StageNameField.picklistValues;
  }
 }
 SelectBox = "<select id='" + picklistid + "'>";
 for (var currentStageName=0;currentStageName<StageNameFieldPicklistValues.length;currentStageName++) {
  SelectBox +="<option value="+ StageNameFieldPicklistValues[currentStageName].value +">" + StageNameFieldPicklistValues[currentStageName].value + "</option>";
 }
 SelectBox +="</select>";
 return SelectBox;
}

 Thanks in advance for any help!

Steve

  • March 05, 2007
  • Like
  • 0
I have some reports and S-Controls that reference record types on standard objects. In the past these have been appexchangeable. With Winter 07 I am now getting errors:

This item depends on another item that is not included in this package. Record Type: Gift

or just:

This item depends on another item that is not included in this package.

In the past, my code wasn't inspected for references to record types, nor were my reports. I used to appexchange them and then fix the references in the new org.

Does anyone know if more integrity checking has been added and if there is a way around this limitation? Can I now not appexchange anything that references a record type on a standard object?

Thanks,
Steve
  • January 24, 2007
  • Like
  • 0
I have code that looks at the members of a campaign and then modifies their memberstatus based on some criteria. Before Winter 07 I could use an arbitrary memberstatus. I discovered that in Winter 07, I have to use a memberstatus that is already assigned to the Campaign. Can an sf.com dev confirm this is a change?

I've fixed the problem by moving my code to the AJAX 8.0 toolkit, and first check for the campaignmemberstatus, creating it on the campaign as necessary.

Thanks,
Steve
  • January 18, 2007
  • Like
  • 0
I'm trying to convert an array of Leads and refresh the browser after each Lead is converted. I've got it all working except for the refresh--currently the browser doesn't refresh until after all the leads have been converted. Here's what I've got.

Code:
function createLeadToConvert(LeadArray,startRow) {
  var row = startRow;
  if (row<LeadArray.length){
    ThisLeadId = LeadArray[row];
    //lots of conversion code here
 //here I change a part of the page
document.getElementById("Row" + leadId + "Lead").innerHTML = "Converted"; //increment the row I'm looking at
startRow++;
//make the recursive call, hitting the next row of the LeadArray
 setTimeout(createLeadToConvert(LeadArray,startRow),50); } }
The setTimeout call isn't quoted, so I know that it will fire without the 50 milisecond pause. But I can't seem to pass the LeadArray in when it's quoted. I can pass the startRow, because it's just a number, but I'm unsuccessful at passing the array.

Any thoughts on how I could get the page to refresh after processing each row?

Thanks!
 

  • November 13, 2006
  • Like
  • 0
Hey Dave, Ron, Adam and all the sf.com folks who read this board.

I love the AJAX tookit! It has put incredible control over the sf.com UI in my hands. I'm creating custom code that users have no idea isn't standard sf.com functionality. I get to chain together API calls and save the user from cumbersome data entry steps. I can't say enough how important this toolkit is to my work--my job is to make sf.com a good platform for nonprofits to use to track donors, grants, volunteers, etc. With S-Controls and the AJAX toolkit I can make it work. I wanted to thank you guys for making my job possible (and fun) and for your continued development of AJAX toolkit.

In the Beta 3.3 I noticed that UI widgets are starting to surface. The most important widget on my wish list is an object lookup field. I find myself creating S-Controls that ask the user for data, and it sure would be nice to be able to look up existing sf.com objects using the existing lookup layouts. Example:

As part of my Householding application, I have an S-Control data entry form that creates two Contacts (a married couple), creates a Household (their home address), and then relates the new Contacts to that new Household. As we all know, Contacts need an Account when they are created. So, the user supplies an Account name to add the Contacts to on creation, and I go look it up with a query, get the ID if I find an exact match of the name, create a new Account if the name doesn't match exactly, or use a default Account if no name is supplied. If the Account name is misspelled, a new account will be created.

Obviously, a lookup box like we have in the sf.com web UI is what's needed here. Frankly, I don't have the time/skills to build that kind of lookup myself.

I'd love to see a lookup widget for objects. In my thinking about how to do it, I've come to realize that there is non-trivial complexity involved. But it sure would be great to be able to add an object lookup to an S-Control in one line of code. So, if you're thinking about it, mark me down as interested!

Thanks again for all the great work,

Steve
I'd like to update a few hundred contacts and blank out their email addressed. I have a CSV with Contact ID and an Email field that is blank. I run an update but the email address doesn't get blanked out.

I know that with the API blank values get ignored in an update, so how do I tell the dataloader to blank out a value?

Thanks,
Steve
I wrote earlier about a dotproject integration I was building. It's now to the point where I can share it. I've written up the whole thing with links to the pieces.
 
In short, I use PHP to take dotproject data stored in mysql and transform it into an sf.com object, which I then can report and dashboard against. It quickly gives me tons of visibility into the data I have in my outside system without having to do a ton of work--it's just one-way and read-only.
 
Thanks to everyone on this forum who helped me out during the project, especially TranMan!
 
Check it out and give me feedback if you have any,
Steve
  • April 15, 2006
  • Like
  • 1
I just did a short write up of a simple integration I built pulling dotproject data into Salesforce.com to leverage the reporting capabilities. If you're using dotproject you might find it interesting.

Steve
  • April 05, 2006
  • Like
  • 1
I stumbled acros a technique that many of you may already be using, but I've found it really helpful. I call S-Controls from custom formula fields that have querystring variables that control their function.

Calling an S-Control from a link is easy. The hyperlink looks something like this:

https://na1.salesforce.com/servlet/servlet.Integration?lid=01N300000008grl&eid=01N300000008jkl

The first ID is the S-Control's ID. The second ID is the ID of the current context object. If you click the link on a Contact layout, this will be the ID of that Contact.

The servlet handles that second ID and makes the fields for that object available to your S-Control in the form {!Contact_Id}.

The cool thing is you can add more querystring variables. This allows you to use a single S-Control for multiple links, each with different behavior because the extra querystring variables are different. Here's an example:

https://na1.salesforce.com/servlet/servlet.Integration?lid=01N300000008grl&eid=01N300000008jkl&type=Individual&opptype=Membership

In this case, the Type and Opptype variables let me use this one S-Control in links to create Opportunites from a Contact record. I get 6 different functions (2 Types x 3 OppTypes) from one S-Control, greatly simplifying my setup.

Steve
  • February 26, 2006
  • Like
  • 1
Here's a simple S-Control that allows for the importing of closed Opportunities. It requires manual User steps for importing the Opportunites as Leads via the Sforce Data Loader. Then, the S-Control converts those Leads to Opportunites and addresses some of the limitations in the Lead Conversion functionality in sf.com.



In addition to the standard Lead Conversion functionality, this S-Control sets the Close Date and Amount for an Opportunity. It also allows you to set the OpportunityContactRole for the Contact.



I have built this for importing donations that a nonprofit has received via PayPal or some other service, but I wanted to share it as I didn't find many examples of AJAX lead conversion while I was working on it.



The code deals with:



The LeadConverts object and the ConvertLeadResult object. I also use the OpportunityContactRole dynabean, another code snip for which I couldn't find AJAX examples.



Any feedback is welcome as I'm no expert in Javascript or S-Control development.



Steve, steve@onenw.org
  • December 01, 2005
  • Like
  • 1
hey Guys ,

just going through Apex code SOQL  queries and found some statements that confuse me a bit ,
u guys just have a look and help me out to reach any conclusion

statement 1

"It is important to note that SOQL queries only return data for SObject fields that are selected in the original query. Any fields that are not selected in the SOQL query (other than ID) are null when dereferenced in Apex Code, even if they contain values in the database."

Account a1 = [select id from accountwhere name = 'Acme'];
Double amt1 = 2 * a1.annualRevenue;
// The code above is incorrect: amt1 is now null, even if
// the account contains a value for annualRevenue in the
// database
Account a2 = [select id, annualRevenue from account
where name = 'Acme'];
Double amt2 = 2 * a2.annualRevenue;
48
Expressions
// The code above is correct: if the account contains a value
// for annualRevenue in the database, amt2 will not be null


statement 2
"Even if only one SObject field is selected, a SOQL query always returns a complete record. Consequently, you must dereference the field in order to access it.
"

Double rev = [select annualRevenue from account
where name = 'Acme'][0].annualRevenue;

*contradiction is  if I can access only those fields that are in the original query what is the need to dereference it ,
and if  query returns a complete record then i can derefernce any field without necessarly providing in query*

thx
  • November 22, 2007
  • Like
  • 1
hi All,
 
i am getting 'maximum trigger depth exceeded' error while inserting new account through trigger.
 
i am using developer account.
 
cud anybody help me out?
 
thanks,
Mahi
  • November 01, 2007
  • Like
  • 0
Has anyone needed to convert a string variable to integer? I need to code a verification digit function, and I am getting the digits from a string with the substring function. Next to that, I need to convert each 'text' number to integer for multiplication.
 
Here is a sample of what I need...
 
Code:
public static boolean CUITVerification(String cuit)
{
       if(cuit.length() != 11)
          return false;
       
       String xx1 = cuit.substring(1,1);
       Integer x1 = xx1;
       x1 = x1 * 5;

       if(x1 == 10)
          return true;

}

 to anyone who can help me...thanks
I've created a new custom object called "Class Registrations". I've created a new button called "create registration record" that once clicked on creates a new record for my custom object.
 
I've used Javascript to do it, this is the code I used:
 
Code:
<script language="JavaScript">
function redirect() 
{
parent.frames.location.replace( "/a0H/e—retUTL=/{Opportunity.id}" 
+ "&00N60000001K1qM={!Opportunity.Class_Price__c}" + "&save=0");
}
redirect();
</script>

 
I need to do a mass delete of records for a custom object. I'm running into a problem with "Too many SOQL queries" though. I have a trigger on the custom object and that is causing me to exceed the limit.

Is there a way to suspend triggers for an object for an operation like this? There is an Is Active property on the trigger, but I see no way to change the setting.

Interestingly, there is no Edit/Delete link on the trigger when I look at the custom object, and when I look at the code there is no option to edit it. Is this because I created it using the Apex Toolkit for Eclipse? Is there a way to make it inactive using the toolkit?

My only idea at this point would be to delete the trigger and its tests and class methods, do the delete, then add the code back. But that is going to be a mess that I'd rather not deal with.

By the way, I'm doing the deletion through the Apex Data Loader. I don't seen any option around the problem in that tool either. Have I missed something?

What options do I have?

Thanks!
Don
I have successfully deployed Apex code from a Dev instance to a production instance. I noticed that when I go to the classes and triggers in the admin interface of my production instance, there are no delete buttons, and I can't deactivate the trigger.

Let's say that I don't want the Apex in my instance any more. If I wanted to "undeploy" this code, that is remove it or inactivate the triggers, what's the best way to do that?

In the deploy wizard in Eclipse, my triggers and classes are recognized, but I can't take any action with ones that are currently already deployed since I haven't changed the files. I see the triggers and classes in Eclipse of my production org, and there is a delete option in the context menu, but I'm afraid to attempt that for screwing things up royally.

Any guidance on undeploying would be appreciated.

Thanks!

Steve
  • October 21, 2007
  • Like
  • 0
Anyone else out there using Eclipse with both the apex toolkit and Subclipse to write apex code and store it in an svn repository?  (I thnk some of you SF employees are doing that, yes?)

We've run into a problem that we're hoping someone else has already figured out.  It may be just an area in which subclipse & the apex plugin don't play well together, but we're guessing there's a way to make it work.

The situation is:
* we've got a small handful of developers collaborating on code within a single SF instance
* all our apex classes/triggers have been committed to svn
* all of my colleagues and I have checked out the project to our own eclipse instances
* as long as we're editing an existing file, it works pretty much as expected
* however, if one of us creates a new trigger or class, that causes problems
    * our current M.O. is periodically (after making sure our own recent changes have been saved to SF & committed to svn) doing an apex "Refresh Folder" on the entire Triggers and Classes folders.  This brings over to my local eclipse project any newly-created code that someone else has created since the last time I synced.
   * however, at that point my local eclipse somehow isn't aware that that file already exists in the svn repository as well, although my colleague has already committed it
   * the new file shows a "?" for its svn status, and most of the svn commands (Update, Syncrhonize, etc.) are disabled
   * one of the only commands available is Add To Version Control, but if I do that Eclipse from then on is confused about that file (it shows a + for its svn status, and still won't let me Update - gives me a name conflict error, seems to think there are two files w/ the same name in the repository, although I can verify that there aren't)
* the only other way we've found to get subclipse to recognize the new code is to delete the entire project, then re-Check Out from svn, which creates a brand new eclipse project including all the latest files.  The problem here is that eclipse seems to re-save all the triggers/classes to SF at this point.  This poses a real issue if one of my colleagues is working on some code and hasn't yet committed it back to svn.  If that's the case, it gets overwritten with the older version.

So how can we use these tools in a team enviornment and handle new triggers/classes? 

  • October 13, 2007
  • Like
  • 0
I was thwarted at the check-in counter by Alaska Airlines in my attempt to go to the developer conference yesterday. I'm bummed I missed it. Were any of these questions answered?

* When will Apex be availabe in General release?
* Will it have additional cost or will it be included in specific editions of Salesforce.com?
* Will there be an SOA preview program? How would one get in on that?

Thanks!

Steve
I can get an array of all fields on an object, but I cannot see the Id of each field. Why would I want the Id of a field? The create/edit forms in the sf.com web interface use these field Ids to pass data on the querystring to custom fields. To see this in action, go to a custom object you have and click new from any of the related lists. On the querystring you'll see lots of Id gibberish. It's that gibberish that sets the custom object reference on the edit page that pops up.

Without access to the field Id from a describe call, I have to manually discover and hardcode the Ids of fields that I want to prepopulate automatically in this way.

Give me the Id in the fields array in the describeSObjects call and I wouldn't have to hard code those custom field Ids.

Thanks!
Steve
I love Eclipse. I use it on multiple machines and connect to 16 different instances of sf.com. I use it for S-Controls and Apex code development. Thanks so much for this tool, it is an incredible time saver.

About a week ago, I got an error when synching my s-control folder on one instance. Since then, I have been unable to connect to that instance. Of the 16 instances I connect to, this is the only one on na4. Looks like it is timing out:

Here is the error I get in Eclipse 3.2.2 with the latest Apex add on:

Failed to send request to https://na4-api.salesforce.com/services/Soap/u/8.0
  com.appexchange.plugin.wizards.ConnectionPage.applySettings (ConnectionPage.java 191)
  com.appexchange.plugin.wizards.AppExchangeProjectWizard.performFinish (AppExchangeProjectWizard.java 60)
  org.eclipse.jface.wizard.WizardDialog.finishPressed (WizardDialog.java 680)
  org.eclipse.jface.wizard.WizardDialog.buttonPressed (WizardDialog.java 355)
  org.eclipse.jface.dialogs.Dialog$3.widgetSelected (Dialog.java 660)
  org.eclipse.swt.widgets.TypedListener.handleEvent (TypedListener.java 90)
  org.eclipse.swt.widgets.EventTable.sendEvent (EventTable.java 66)
  org.eclipse.swt.widgets.Widget.sendEvent (Widget.java 928)
  org.eclipse.swt.widgets.Display.runDeferredEvents (Display.java 3348)
  org.eclipse.swt.widgets.Display.readAndDispatch (Display.java 2968)
  org.eclipse.jface.window.Window.runEventLoop (Window.java 820)
  org.eclipse.jface.window.Window.open (Window.java 796)
  org.eclipse.ui.actions.NewProjectAction.run (NewProjectAction.java 116)
  org.eclipse.jface.action.Action.runWithEvent (Action.java 499)
  org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection (ActionContributionItem.java 539)
  org.eclipse.jface.action.ActionContributionItem.access$2 (ActionContributionItem.java 488)
  org.eclipse.jface.action.ActionContributionItem$5.handleEvent (ActionContributionItem.java 400)
  org.eclipse.swt.widgets.EventTable.sendEvent (EventTable.java 66)
  org.eclipse.swt.widgets.Widget.sendEvent (Widget.java 928)
  org.eclipse.swt.widgets.Display.runDeferredEvents (Display.java 3348)
  org.eclipse.swt.widgets.Display.readAndDispatch (Display.java 2968)
  org.eclipse.ui.internal.Workbench.runEventLoop (Workbench.java 1930)
  org.eclipse.ui.internal.Workbench.runUI (Workbench.java 1894)
  org.eclipse.ui.internal.Workbench.createAndRunWorkbench (Workbench.java 422)
  org.eclipse.ui.PlatformUI.createAndRunWorkbench (PlatformUI.java 149)
  org.eclipse.ui.internal.ide.IDEApplication.run (IDEApplication.java 95)
  org.eclipse.core.internal.runtime.PlatformActivator$1.run (PlatformActivator.java 78)
  org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication (EclipseAppLauncher.java 92)
  org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start (EclipseAppLauncher.java 68)
  org.eclipse.core.runtime.adaptor.EclipseStarter.run (EclipseStarter.java 400)
  org.eclipse.core.runtime.adaptor.EclipseStarter.run (EclipseStarter.java 177)
  sun.reflect.NativeMethodAccessorImpl.invoke0 (null -2)
  sun.reflect.NativeMethodAccessorImpl.invoke (null -1)
  sun.reflect.DelegatingMethodAccessorImpl.invoke (null -1)
  java.lang.reflect.Method.invoke (null -1)
  org.eclipse.core.launcher.Main.invokeFramework (Main.java 336)
  org.eclipse.core.launcher.Main.basicRun (Main.java 280)
  org.eclipse.core.launcher.Main.run (Main.java 977)
  org.eclipse.core.launcher.Main.main (Main.java 952)

Anything up with na4? This happens to be the instance of my employer, so I'd love some help troubleshooting so I can get working on our code again!

Thanks again for the great tool and any help you could provide tracking this error down.

Steve
  • April 11, 2007
  • Like
  • 0
 Hi
I am doing a project which involves generating a sales-order at the end.The sales order requires to be in a Word/PDF format.
It requires fields from different Custom/Standard objects.
Is there a way using mail merge or otherwise,to generate a sales order using JS/AJAX and the web APIs?

Thanks
Kaushik
Before a Contact is created I want to see if it has been related to an existing Custom Object called "ONEN_Household__C". If it hasn't, I want to create that Custom Object, then get the id of the new object, creating the Contact with that reference recorded.

Here's what I've got so far:
Code:
trigger HouseholdCheck on Contact bulk (before insert) {
         
  for (Contact c : Trigger.new) {
    if (c.ONEN_Household__c == NULL) {
      c.Description='No Household';
      insert new ONEN_Household__c (Name=c.firstname + ' ' + c.lastname + ' Household');
    }
  }
}
After I do the insert new ONEN_Household__C, how do I get that new object's Id?

Thanks!

Steve
 

  • March 29, 2007
  • Like
  • 0
Winter '07 added some validation on the upload of Appexchange packages that affected some of my code. Any S-Controls that had explicit references to Record Type Ids wouldn't load to the Appexchange. I would often write code like this:

var PurchaseRecordTypeId = "0000000000fff55";

When I needed this code in another instance, I would Appexchange it, install it, and then change the hard-coded reference.

Here's more elegant code that gets Record Type Ids dynamically, and doesn't trip the Appexchange validator:
var oOppRecordTypes = getRecrodTypesforObjects("Opportunity");

var DonationLabel = "Gift";
var MembershipLabel = "Membership";
var DonationRecordType = oOppRecordTypes[DonationLabel].Id;
var MembershipRecordType = oOppRecordTypes[MembershipLabel].Id;

function getRecrodTypesforObjects(ObjectName) {
 var RecordTypesArray = new Array();
 sfc = sforce.connection;

 var result = sfc.query("Select r.Id, r.Name, r.SobjectType from
 RecordType r where r.IsActive=true and r.SobjectType='"+ ObjectName +"'");

 var RecordTypesArray = result.getArray("records");
 oRecordTypes = new Object();
 for (var i=0;i<RecordTypesArray.length;i++) {
  var oSingleRecordType = new Object();
  oSingleRecordType.Name=RecordTypesArray[i].Name;
  oSingleRecordType.Id=RecordTypesArray[i].Id;
  oRecordTypes[RecordTypesArray[i].Name]=oSingleRecordType;
 }
 return oRecordTypes;
}

 I'd love to hear feedback if you have suggestions on how this code could do the job better.

Enjoy!

  • March 13, 2007
  • Like
  • 0
I've got working code to give me all Opp stagenames. I would like to narrow that list to values appropriate to one record type. I wasn't able to find a path to that in the documentation about the describeSObjects call.

Here's the working code:

Code:
function generateStageNamePicklist(picklistid) {
 var objects = sforce.connection.describeSObjects(["Opportunity"]);
 var OppObject = objects[0];
 var OppSourcePicklistValues = new Array();
   
 for (var i=0; i<OppObject.fields.length; i++) {
  if(OppObject.fields[i].name=="StageName") {
   var StageNameField = OppObject.fields[i];
   StageNameFieldPicklistValues = StageNameField.picklistValues;
  }
 }
 SelectBox = "<select id='" + picklistid + "'>";
 for (var currentStageName=0;currentStageName<StageNameFieldPicklistValues.length;currentStageName++) {
  SelectBox +="<option value="+ StageNameFieldPicklistValues[currentStageName].value +">" + StageNameFieldPicklistValues[currentStageName].value + "</option>";
 }
 SelectBox +="</select>";
 return SelectBox;
}

 Thanks in advance for any help!

Steve

  • March 05, 2007
  • Like
  • 0
I'm trying to convert an array of Leads and refresh the browser after each Lead is converted. I've got it all working except for the refresh--currently the browser doesn't refresh until after all the leads have been converted. Here's what I've got.

Code:
function createLeadToConvert(LeadArray,startRow) {
  var row = startRow;
  if (row<LeadArray.length){
    ThisLeadId = LeadArray[row];
    //lots of conversion code here
 //here I change a part of the page
document.getElementById("Row" + leadId + "Lead").innerHTML = "Converted"; //increment the row I'm looking at
startRow++;
//make the recursive call, hitting the next row of the LeadArray
 setTimeout(createLeadToConvert(LeadArray,startRow),50); } }
The setTimeout call isn't quoted, so I know that it will fire without the 50 milisecond pause. But I can't seem to pass the LeadArray in when it's quoted. I can pass the startRow, because it's just a number, but I'm unsuccessful at passing the array.

Any thoughts on how I could get the page to refresh after processing each row?

Thanks!
 

  • November 13, 2006
  • Like
  • 0
Hey Dave, Ron, Adam and all the sf.com folks who read this board.

I love the AJAX tookit! It has put incredible control over the sf.com UI in my hands. I'm creating custom code that users have no idea isn't standard sf.com functionality. I get to chain together API calls and save the user from cumbersome data entry steps. I can't say enough how important this toolkit is to my work--my job is to make sf.com a good platform for nonprofits to use to track donors, grants, volunteers, etc. With S-Controls and the AJAX toolkit I can make it work. I wanted to thank you guys for making my job possible (and fun) and for your continued development of AJAX toolkit.

In the Beta 3.3 I noticed that UI widgets are starting to surface. The most important widget on my wish list is an object lookup field. I find myself creating S-Controls that ask the user for data, and it sure would be nice to be able to look up existing sf.com objects using the existing lookup layouts. Example:

As part of my Householding application, I have an S-Control data entry form that creates two Contacts (a married couple), creates a Household (their home address), and then relates the new Contacts to that new Household. As we all know, Contacts need an Account when they are created. So, the user supplies an Account name to add the Contacts to on creation, and I go look it up with a query, get the ID if I find an exact match of the name, create a new Account if the name doesn't match exactly, or use a default Account if no name is supplied. If the Account name is misspelled, a new account will be created.

Obviously, a lookup box like we have in the sf.com web UI is what's needed here. Frankly, I don't have the time/skills to build that kind of lookup myself.

I'd love to see a lookup widget for objects. In my thinking about how to do it, I've come to realize that there is non-trivial complexity involved. But it sure would be great to be able to add an object lookup to an S-Control in one line of code. So, if you're thinking about it, mark me down as interested!

Thanks again for all the great work,

Steve
I'm pondering the idea of creating an AJAX-based s-control and then launching it via a 'bookmarklet' link in the browser.  I'm wondering if anyone has tried this, and if there are any pitfalls to watch out for, tips to try, etc.

The motivation is that there are so few places in the SFDC UI where one can put a link to an s-control.  Basically your options are limited to object "view" screens, and splash pages.  I'm thinking that if I have a function I want to be able to run while editing a record, or viewing a report, a bookmarklet might be the best way.

What say you?