• Suvra
  • NEWBIE
  • 65 Points
  • Member since 2009

  • Chatter
    Feed
  • 2
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 19
    Questions
  • 32
    Replies

Hi,

 

I have one SOQL which will retrieve nearly 50k records. Can anyone please tell me how to handle this scenario.

As SOQL is able to retrieve at most 10,000 records, somehow I need to pass the start index to SOQL to retrieve set of next 10,000 recs..etc.

 

Is it possible at all? How will Batch apex help in this?

 

Thanks ain advance,

Suvra

  • December 08, 2009
  • Like
  • 0

Hi,

 

I am trying tp develop one Pagination framework along with Filtering and Sorting Utility incorporated in it. I need to make it generalized for any sObject.

 

Say, i'm using it for Product2 object andthus  one method returns List<Product2>. In another case, sObject is OpportunityProducts(some custom object) and hence, the method should return List<OpportuinityProducts>..

 

Can anyone please tell me how to achieve this?

 

 

Thanks in advance,

Suvra

  • August 10, 2009
  • Like
  • 0

Hi,

 

Is there any way to retrieve data in sets by using SOQL? Just fro avoiding governor limit, I need to retrieve a certain no. of records from data base in one go. In my page, i'll have one "Next Set" button, on click of which next set of data should come up.

 

Can anyone plz help me on this..

 

Thanks,

Suvra

  • August 07, 2009
  • Like
  • 0

Hi,

 

Is there any way of accessing the Index of a list on which I am iterating in a page? How to get the current index?

 

Also, if I have another List object in Controller, and I just want to use that list in a page. Say, i have a list of string called "productList" in Controller and it has values like "A","B","C","D". Now in page I have some index value say,3 available in some variable. And with that index I need to access productList[3]. Is it at all possible in VF?

 

 

Thanks in advance,

 

Suvra

  • August 07, 2009
  • Like
  • 0

Hi All,

 

In many places of Visualforce Code development I needed to have the some javascript variables to be accessed from the page. Say, I have one String "Hello World" in one javascript variable, how to print that by use of <apex:outputtext> tag of visualforce?

 

Also, sometimes I need to update some Apex COntroller variable with the value of Javascript var. 

 

Do you people have any kind of idea on how to accomplish this..Please help.

 

Thanks in advance,

Suvra

  • August 07, 2009
  • Like
  • 0

Hi,

 

I need to override "Save & New" button on Opportunity edit page. But, there should not be any change in the "New" button on Object Home Page in terms of functionality.

 

Either "Save & New" needs be removed or it should not allow creating new records.

 

Any idea how to go about it??

 

Please help.. Thanks in Advance,

 

Suvra

  • July 20, 2009
  • Like
  • 0

Hi,

 

 

I need to create one Grid Structure in Visualforce page. The row Headings and Column headings will get populatetd from 2 lists. Can anybody please tell me how to achieve this..

 

I will give one example. Say, I have a list of Strings containings Account Names and another List containing Contact Names. Now, I need to keep Account Names in rows and Contact names in columns. At least I am trying to acheve this before proceeding further.

 

Please help..

 

Thanks in advance,

Suvra

  • June 29, 2009
  • Like
  • 0

Hi all,

 

Does anyone have any idea on how to call Apex Class methods directly from a S-Control without using Visualforce page?

If it is possible, what is the code syntax in S-control??

 

Please help..

 

Thanks in advance,

Suvra

  • May 28, 2009
  • Like
  • 0

Hi,

 

In a oage I have one outputpanel containing 6 columns, each with column header and list of values displayed. Now, above each header I want to display one input Text component.

 

In the outputPanel <apex:pageblock...> and <apex:column> are used.

 

code segment is given below :

 

