• Abhijit Shrikhande 10
  • NEWBIE
  • 19 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 14
    Questions
  • 16
    Replies
I am using the following request to create a poll through the REST API.
I am obviously missing something, since my error is Unrecognized field "choices"
I am doing this via the REST Explorer in the workbench.
{ 
   "feedElementType":"FeedItem",
   "subjectId":"00570000001J64WAAS",
   "body" : {
      "messageSegments" : [      {
         "type" : "Text",
         "text" : "When should we meet for UDW planning?"}]
   },
   "capabilities":{ 
   "choices" : [
      "Monday", "Tuesday"
   ]
   }
}

 
Hello All,
How can I find out the apex classes that are not being used in the production org?
Is there some kind of mechanism available in the tooling api or the metadata api to find out when was a class last accessed?

Thanks,
Abhijit
I have a sandbox that was created in 2013. My user id was created in 2014 and the system admin profile was assigned to me.
I wish to logon to this sandbox that was created in 2013. How can I go about doing this?
I have two visual force pages. One for edit and another for save. From the edit page, I am calling a function in the controller extension, where I am attepmting to save the record. The name of this function is "QuoteNow
public PageReference QuoteNow()
    {
       string sfdcoperation = '';
        PageReference pageRef = ApexPages.currentPage();
        try
        {
            System.Debug('opp amount '+ opportunity.Amount);
            if (this.opportunity.id == null) 
            {
                System.Debug(this.opportunity);
                insert this.opportunity; 
            }
            else
            {
                update  this.opportunity;
            }
            System.Debug('new opp created ' + opportunity.Id);  
}

I am unable to see any values for this record. I have the following line of code in my constructor.
 
public OppExtension(ApexPages.StandardController stdController) 
    {
        System.Debug('Constructor of OppExtension');
        System.Debug('Standard controller - ' + stdController);
        try{
            
        this.opportunity= stdController.getId()!=null?
                          [SELECT  X42Id__c,
                                ConstructionPts__CP_Project__c,
                                Project_Name__c,
                                Project_Country__c,
                                Project_Zip_Postal_Code__c,
                                Project_State__c,
                                Project_City__c,
                                Project_Address__c,
                                Project__c,
                                RecordTypeId,
                                StageName,
                                AccountId,
                                Name,
                                CloseDate,
                                Id,
                                Product_Type__c,
                                Floors__c,
                                Contact__c,
                                Construction_Services_Involved__c,
                                LeadSource,
                                Delivery_Date__c,
                                Committed_Date__c,
                                Completed_Date__c,
                                OwnerId,
                                Amount
                                FROM Opportunity
                           WHERE Id = :stdController.getId()]:
                           new Opportunity();
} catch(Exception ex)
                           {
                            //Not hitting exception.
                            System.Debug('We are in exception '+ex.getMessage());
                           }


This is my visual force page.
<apex:page standardController="Opportunity" extensions="OppExtension" tabstyle="Opportunity" standardStylesheets="true">
	<apex:sectionHeader title="Opportunity Edit" subtitle="{!Opportunity.name}"/>
	<apex:form >
		<apex:pageBlock title="Opportunity Edit" mode="edit">
			<apex:pageBlockButtons location="top">
				<apex:commandButton title="Save Record." value="Quote Now" action="{!QuoteNow}" rendered="{!showQuoteNowButton}"/></apex:pageBlockButtons>
            <apex:pageBlockSection title="Naming convention: Party Name-Branch Name-Site Location-Project Description" columns="1">
                <apex:inputField value="{!Opportunity.Name}" required="true"/>
                <apex:inputField value="{!Opportunity.Floors__c}" required="true"/>
                <apex:inputField value="{!Opportunity.OwnerId}" required="false"/>
                <apex:inputField value="{!Opportunity.StageName}" required="true"/>                
                <apex:inputField value="{!Opportunity.AccountId}" required="true"/>
                <apex:inputField value="{!Opportunity.Amount}" required="true"/>
                <apex:inputField value="{!Opportunity.Product_Type__c}" required="true"/>                
                <apex:inputField label="Activation date" value="{!Opportunity.CloseDate}" required="true"/>        
</apex:pageBlockSection>
		</apex:pageBlock>
	</apex:form>
</apex:page>
Is there something that I am missing?

I am trying to make a call from the SoapUI tool to create a Remote Site Setting on a salesforce instance. I downloaded the Metadata WSDL and set it up in the tool by importing it.

If I make a call to describeMetaData it works as expected.

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:met="http://soap.sforce.com/2006/04/metadata">
   <soapenv:Header>
      <met:CallOptions>
         <met:client>SoapUI</met:client>
      </met:CallOptions>
      <met:SessionHeader>
         <met:sessionId>SessionToken</met:sessionId>
      </met:SessionHeader>
   </soapenv:Header>
   <soapenv:Body>
      <met:describeMetadata>
         <met:asOfVersion>36.0</met:asOfVersion>
      </met:describeMetadata>
   </soapenv:Body>
</soapenv:Envelope>
If I attempt to make a call to create a remote setting using the following request,
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:met="http://soap.sforce.com/2006/04/metadata">
	<soapenv:Header>
		<met:AllOrNoneHeader>
			<met:allOrNone>false</met:allOrNone>
		</met:AllOrNoneHeader>
		<met:CallOptions>
			<met:client>SoapUI</met:client>
		</met:CallOptions>
		<met:SessionHeader>
			<met:sessionId>SESSIONTOKEN</met:sessionId>
		</met:SessionHeader>
	</soapenv:Header>
	<soapenv:Body>
		<met:createMetadata>
			<!--Zero or more repetitions:-->
			<met:metadata>
				<RemoteSiteSetting xmlns="http://soap.sforce.com/2006/04/metadata">
					<description>Used for Apex callout to mapping web service</description>
					<disableProtocolSecurity>false</disableProtocolSecurity>
					<isActive>true</isActive>
					<url>https://www.maptestsite.net/mapping1</url>
					<met:fullName>TestSutieMap</met:fullName>
				</RemoteSiteSetting>
			</met:metadata>
		</met:createMetadata>
	</soapenv:Body>
</soapenv:Envelope>


it fails with the error.
 
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
   <soapenv:Body>
      <soapenv:Fault>
         <faultcode>soapenv:Client</faultcode>
         <faultstring>Must specify a {http://www.w3.org/2001/XMLSchema-instance}type attribute value for the {http://soap.sforce.com/2006/04/metadata}metadata element</faultstring>
      </soapenv:Fault>
   </soapenv:Body>
</soapenv:Envelope>
I have tried to force xsi:type="RemoteSiteSetting" on the <met:metadata> tag, but that has not worked either.
 
I have a batch class that runs once a day to send me emails.
global class getCreatedLeadsSummary implements Database.Batchable<AggregateResult>, Database.Stateful {
    public string leadSummary;
    global Iterable<AggregateResult> start(Database.batchableContext info){
        // just instantiate the new iterable here and return
        return new AggregateResultIterable();
    }

    global void execute(Database.BatchableContext BC, List<AggregateResult> scope)
    {
        try
        {
            leadSummary = '<table bgcolor="silver" border="2" cellpadding="2"><tr><td><b>Lead Source</b></td><td><b>Count</b></td></tr>';
            for(AggregateResult ar: scope)
            {
                string src = (string) ar.get('LeadSource');
                Integer cnt = (Integer) ar.get('cnt');
                leadSummary = leadSummary + '<tr><td>' + src + '</td><td>'+ cnt.format() +'</td></tr>';
            }
            leadSummary = leadSummary + '</table>';            
        }
        catch(Exception ex)
        {
            System.Debug('Some Exception >'+ ex.getMessage());
        }
    }

    global void finish(Database.BatchableContext BC)
    {
        // Get the AsyncApexJob using JobId 
        AsyncApexJob a = [SELECT Id, Status, NumberOfErrors, JobItemsProcessed, TotalJobItems, CreatedBy.Email, ExtendedStatus   
                            FROM AsyncApexJob 
                            WHERE Id = :BC.getJobId()];  
                                    
        if(a.Status == 'Completed')           
            utilMail.sendNotificationMail('Lead Summary Job Result',a,leadSummary);   
        else
            utilMail.sendNotificationMail('Job Did not Complete!',a,'Failure');   
    }   

    global class AggregateResultIterable implements Iterable<AggregateResult> {
        global Iterator<AggregateResult> Iterator(){
            return new AggregateResultIterator();
       }
    }

    global class AggregateResultIterator implements Iterator<AggregateResult> {
        AggregateResult [] results {get;set;}
        Integer index {get; set;} 

        global AggregateResultIterator() {
            index = 0;
            String query = 'Select COUNT(Id) cnt, LeadSource From Lead WHERE CreatedDate = YESTERDAY GROUP BY LeadSource';
            results = Database.query(query);            
        } 
        
        global boolean hasNext(){ 
           return results != null && !results.isEmpty() && index < results.size(); 
        }    
        
        global AggregateResult next(){ 
            return results[index++];            
        }       
    }    
}

This is my test metohd I created.
 
static testmethod void testmethod1() {
            
            List<Lead> allLeads = new List<Lead>();
            for(integer i =0; i< 199; i++)
            {
                            Lead l = new Lead();
                            l.FirstName = 'TEST ' + i.format();
                            l.LastName = 'Lead';
                            l.Lease_Amount__c = 240;
                            l.LeadSource='2055 - Website';
                            l.Company = 'Testing Batch Jobs';   
                            l.Title = 'Dr';
                            l.Phone='5556667777';
                            allLeads.Add(l);
            }
       
       insert allLeads;

       Test.startTest();
       Database.executeBatch(new getCreatedLeadsSummary());     
       Test.stopTest();

       Integer i = [SELECT COUNT() FROM Lead WHERE CreatedDate=Today];
       System.Debug(i);       
       System.assertEquals(i, 199);
    }
After executing this test method, my coverage is at 56% (17/30) lines. So I found that the execute method is not being covered. How can I cover the execute method in my test class and attempt to reach 100% coverage?
 
I am looking at the Tooling API for an example on how to create a class. I took a a look at this example and I suspect this documentation is outdated.

https://developer.salesforce.com/docs/atlas.en-us.198.0.api_tooling.meta/api_tooling/intro_soap_overview.htm

If you read the page it says "These Examples use java". This is incorrect. Console.WriteLine is not present in Java. It is a feature of C#.
When you attempt to compile this code, there are further errors.
 
String classBody = "public class Messages {\n"
   + "public string SayHello() {\n"
   + " return 'Hello';\n" + "}\n"
   + "}";

// create an ApexClass object and set the body 
ApexClass apexClass = new ApexClass();
apexClass.Body = classBody;
ApexClass[] classes = { apexClass };

// call create() to add the class
SaveResult[] saveResults = sforce.create(classes);
for (int i = 0; i < saveResults.Length; i++)
   {
   if (saveResults[i].success)
      {
        Console.WriteLine("Successfully created Class: " +
         saveResults[i].id);
      }
   else
      {
         Console.WriteLine("Error: could not create Class ");
         Console.WriteLine("   The error reported was: " +
         saveResults[i].errors[0].message + "\n");
      }
   }

Is there a specific example on how to use tooling API?
 
I have an Queueable class.
Example:
public class AsyncExecutionExample implements Queueable {
    public void execute(QueueableContext context) {
        Account a = new Account(Name='Acme',Phone='(415) 555-1212');
        insert a;        
    }
}
I am calling this class from another class.
Example:
ID jobID = System.enqueueJob(new AsyncExecutionExample());

In my Queueable class, I plan to send an email to certain users in case the process falters or fails along the way. I need to get the ApexJobId of the running process for that. How can I get the ApexJobId from within the queueable class?
 
I have the following process setup in my sandbox environment.

1) Read Data From Local Sqlserver
2) Call Apex Rest Class
3) Create Contacts.
4) Create community Users from the contacts.

