Ye Meri Life Hai - Chirag Mehta

Be Good & Do Good!

Page 11 of 134

Salesforce: Eliminate Scrollbars

Source : http://www.interactiveties.com/b_remove_scrolls.php

Many new salesforce.com AJAX developers ask me how I am able to build my sControls into a frame and get the sizing setup in such a manner to prevent scrollbars. Over the years I’ve tried many different JavaScript functions but found that one works better than any I’ve seen.

For those reading this that might be unfamiliar with what I’m referring too I’ve included a screenshot.
In some instances an AJAX developer may want to build a sControl into salesforce.com whereby the sControl is embedded into the page. Basically there are tabs at the top and the navigation bar on the left-hand side with the sControl on the right-hand side.

When the web tab containing a sControl is setup through the Salesforce.com user interface the developer is allowed to dictate the size of the frame in which the sControl gets loaded. In most cases these new developers will simply alter that frame size to account for the largest height that may occur in the sControl. However, the script that I will eventually share with you will allow these developers to now ignore this pixel height setting and resize the frame dynamically.

I started using the script a year or two ago and a few months ago I altered it a bit because I was still getting scrollbars in Firefox. I found that the scrollbars didn’t always occur but I wanted to account for the percentages and try to eliminate them in entirely. Therefore, I decided to add a line where I determine if the browser is Firefox and then add 10 pixels to the adjusted frame height. I found that this truly eliminates the vertical scrollbars in almost 100% of the instances where I’ve used this script.

//resizes the frame holding the sControl to make up for odd dimensions
function resizeFrame()
{
var sframe = parent.document.getElementById("itarget"); //get id of iframe from parent
if (navigator.userAgent.indexOf("Firefox") != -1)
{ //if Firefox
var nHeight = document.body.scrollHeight+10; //add ten pixels to height of sControl frame
}
else
{ //otherwise
var nHeight = document.body.scrollHeight; //use the returned height of sControl frame
}
sframe.style.height = nHeight+"px"; //set the frame height to correspond to the content
}

And it can be called using this line:
resizeFrame(); //calls function from above

I hope you find this useful or can tweak it to meet your needs.,

Salesforce – URL hack to close an opportunity

Requirement