<apex:outputpanel layout="block" style="overflow:auto; width:950px; height:170px" rendered="{!currentSetSizeInternet>0}">
                   
                      <apex:pageBlockTable value="{!currentInternetListing}" var="VisionListing">
                        <apex:column >                 
                                                                                  
                            <apex:facet name="header"> 
                               
                                <apex:CommandLink action="{!sortByInternetCompanyID}">Company ID
                                <apex:outputText rendered="{!internetListingSorting.sortByCompanyIDAscending==1}">&uarr;</apex:outputtext>
                                <apex:outputText rendered="{!internetListingSorting.sortByCompanyIDAscending==2}">&darr;</apex:outputtext> 
                                </apex:CommandLink>
                            </apex:facet>                 
                            <apex:outputtext value="{!VisionListing.custCompId}"/>
                        </apex:column>

      
                        <apex:column >
                            <apex:facet name="header">
                                <apex:CommandLink action="{!sortByInternetName}">Listed Name
                                <apex:outputText rendered="{!internetListingSorting.sortByNameAscending==1}">&uarr;</apex:outputtext>
                                <apex:outputText rendered="{!internetListingSorting.sortByNameAscending==2}">&darr;</apex:outputtext> 
                                </apex:CommandLink>
                            </apex:facet>                 
                            <apex:outputtext value="{!VisionListing.listedName}"/>
                        </apex:column>

 

Now, where to put the <apex:inputText> field, such that it'll come above the Column Headings??

 

Please help.

 

Thanks in advance,

Suvra

  • May 26, 2009
  • Like
  • 0

Hi,

 

While Running a testmethod, I am getting the exception "System.TypeException: Testmethods do not support webservice callouts". This testmethod is for testing a trigger, which is calling the Google API service for Latitude and Lonitude Conversion. I am using Salesforce API version 15.0

 

What can be the alternative way? Please help..

 

Thanks in advance,

Suvra

  • April 17, 2009
  • Like
  • 0

Hi,

In my Account Page layout I can see the "Sharing" button present. But when I'm crerating a new Account record, then in its detail page the "Sharing" button is not present.

 

What can be the reason behind that?? Please help..

 

Thnaks in advance,

Suvra

  • April 08, 2009
  • Like
  • 0
Hi all, Can anyone kindly give me a brief idea about the web-to-case functionality in salesforce and how it is related to Contact or other objects.. Thanks in advance, Suvra
  • April 07, 2009
  • Like
  • 0

HI,

I have written one after update trigger on Opportunity standard object, which will update one field in Contact Object. But this trigger is getting fired twice.

 

Any idea on why the trigger is getting fired twice and how to resolve the problem?

 

Thanks in Advance,

Suvra

  • March 23, 2009
  • Like
  • 0

Hi,

I have one custom lookup object to Contacts in Opportunity. So, for every Opportunity Record, there will be one Contact Record. Now i want to access the Contact Record fields like Id,Address etc. from a S-Control, for one particular opportunity.

 

Can anyone kindly tell me how to do this?

 

Thanks in advance,

Suvra

  • March 18, 2009
  • Like
  • 0
Hi, How to create Help Text for Custom Object field? Thanks, Suvra
  • March 12, 2009
  • Like
  • 0

Hi,

I want to delete records from a custom table. Can anybody tell me what is the exact commend for deleting set of records in SOQL?

 

Thanks,

Suvra

  • February 26, 2009
  • Like
  • 0

Hi,

Can anybody tell me, what is the base class for all the classes in salesforce?

 

e.g, "Object" is the base of all classes in java and onject of any class can be assigned to object of "Object" class..

 

I have one class called "OpportunityProductUDACVO" in salesforce. From another class i'm creating instances of this class. Now, I want to have a generic object for all the classes, to which i can assign the instance of this particular class.

I know that sObject is generic object for all salesforce objects. But, its nt working for salesforce class objects.

Kindly let me know if there is anything else to consider.

 

Thanks in advance,

Suvra

  • February 25, 2009
  • Like
  • 0

Hi,

 

I have problem in inserting list of records in a custom table called, marker. Please find the code below :

 

Apex Controller Class :