Currently I am reluctant to run the 4th step in the process as I don't want emails going out to these contacts upon user creation. How can I stop that from happening? I don't want to stop all outgoing emails from the sandbox, but is there some setting that will not send emails when a user gets created?
I have performance edition and I have created a custom profile. Now I wish to assign this custom profile to an existing user. When I edit a user, I am not able to change the profile for that user. When I go to the newly created profile, I can create new users on it, but not select existing users.

Also, is it possible for a user to be assigned multiple profiles in salesforce?

 
I wish to understand how the REST API works with document attachments. I found some links
http://www.salesforce.com/us/developer/docs/api_rest/index.htm
http://www.salesforce.com/us/developer/docs/api_rest/Content/dome_sobject_insert_update_blob.htm

Using this information, I wanted to test this in the workbench REST Explorer. So I composed the following request:
{  
    "Description" : "Marketing brochure for Q1 2011",
    "Keywords" : "marketing,sales,update",
    "FolderId" : "00l70000001AG5g",
    "Name" : "Marketing Brochure Q1",
    "Type" : "pdf"
}

--boundary_string
Content-Type: application/pdf
Content-Disposition: form-data; name="Body"; filename="2011Q1MktgBrochure.pdf"
%PDF-1.4
%âãÏÓ
519 0 obj
<</Linearized 1/L 855529/O 521/E 35857/N 12/T 845101/H [ 894 565]>>
endobj
             