I’d like to create a button on Opportunities that does several things:
1.) Closes the Opportunity (Stage = Closed Lost)
2.) Makes a custom field have a specific value (Opportunity Lost Reason = “Wrong/Bad Number”

Solution:
Here’s the URL behind the button:

/{!Opportunity.Id}/e?retURL={!Opportunity.Id}&opp11=”Closed Lost”&00N80000002eg5T=”Wrong/Bad Number”&save=x

Where

00N80000002eg5T is the ID of the “Opportuntiey Lost Reason” custom field!
opp11 is the SF field name for Stage standard field in the layout.
save=x will automatically save the record after the changes are made.

Google Nexus Launched …

Google’s much anticipated Nexus One was finally unveiled at a press conference in Mountain View, California on January 5. It had already been distributed to Google employees in December, before its launch.

Made by HTC, Google has co-branded the phone. Google is retailing this phone in a way that it knows best, on the web. Available through www.google.com/phone, the phone is available for $529 as an unlocked version and $179 with two year contract with T-mobile (with a $79.99 monthly data plan) in the United States. It is also available for delivery in UK, Singapore and Hong Kong. So, yes, you cannot buy it in India yet, nor get it shipped here.

The looks of the phone are pretty similar to the iPhone but have a few more buttons that then Apple device. The bottom of the screen houses four touch sensitive buttons for Back, Home, Menu and Search unlike the iPhone that has just the one button to go back to the home screen. Below the buttons is a tri-color illuminated trackball. The color of the trackball changes depending on the kind of notification being received on the phone.

Read More @ http://www.google.com/phone/

http://www.google.com/phone/static/nexus-one-specs-shot.png

Increasing Java Heap for Ant

I ran across a little tip tonight I thought I should share. Trying to perform a large Salesforce Code migration with Ant kept giving me the following error: Out of memory. Increase Heap Size.

This is a Java error indicating that the virtual machine is out of memory. So now I know what the problem is, what next? If I was launching from a command line changing the heap size is not that tough. Just look up the options for java and set a new value, but I’m using Ant. Looking at the Ant shell script or batch file was no help.

Well a bit of Googling turned up that Ant looks for an environment variable called ANT_OPTS which is use to set Java parameters. Just set the environment variable and off you go. So I added the following to increase the heap size:

export ANT_OPTS=-Xmx256m

That sets the maximum heap size to 256 Megabytes. So if you ever need to increase the size of the Ant JVM, now you know how.

Apex Code to Invoke an External Web Service

To invoke an external service after using its WSDL document to generate an Apex class, create an instance of the stub in your Apex script and call the methods on it.

For example, to invoke the StrikeIron IP address lookup service from Apex, you could write a script similar to the following:

// Create the stub
strikeironIplookup.DNSSoap dns = new strikeironIplookup.DNSSoap();

// Set up the license header
dns.LicenseInfo = new strikeiron.LicenseInfo();
dns.LicenseInfo.RegisteredUser = new strikeiron.RegisteredUser();
dns.LicenseInfo.RegisteredUser.UserID = ‘you@company.com’;
dns.LicenseInfo.RegisteredUser.Password = ‘your-password’;

// Make the Web service call
strikeironIplookup.DNSInfo info = dns.DNSLookup(‘www.myname.com’);

Read More @ Salesforce.com

Salesforce Web service Callout Limits(Timeouts)

The following limits apply when an Apex script makes a callout to an HTTP request or a Web services call. The Web services call can be a Force.com Web Services API call or any external Web services call.

  1. A single Apex transaction can make a maximum of 10 callouts to an HTTP request or an API call.
  2. The default timeout is 10 seconds. A custom timeout can be defined for each callout. The minimum is 1 millisecond and the maximum is 60 seconds. See the following examples for how to set custom timeouts for Web Services or HTTP callouts.
  3. The maximum cumulative timeout for callouts by a single Apex transaction is 120 seconds. This time is additive across all callouts invoked by the Apex transaction.

The following is an example of setting a custom timeout for Web services callouts:

docSample.DocSamplePort stub = new docSample.DocSamplePort();
stub.timeout_x = 2000; // timeout in milliseconds

The following is an example of setting a custom timeout for HTTP callouts:

HttpRequest req = new HttpRequest();
req.setTimeout(2000); // timeout in milliseconds

How to Set Java Heap Space

The Java Virtual Machine (JVM) is the execution component of the Java Runtime Environment (JRE) that interprets and executes the byte code stores in a Java class. Within the Java Virtual Machine is a notional idea of the Java heap which is where objects created in a Java class reside in memory during the program’s execution.

When an object is done being used by the executing program, the Java Garbage Collector frees the memory in the Java Heap used by the object. If your java program requires an extensive use of memory and you do not increase the default Java Heap size, then your program can fail on a “out of memory” Java exception.

Step1 Open the command or DOS prompt on your computer. To open the prompt, select the “Start” menu and type “command” in the search text field followed by the “Enter” key.

Step 2 Change the DOS directory to the location of the Java program you are going to execute with the larger Java Heap size. To do this, type “cd ” followed by the fully qualified directory path of the class files. An example of this is: “cd c:\myjavafiles”.

Step 3 Change the max Java Heap size to 128 megabytes through the use of command line arguments on the Java Virtual Machine invocation. To do this, type the following command at the DOS prompt followed by the “Enter” key:
java –Xmx128m YourClassNameHere

Step 4 Exit the Java program run in Step 3. Re-run the Java application setting an initial default Java Heap size of 32 megabytes (MB) with the ability to increase the heap size to 128 MB if required by typing the following command at the DOS prompt followed by the “Enter” key:

java -Xms32m -Xmx128m YourClassNameHere

Salesforce Java Application to export Attachments – Appreciation …

Following are few appreciation notes from client, manager and team member ….

Ajay Kumar – Chirag chipped in early to find more details about this and got a fix in couple of long working days!! I would like to take this opportunity to appreciate Chirag’s terrific contribution and dedication on this. Bravo Chirag!! 🙂 U ROCK!!

Sue Gausch – I have already sung Chirag’s praises on this one, and will definitely continue to do so

Ajay Kumar – Chirag has been terrific in deliveries through past 6 months with wonderful client feedback. He has been instrumental in making a brand name for TATA’s.

Sunil Chauhan – Last few months have been nothing but great as far as your work is concerned. I have heard many good things about you in Dreamforce and now in Staples. I would love to imbibe your attitude and work ethic in the newbies who join our group. Keep up the good work and thanks for all your hardwork.

Salesforce – Move Attachments from 1 Organization to another

If you want to migrate from one org to another, then you first need to get a Weekly Export Service download. Make sure you check the “Include attachments” box. You will get an attachments.csv and the actual attachments.

The key to importing attachments is a little known feature inside Data Loader. The part that is not documented is that the import wants the actual filename in the BODY field. So for example, the attachments themselves have a ID name, let’s say its 123456789 and it is on your hard drive in the C:\Export folder. So in the BODY field you need to put C:\Export\123456789.

The only fields you need in the import file are – ParentId, Name, IsPrivate, OwnerId and Body.

« Older posts Newer posts »