public Abstract class SearchNearby { 

    private Account acct;
    public String strLat;
    public String strLong;
    public Double dbLat,dbLong;
    
    
    public List<suvra__marker__c> marker {get; set;}
    public List<suvra__marker__c> markerListTest {get; set;}

    
    public SearchNearby(ApexPages.StandardController controller) {
        this.acct = (Account)controller.getRecord();
        acct=[select Id,suvra__Latitude__c,suvra__Longitude__c from Account where Id=:acct.Id];
        strLat=acct.suvra__Latitude__c;
        strLong=acct.suvra__Longitude__c;
    }


    public SearchNearby () {
        marker = new List<suvra__marker__c>();
        //marker.add(new suvra__marker__c());
    }

   public PageReference getNearbyPlaces() {
   
       
        dbLat= Double.valueOf(strLat);
        dbLong= Double.valueOf(strLong);        

       
       Double maxLat=dbLat+1;
       Double minLat=dbLat-1;
       Double maxLong=dbLong+1;
       Double minLong=dbLong-1;
       Integer i;
       Double sampleLat,sampleLong;
       
       List<Account> finalList ;
       List<Account> myList ;
       
       myList=[select Id,name,billingstreet,billingcity,billingPostalcode,billingstate,suvra__Latitude__c,suvra__Longitude__c from Account];          
       try{
       for(Account acc:myList)
       {
           if(acc.suvra__Latitude__c != null && acc.suvra__Longitude__c != null){
               sampleLat = Double.valueOf(acc.suvra__Latitude__c);
               sampleLong = Double.valueOf(acc.suvra__Longitude__c);
           }
           else {
               continue;
           }    
           if(sampleLat != null){
               if((sampleLat <= maxLat && sampleLat >= minLat) && (sampleLong <= maxLong && sampleLong >= minLong))
               {
                    if(acc != null)
                    finalList.add(acc);
                                       
                }
       }
       }
       
             
       
           
       for(Account accfinal:finalList){
       
           suvra__marker__c markerSingle = new suvra__marker__c(); 
           
           markerSingle = [select suvra__Record_Identifier__c,suvra__Street__c,suvra__City__c,suvra__State__c,suvra__Postal_Code__c,suvra__Country__c,suvra__Latitude__c,suvra__Longitude__c from suvra__marker__c limit 1];
           
           if(accfinal != null){
           

               markerSingle.suvra__Record_Identifier__c = accfinal.Id;
               markerSingle.suvra__Street__c = accfinal.billingstreet;
               markerSingle.suvra__City__c = accfinal.billingcity;
               markerSingle.suvra__State__c = accfinal.billingstate;
               markerSingle.suvra__Postal_Code__c = accfinal.billingpostalcode;
               markerSingle.suvra__Country__c = accfinal.billingcountry;
               markerSingle.suvra__Latitude__c = Double.valueOf(accfinal.suvra__Latitude__c);
               markerSingle.suvra__Longitude__c = Double.valueOf(accfinal.suvra__Longitude__c);
               
               marker.add(markerSingle);
            }
        }    
       
            
       
        insert marker;
        markerListTest = new List<suvra__marker__c>();
       
       markerListTest = [select s.suvra__Street__c, s.suvra__State__c, s.suvra__Record_Identifier__c, s.suvra__Postal_Code__c, s.suvra__Longitude__c, s.suvra__Latitude__c, s.suvra__Country__c, s.suvra__City__c, s.SystemModstamp, s.OwnerId, s.Name, s.LastModifiedDate, s.LastModifiedById, s.IsDeleted, s.Id, s.CreatedDate, s.CreatedById From suvra__marker__c s];
       
       if(markerListTest.size() > 0)
           System.debug('Record Inserted Successfully');
       else
           System.debug('Sorry..Record not inserted');
       }catch(Exception e){
            System.debug('Exception occured'+e);
       }
                 
       PageReference redirPage = new PageReference('/'+ 'a0C/o');
       redirPage.setRedirect(true);
       return redirPage ;
       
        
                
        
   
  }
  
 }

 

VisualForce Page :

<apex:page standardController="Account" extensions="SearchNearby">

<apex:form >
<apex:pageBlock >
<apex:outputText >
Find the nearby Places for the Present Address :