xref
519 29
0000000016 00000 n
0000001647 00000 n
0000001459 00000 n
0000000894 00000 n
trailer
<</Size 548/Prev 845089/XRefStm 1459/Root 520 0 R/Info 124 0 R/ID[<097E027FBE8C884598F32EB7C237FF5B><4080463A838922439FB92E5A73905FAB>]>>
startxref
0
%%EOF
             
547 0 obj
<</Length 476/C 591/Filter/FlateDecode/I 615/S 450>>stream
xÚb```f``¹ÀÀÊÀ ¦Ï Ì€

--boundary_string--


When I attempt to execute this using REST API - /services/data/v29.0/sobjects/Document
using the POST method, I get this error:
JSON_PARSER_ERROR
message: Extra JSON in request found after deserialization at: [line:9, column:3]
errorCode: JSON_PARSER_ERROR


I wish to know how can I test this in the Rest Explorer
I have been through the following document on developerforce.

https://developer.salesforce.com/page/Working_with_Custom_SOAP_and_REST_Services_in_.NET_Applications

I am trying to call a REST based service from a console application in . NET 4.0
The await keyword is not available in 4.0. I do not wish to cannot change my target framework to 4.5
So how do I go about making this code work with .NET 4.0?

Any help is appreciated. Thanks in advance.

 
How do I go about downloading an XML file from a FTP server and processing the file in APEX?


I have three objects. Two standard and one custom.
The standard objects are: Account and Opportunity.
The custom object is an object called Billing_Profile__C.

AccountId is the common field in all three objects. I am able to write a SOQL query like this.

Select o.Name, o.Id, o.Competitor__c, o.Amount, o.AccountId From Opportunity o WHERE o.AccountId NOT IN (Select  b.Account__c From Billing_Profile__c b)


This gives me a list of all the opportunities that have been created on accounts that do not have a billing profile. I want to put this in a validation rule on the opportunity object so that my user is not able to create an opportunity for any account that does not have a billing profile.

Firstly, instead of my query that simply returns a list of opportunities, how do I get the count of billing profiles for an account on an opportunity.

Secondly, how can I use that information in a validation rule when the user is creating this opportunity.

I have attempted to write a validation using VLOOKUP function. This is the rule I wrote.

VLOOKUP(
$ObjectType.Billing_Profile__c.Fields.Account__c,
$ObjectType.Billing_Profile__c.Fields.Name,
AccountId) <> AccountId
I am not sure if this rule is working as expected. I am getting an error on every save, regardless of the data. How can I correct this situation? Is there some way to log the values for each of the parameters I am sending? Can I test my function in the execute anonymous window?

Hi,
I've just started off wirh Salesforce development for my company. We want to integrate Salesforce with our existing android app and fetch the follow-up tasks of an user. I'm trying to do the same with the RestRequest class provided in the Salesforce Android SDK, and sending my request for the same as an SOQL statement. Now, I need help with following two things -
​1) Is it possible at all to obtain the follow-up tasks of user through SOQL?
2) If yes, can someone please provide me the exact SOQL statement for the same?

I know my problems are rather elementary, but I couldn't find any exact documentation for  what I am trying to achieve through the Salesforce API. So, any help with this will be highly appreciated!

Thank you for your time!
I have a sandbox that was created in 2013. My user id was created in 2014 and the system admin profile was assigned to me.
I wish to logon to this sandbox that was created in 2013. How can I go about doing this?
I have two visual force pages. One for edit and another for save. From the edit page, I am calling a function in the controller extension, where I am attepmting to save the record. The name of this function is "QuoteNow
public PageReference QuoteNow()
    {
       string sfdcoperation = '';
        PageReference pageRef = ApexPages.currentPage();
        try
        {
            System.Debug('opp amount '+ opportunity.Amount);
            if (this.opportunity.id == null) 
            {
                System.Debug(this.opportunity);
                insert this.opportunity; 
            }
            else
            {
                update  this.opportunity;
            }
            System.Debug('new opp created ' + opportunity.Id);  
}

I am unable to see any values for this record. I have the following line of code in my constructor.
 
public OppExtension(ApexPages.StandardController stdController) 
    {
        System.Debug('Constructor of OppExtension');
        System.Debug('Standard controller - ' + stdController);
        try{
            
        this.opportunity= stdController.getId()!=null?
                          [SELECT  X42Id__c,
                                ConstructionPts__CP_Project__c,
                                Project_Name__c,
                                Project_Country__c,
                                Project_Zip_Postal_Code__c,
                                Project_State__c,
                                Project_City__c,
                                Project_Address__c,
                                Project__c,
                                RecordTypeId,
                                StageName,
                                AccountId,
                                Name,
                                CloseDate,
                                Id,
                                Product_Type__c,
                                Floors__c,
                                Contact__c,
                                Construction_Services_Involved__c,
                                LeadSource,
                                Delivery_Date__c,
                                Committed_Date__c,
                                Completed_Date__c,
                                OwnerId,
                                Amount
                                FROM Opportunity
                           WHERE Id = :stdController.getId()]:
                           new Opportunity();
} catch(Exception ex)
                           {
                            //Not hitting exception.
                            System.Debug('We are in exception '+ex.getMessage());
                           }


This is my visual force page.
<apex:page standardController="Opportunity" extensions="OppExtension" tabstyle="Opportunity" standardStylesheets="true">
	<apex:sectionHeader title="Opportunity Edit" subtitle="{!Opportunity.name}"/>
	<apex:form >
		<apex:pageBlock title="Opportunity Edit" mode="edit">
			<apex:pageBlockButtons location="top">
				<apex:commandButton title="Save Record." value="Quote Now" action="{!QuoteNow}" rendered="{!showQuoteNowButton}"/></apex:pageBlockButtons>
            <apex:pageBlockSection title="Naming convention: Party Name-Branch Name-Site Location-Project Description" columns="1">
                <apex:inputField value="{!Opportunity.Name}" required="true"/>
                <apex:inputField value="{!Opportunity.Floors__c}" required="true"/>
                <apex:inputField value="{!Opportunity.OwnerId}" required="false"/>
                <apex:inputField value="{!Opportunity.StageName}" required="true"/>                
                <apex:inputField value="{!Opportunity.AccountId}" required="true"/>
                <apex:inputField value="{!Opportunity.Amount}" required="true"/>
                <apex:inputField value="{!Opportunity.Product_Type__c}" required="true"/>                
                <apex:inputField label="Activation date" value="{!Opportunity.CloseDate}" required="true"/>        
</apex:pageBlockSection>
		</apex:pageBlock>
	</apex:form>
</apex:page>
Is there something that I am missing?

I am trying to make a call from the SoapUI tool to create a Remote Site Setting on a salesforce instance. I downloaded the Metadata WSDL and set it up in the tool by importing it.

If I make a call to describeMetaData it works as expected.

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:met="http://soap.sforce.com/2006/04/metadata">
   <soapenv:Header>
      <met:CallOptions>
         <met:client>SoapUI</met:client>
      </met:CallOptions>
      <met:SessionHeader>
         <met:sessionId>SessionToken</met:sessionId>
      </met:SessionHeader>
   </soapenv:Header>
   <soapenv:Body>
      <met:describeMetadata>
         <met:asOfVersion>36.0</met:asOfVersion>
      </met:describeMetadata>
   </soapenv:Body>
</soapenv:Envelope>
If I attempt to make a call to create a remote setting using the following request,
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:met="http://soap.sforce.com/2006/04/metadata">
	<soapenv:Header>
		<met:AllOrNoneHeader>
			<met:allOrNone>false</met:allOrNone>
		</met:AllOrNoneHeader>
		<met:CallOptions>
			<met:client>SoapUI</met:client>
		</met:CallOptions>
		<met:SessionHeader>
			<met:sessionId>SESSIONTOKEN</met:sessionId>
		</met:SessionHeader>
	</soapenv:Header>
	<soapenv:Body>
		<met:createMetadata>
			<!--Zero or more repetitions:-->
			<met:metadata>
				<RemoteSiteSetting xmlns="http://soap.sforce.com/2006/04/metadata">
					<description>Used for Apex callout to mapping web service</description>
					<disableProtocolSecurity>false</disableProtocolSecurity>
					<isActive>true</isActive>
					<url>https://www.maptestsite.net/mapping1</url>
					<met:fullName>TestSutieMap</met:fullName>
				</RemoteSiteSetting>
			</met:metadata>
		</met:createMetadata>
	</soapenv:Body>
</soapenv:Envelope>


it fails with the error.
 
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
   <soapenv:Body>
      <soapenv:Fault>
         <faultcode>soapenv:Client</faultcode>
         <faultstring>Must specify a {http://www.w3.org/2001/XMLSchema-instance}type attribute value for the {http://soap.sforce.com/2006/04/metadata}metadata element</faultstring>
      </soapenv:Fault>
   </soapenv:Body>
</soapenv:Envelope>
I have tried to force xsi:type="RemoteSiteSetting" on the <met:metadata> tag, but that has not worked either.
 
I have a batch class that runs once a day to send me emails.
global class getCreatedLeadsSummary implements Database.Batchable<AggregateResult>, Database.Stateful {
    public string leadSummary;
    global Iterable<AggregateResult> start(Database.batchableContext info){
        // just instantiate the new iterable here and return
        return new AggregateResultIterable();
    }

    global void execute(Database.BatchableContext BC, List<AggregateResult> scope)
    {
        try
        {
            leadSummary = '<table bgcolor="silver" border="2" cellpadding="2"><tr><td><b>Lead Source</b></td><td><b>Count</b></td></tr>';
            for(AggregateResult ar: scope)
            {
                string src = (string) ar.get('LeadSource');
                Integer cnt = (Integer) ar.get('cnt');
                leadSummary = leadSummary + '<tr><td>' + src + '</td><td>'+ cnt.format() +'</td></tr>';
            }
            leadSummary = leadSummary + '</table>';            
        }
        catch(Exception ex)
        {
            System.Debug('Some Exception >'+ ex.getMessage());
        }
    }

    global void finish(Database.BatchableContext BC)
    {
        // Get the AsyncApexJob using JobId 
        AsyncApexJob a = [SELECT Id, Status, NumberOfErrors, JobItemsProcessed, TotalJobItems, CreatedBy.Email, ExtendedStatus   
                            FROM AsyncApexJob 
                            WHERE Id = :BC.getJobId()];  
                                    
        if(a.Status == 'Completed')           
            utilMail.sendNotificationMail('Lead Summary Job Result',a,leadSummary);   
        else
            utilMail.sendNotificationMail('Job Did not Complete!',a,'Failure');   
    }   

    global class AggregateResultIterable implements Iterable<AggregateResult> {
        global Iterator<AggregateResult> Iterator(){
            return new AggregateResultIterator();
       }
    }

    global class AggregateResultIterator implements Iterator<AggregateResult> {
        AggregateResult [] results {get;set;}
        Integer index {get; set;} 

        global AggregateResultIterator() {
            index = 0;
            String query = 'Select COUNT(Id) cnt, LeadSource From Lead WHERE CreatedDate = YESTERDAY GROUP BY LeadSource';
            results = Database.query(query);            
        } 
        
        global boolean hasNext(){ 
           return results != null && !results.isEmpty() && index < results.size(); 
        }    
        
        global AggregateResult next(){ 
            return results[index++];            
        }       
    }    
}

This is my test metohd I created.
 
static testmethod void testmethod1() {
            
            List<Lead> allLeads = new List<Lead>();
            for(integer i =0; i< 199; i++)
            {
                            Lead l = new Lead();
                            l.FirstName = 'TEST ' + i.format();
                            l.LastName = 'Lead';
                            l.Lease_Amount__c = 240;
                            l.LeadSource='2055 - Website';
                            l.Company = 'Testing Batch Jobs';   
                            l.Title = 'Dr';
                            l.Phone='5556667777';
                            allLeads.Add(l);
            }
       
       insert allLeads;

       Test.startTest();
       Database.executeBatch(new getCreatedLeadsSummary());     
       Test.stopTest();

       Integer i = [SELECT COUNT() FROM Lead WHERE CreatedDate=Today];
       System.Debug(i);       
       System.assertEquals(i, 199);
    }
After executing this test method, my coverage is at 56% (17/30) lines. So I found that the execute method is not being covered. How can I cover the execute method in my test class and attempt to reach 100% coverage?
 
I am looking at the Tooling API for an example on how to create a class. I took a a look at this example and I suspect this documentation is outdated.

https://developer.salesforce.com/docs/atlas.en-us.198.0.api_tooling.meta/api_tooling/intro_soap_overview.htm

If you read the page it says "These Examples use java". This is incorrect. Console.WriteLine is not present in Java. It is a feature of C#.
When you attempt to compile this code, there are further errors.
 
String classBody = "public class Messages {\n"
   + "public string SayHello() {\n"
   + " return 'Hello';\n" + "}\n"
   + "}";

// create an ApexClass object and set the body 
ApexClass apexClass = new ApexClass();
apexClass.Body = classBody;
ApexClass[] classes = { apexClass };

// call create() to add the class
SaveResult[] saveResults = sforce.create(classes);
for (int i = 0; i < saveResults.Length; i++)
   {
   if (saveResults[i].success)
      {
        Console.WriteLine("Successfully created Class: " +
         saveResults[i].id);
      }
   else
      {
         Console.WriteLine("Error: could not create Class ");
         Console.WriteLine("   The error reported was: " +
         saveResults[i].errors[0].message + "\n");
      }
   }

Is there a specific example on how to use tooling API?
 
I have an Queueable class.
Example:
public class AsyncExecutionExample implements Queueable {
    public void execute(QueueableContext context) {
        Account a = new Account(Name='Acme',Phone='(415) 555-1212');
        insert a;        
    }
}
I am calling this class from another class.
Example:
ID jobID = System.enqueueJob(new AsyncExecutionExample());

In my Queueable class, I plan to send an email to certain users in case the process falters or fails along the way. I need to get the ApexJobId of the running process for that. How can I get the ApexJobId from within the queueable class?
 
I have the following process setup in my sandbox environment.

1) Read Data From Local Sqlserver
2) Call Apex Rest Class
3) Create Contacts.
4) Create community Users from the contacts.

Currently I am reluctant to run the 4th step in the process as I don't want emails going out to these contacts upon user creation. How can I stop that from happening? I don't want to stop all outgoing emails from the sandbox, but is there some setting that will not send emails when a user gets created?
I have performance edition and I have created a custom profile. Now I wish to assign this custom profile to an existing user. When I edit a user, I am not able to change the profile for that user. When I go to the newly created profile, I can create new users on it, but not select existing users.

Also, is it possible for a user to be assigned multiple profiles in salesforce?

 
Hi,
  
    I want to deploy my changes to production from sandbox. Here is wat I am doing right now.
 1. I imported sandbox code in Eclipse IDE.
 2. Created some apex class and tested it on sandbox salesforce. (while saving I used right click -> save to server option)
 3. To deploy chnages to production (write click on file -> deploy to server)
 4. I entered user name, password and security token
 5.  Its givin me error for two class files which I never modified and those files exist on production server (some syntax error in those files) and I really can not modify those file


How I can deploy my changes in production. Can anyone please help me with this ? Any help in this regards will be appreciated.

Thanks,
Abhishek

I have three objects. Two standard and one custom.
The standard objects are: Account and Opportunity.
The custom object is an object called Billing_Profile__C.

AccountId is the common field in all three objects. I am able to write a SOQL query like this.

Select o.Name, o.Id, o.Competitor__c, o.Amount, o.AccountId From Opportunity o WHERE o.AccountId NOT IN (Select  b.Account__c From Billing_Profile__c b)


This gives me a list of all the opportunities that have been created on accounts that do not have a billing profile. I want to put this in a validation rule on the opportunity object so that my user is not able to create an opportunity for any account that does not have a billing profile.

Firstly, instead of my query that simply returns a list of opportunities, how do I get the count of billing profiles for an account on an opportunity.

Secondly, how can I use that information in a validation rule when the user is creating this opportunity.

I have attempted to write a validation using VLOOKUP function. This is the rule I wrote.

VLOOKUP(
$ObjectType.Billing_Profile__c.Fields.Account__c,
$ObjectType.Billing_Profile__c.Fields.Name,
AccountId) <> AccountId
I am not sure if this rule is working as expected. I am getting an error on every save, regardless of the data. How can I correct this situation? Is there some way to log the values for each of the parameters I am sending? Can I test my function in the execute anonymous window?