{!account.billingstreet}
{!account.billingcity}
{!account.billingstate} {!account.billingpostalcode}
{!account.billingcountry}

</apex:outputText>

<apex:commandButton value="Search" action="{!getNearbyPlaces}"/>

</apex:pageBlock>
</apex:form>
</apex:page>

 

This code is executing properly, but no record are getting updated in marker table. Please help

  • February 20, 2009
  • Like
  • 0

Hi,

 

I need to Incorporate Google Map into salesforce. For that I generated one API Key and used that key in the following Visual Force page. But after executing the page, Map is not getting loaded.

 

<apex:page standardController="Account" sidebar="false">
<apex:variable var="DestAddress" value="{!account.billingstreet}, {!account.billingcity}, {!account.billingstate}, {!account.billingpostalcode}"/>
<apex:variable var="SourceAddress" value="from: 500 Memorial Drive, Cambridge, MA to: "/>
<apex:variable var="address" value="{!SourceAddress} {!DestAddress}"/>
<!--<apex:outputPanel >
<apex:outputLabel value="{!account.name}"/>
</apex:outputPanel>-->

 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"  xmlns:v="urn:schemas-microsoft-com:vml">
  <head>
    <title>Google Maps JavaScript API Example: Simple Directions</title>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
   
    <script src="http://maps.google.com/maps?
    file=api&v=2&key=ABQIAAAAAU2IOEFrV1LYavl7OvxJjBQwNgRt8BDbI5KFRawO0dUAA_H1zxTwu7jPL6-
    izlVOZ3V76V8efAsRpA" type="text/javascript"></script>     
    <script type="text/javascript">
    // Create a directions object and register a map and DIV to hold the
    // resulting computed directions

    var map;
    var directionsPanel;
    var directions;
    var addressScript = "{!address}";
   
      
    function initialize() {    
     
     
      map = new GMap2(document.getElementById("map_canvas"));
      map.setCenter(new GLatLng(42.351505,-71.094455), 15);
      directionsPanel = document.getElementById("route");
      directions = new GDirections(map, directionsPanel);
      directions.load(addressScript);
    }
    </script>
  </head>
 
   <body onload="initialize()">
         
    <div id="map_canvas" style="width: 70%; height: 480px; float:left; border: 1px solid black;"></div>
    <div id="route" style="width: 25%; height:480px; float:right; border; 1px solid black;"></div>
   

   
    <br/>
  </body>
  </html>
</apex:page>

 

 

Kindly help me in solving the problem. This is for getting direction in Map,where the central location is the address of current account selected.Don't understand if anything else is also required with this.

  • February 17, 2009
  • Like
  • 0

Hi,

 

I am trying to implement initial Helloworld webservice in Salesforce.

But i got error:

 

"Web service callout failed: WebService returned a SOAP Fault: INVALID_SESSION_ID: Invalid Session ID found in SessionHeader: Illegal Session faultcode=sf:INVALID_SESSION_ID faultactor="

 

 

After that i have tried to write login() method for getting valid session id so i took reference of sample java method

 

Sample Code—Java

 

privateboolean login()

{

LoginResult loginResult = null;

SoapBindingStubbinding = null;

try {

// Createbinding object

binding = (SoapBindingStub) new SforceServiceLocator().getSoap(); // login

 

loginResult =binding.login("username", "password");

    }

catch (Exception ex){

System.out.println("An unexpected errorhas occurred." + ex.getMessage());

return false;

}System.out.println("Login was successful.");

 

// Resetthe SOAP endpoint to the returned server URL

 

binding._setProperty(Stub.ENDPOINT_ADDRESS_PROPERTY, loginResult.getServerUrl());



// Createa new session header object // add the session ID returned from thelogin

 

_SessionHeader sh = new _SessionHeader(); sh.setSessionId(loginResult.getSessionId());

// Set the sessionheader for subsequent call authentication

 

binding.setHeader(new SforceServiceLocator().getServiceName().getNamespaceURI(),

"SessionHeader",sh);

 

//get user info

 

try {

GetUserInfoResultuserInfo = binding.getUserInfo(); }

 

catch (Exception ex) {

System.out.println("Anunexpected error has occurred." + ex.getMessage()); returnfalse;

}return true;

}

 

 

But when i tried to implement this same code in Apex i got many error bcoz it is in java .

I just want to know hoe can we write login method in Apex so tat could get valid session id to implement my webservice.

 

Regards

Manoj 

 

 

 

 

Hi All,

 

My app has a couple of custom user fields that are used to access outside data (almost identical to SalesForce's own username/pass+security token setup).

 

I ask for this info in the user setup section of SalesForce, but they don't show up by default until the admin either manually adds them to the layour or designates our layout.

 

Is there a way to automatically add these fields to the user layout during install? If not, is there a tutorial I can link to about setting up the user layout?

Hi,

 

I have one SOQL which will retrieve nearly 50k records. Can anyone please tell me how to handle this scenario.

As SOQL is able to retrieve at most 10,000 records, somehow I need to pass the start index to SOQL to retrieve set of next 10,000 recs..etc.

 

Is it possible at all? How will Batch apex help in this?

 

Thanks ain advance,

Suvra

  • December 08, 2009
  • Like
  • 0

Hi,

 

Is there any way to retrieve data in sets by using SOQL? Just fro avoiding governor limit, I need to retrieve a certain no. of records from data base in one go. In my page, i'll have one "Next Set" button, on click of which next set of data should come up.

 

Can anyone plz help me on this..

 

Thanks,

Suvra

  • August 07, 2009
  • Like
  • 0

Hi,

 

Is there any way of accessing the Index of a list on which I am iterating in a page? How to get the current index?

 

Also, if I have another List object in Controller, and I just want to use that list in a page. Say, i have a list of string called "productList" in Controller and it has values like "A","B","C","D". Now in page I have some index value say,3 available in some variable. And with that index I need to access productList[3]. Is it at all possible in VF?

 

 

Thanks in advance,

 

Suvra

  • August 07, 2009
  • Like
  • 0

Hi All,

 

In many places of Visualforce Code development I needed to have the some javascript variables to be accessed from the page. Say, I have one String "Hello World" in one javascript variable, how to print that by use of <apex:outputtext> tag of visualforce?

 

Also, sometimes I need to update some Apex COntroller variable with the value of Javascript var. 

 

Do you people have any kind of idea on how to accomplish this..Please help.

 

Thanks in advance,

Suvra

  • August 07, 2009
  • Like
  • 0

In Java you can access a class's fields using the reflective method getField(String name). Is something like this possible in Apex?

 

For example, instead of accessing with simple dot notation:

 

String lname = Contact.lastName;

 

Is there a way to do something like this:

 

String lname = Contact.getField('lastName'); 

 

I'm trying to access a field where I'm pulling the field name from a variable, but I obviously can't do something like. 

 

String.myVar = "lastName";

String lname = Contact.myVar;

 

I can set this up with a block of if statements (like a switch statement), but if there's a way to do it with reflection, that seems more elegant to me. I'm going to be testing for a lot of values so it would certainly be more concise (1 line of code vs n lines, where n is the number possible values).

 

 if(myVar == "lastName" ) {lname = Constant.lastName}

 

I'm guessing the answer is no, because I don't see it in the manual...

 

-paul

Message Edited by ptepper on 08-03-2009 02:27 PM



Hi

I need to be able to call a method in a Custom Controller and pass it a parameter. I could not find a way to do this.

So basically, I came up with a workaround using a CustomComponent, passing it an Attribute. Then my CustomController for the Component uses that Attribute to determine its output.

My question is, is this slow and/or heavy?! Is there a better/easier way to do this with VisualForce page and Apex?

Here is a sample use of how I have it set up now.

VF page:
<td class="whee"><c:TranslateComponent translate="{!myVaryingText}" /></td>

 

Component:

<c:TranslateComponent:
<apex:component controller="TranslateController">
    <apex:attribute name="Translate" type="String" description="Text to be translated." required="required" assignTo="{!Translate}" />
    {!Translated}
</apex:component>

Message Edited by maraflux on 07-31-2009 03:47 PM

Hi,

 

I need to override "Save & New" button on Opportunity edit page. But, there should not be any change in the "New" button on Object Home Page in terms of functionality.

 

Either "Save & New" needs be removed or it should not allow creating new records.

 

Any idea how to go about it??

 

Please help.. Thanks in Advance,

 

Suvra

  • July 20, 2009
  • Like
  • 0

Hello,

 

I'm developing error logger for SFDC and im courius is there a way to get current class and method name?

E.g. i want to add in catch exception brackets line:

 

logNewError(currentClassName, currentMethodName, errorDescription).

 

I hope you got my point;)

 

Best Regards,

Lukas

Hi,

 

 

I need to create one Grid Structure in Visualforce page. The row Headings and Column headings will get populatetd from 2 lists. Can anybody please tell me how to achieve this..

 

I will give one example. Say, I have a list of Strings containings Account Names and another List containing Contact Names. Now, I need to keep Account Names in rows and Contact names in columns. At least I am trying to acheve this before proceeding further.

 

Please help..

 

Thanks in advance,

Suvra

  • June 29, 2009
  • Like
  • 0

Hi All,

 

I'm having a problem with my visual force page whereby i'm simply trying to get a command button to call a test javascript function, and it just doesn't want to play! i've managed to do it on other VF pages i have, but for some reason here it just won't work. Hopefully it's something dead simple that i've just missed because i've been staring at it for so long!

 

The page is of the form:

 

 

<apex:page controller="AController" extensions="AControllerExt" >
<apex:form id="form">
<h1>Some text here</h1>
</apex:form>
<apex:form>
<apex:outputLabel>Label text here</apex:outputLabel>
<br/>
<br/>
<apex:commandButton value="ButtonText" onmousedown="test()"/>
<br/>
<br/>
</apex:form>

<script>

function test() {

alert('in test function');
}

</script>

</apex:page>

 

 

Just to clarify, I don't get the alert box popping up, the page just refreshes.

 

Any ideas?

 

TIA,

 

Marco

 

Message Edited by mt0859 on 05-27-2009 10:03 AM
Message Edited by mt0859 on 05-27-2009 10:04 AM

Hi All,

 

I'm trying to call an Apex function (in a controller extension class) using a Javascript "onclick" event and a VF ActionFunction. The scenario is this....

 

The button that triggers the "onclick" event is located in a VF page of form:

 

 

<apex:page controller="MyMasterPageController">

<apex:sectionHeader title="ATitle">
<apex:pageBlock >
<apex:composition template="MyChildPageComposition"/>

<apex:form >
<apex:commandButton value="Click Me" onclick="MyJavascriptFunc()"/>
</apex:form>

</apex:pageBlock>
</apex:sectionHeader>

</apex:page>

 

which is known as the "master" page.

 

 

The javascript function is located in the composition "MyChildPageComposition" of form:

 

 

<apex:page controller="MyMasterPageController" extensions="ControllerExtForChildPage">
<apex:form >

<apex:actionFunction action="{!myApexFunc}" name="MyJavascriptFunc"/>

<apex:pageBlock>
<apex:pageBlockSection title="ASectionTitle">

<!-- Input fields/bulk of VF page etc goes here -->

</apex:pageBlockSection>
</apex:pageBlock>

</apex:form>
</apex:page>

 

which is known as the "child" page and displayed within the "master" page using the <apex:composition> functionality.

 

 

The Apex function "myApexFunc" is found in the class "ControllerExtForChildPageComposition" and is of form:

 

 

public PageReference myApexFunc() {

// do something here
system.debug('Print some debug here');

return null;
}

 

 

 

Now, my issue is that if I create the VF pages for real as basic as those examples above, "myApexFunc" is successfully called (the debug is printed, and any other code in it runs) when the "Click Me" button in the master page is clicked.

 

However, when I have attempted to incorprate the basic apex and VF code above into existing master/child pages and their associated controllers and extensions, "myApexFunc" is never successfully called. In fact, if the child page is subsituted for a child page of this form:

 

 

 

<apex:page controller="MyMasterPageController" extensions="ControllerExtForChildPage">
<apex:form >

<apex:actionFunction action="{!myApexFunc}" name="AnotherJavascriptFunc"/>

<script>

function MyJavascriptFunc() {
alert('Running Javascript');
AnotherJavascriptFunc();
alert('Finishing javascript');
}

</script>

<apex:pageBlock>
<apex:pageBlockSection title="ASectionTitle">

<!-- Input fields/bulk of VF page etc goes here -->

</apex:pageBlockSection>
</apex:pageBlock>

</apex:form>
</apex:page>

 

which is incorprated into an existing child page,both alerts are run (proving that the link between the "onclick" event in the master page and "MyJavascriptFunc" in the child page composition is there, but "myApexFunc" is still not called! Can anyone shed any light on this? Is there any VF or Apex code which is incompatible with using Javascript and action functions? As I said before, when it's in its basic forms above, everything works, just not when other VF and apex code are added.

 

Many thanks,

 

Marco

 

 

 

 

 

 

 

 

Hi,

 

While Running a testmethod, I am getting the exception "System.TypeException: Testmethods do not support webservice callouts". This testmethod is for testing a trigger, which is calling the Google API service for Latitude and Lonitude Conversion. I am using Salesforce API version 15.0

 

What can be the alternative way? Please help..

 

Thanks in advance,

Suvra

  • April 17, 2009
  • Like
  • 0
how to  access controller variable from visual force page's java script
I get "Sforce is not defined" error message on the following code for mass completing tasks. The button is executing Javascript.

If the user has "View all Data" permission, I do not get the error message.

I read somwhere that AJAX libray is not being loaded and including {!REQUIRESCRIPT("/soap/ajax/12.0/connection.js")}; should fix it. But it doesn't.

Interesting, "mark complete" code for single task works okay - so i suspect there is an interaction with GETRECORDIDs.

Code:
/* This code allows the javascript to access the API and push data into the Org.*/
{!REQUIRESCRIPT("/soap/ajax/12.0/connection.js")};
sforce.connection.session = "{!$Api.Session_ID}";

function massCompleteTasks( )
{
var taskArray = {!GETRECORDIDS( $ObjectType.Task )};
if (taskArray == null || taskArray.length == 0) {
    alert("Please select the tasks you wish to close.");
    return;
} else {
   var newTaskArray = new Array();
  for (var i = 0; i < taskArray.length; i++) {
     var newTask = new sforce.SObject("Task");
     newTask.Id = taskArray[i];
     newTask.Status = "Completed";
     newTaskArray.push(newTask);
  }
}
var callCompleted = false;  
try
{
   var result = sforce.connection.update(newTaskArray);
   callCompleted = true;
} catch(error) {
   alert("Failed to update Tasks with error: " + error);
}
if (callCompleted) {
    for (var i = 0; i < result.length; i++) {
         if (!result[i].getBoolean("success")) {
            alert("Task (id='" + newTaskArray[i] + "') could not be updated with error: " + result[i].errors);
         }
    }
    window.location.reload(true);
}

}

massCompleteTasks();

 
This code for markcomplete works okay:

Code:
* This code allows the javascript to access the API and push data into the Org.*/
{!REQUIRESCRIPT("/soap/ajax/12.0/connection.js")};
sforce.connection.session = "{!$Api.Session_ID}";

function updateTask( )
{
 try
    {
  var task = new sforce.SObject("Task");
  task.Id = "{!Task.Id}";
     task.Status = "Completed";
     var result = sforce.connection.update([task]);
     if (result[0].getBoolean("success") == false ) {
   alert(result[0].errors.message);
   return;
  }    
  window.top.location.href=window.top.location.href;
 } 
 catch (e) {
  alert(e);
 } 
}

updateTask();