• richginpa
  • NEWBIE
  • 0 Points
  • Member since 2011

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 3
    Replies

Hi,

 

Hoping someone can assist with VERY basic question.

 

Trying to query my developer instance of Salesforce and store the data in a format so I can import into a local DB.  Having issues looping the data for all the fields as some appear to be object within an object.  For instance, I am querying OpportunityLineItems table fields Opportunity.Name, Opportunity.StageName, Pricebook.EntryName, etc...

 

 

Below is an example of the very basic code and the results.  How do I loop through the results so that all of the data is stored in an array that can then be imported into MySQL?

 

Any help is appreciated.

 

Sample Code:

try {

  $mySforceConnection = new SforceEnterpriseClient();
  $mySoapClient = $mySforceConnection->createConnection(SOAP_CLIENT_BASEDIR.'/enterprise.wsdl.xml');
  $mylogin = $mySforceConnection->login($USERNAME, $PASSWORD);

//Describe sObject
  // print_r($mySforceConnection->describeSObject('OpportunityLineItem'));

  $query = 'SELECT Opportunity.Name, Flight_Start_Date__c, Flight_End_Date__c, ListPrice, Impressions__c, UnitPrice, Quantity, Pricing_Model__c, PricebookEntry.Name, Opportunity.StageName FROM OpportunityLineItem';


  $queryResult = $mySforceConnection->query(($query));
  $records = $queryResult->records;

  foreach ($records as $record) {
  // $sObject = new sObject($record);
  // echo "Id= ".$sObject->Id;
  // echo "OpportunityName =" .$record->fields->Flight_Start_Date__c;
  // echo "Id = ".$sObject->ListPrice;

  print_r($record);
  print_r("<br>");
  }

/*
  echo "***** Login Info*****\n";
  print_r($mylogin);
*/



} catch (Exception $e) {
  echo $mySforceConnection->getLastRequest();
  echo $e->faultstring;
}

 

Results:

tdClass Object ( [Id] => [Flight_End_Date__c] => 2012-01-31 [Flight_Start_Date__c] => 2011-12-01 [Impressions__c] => 4000 [ListPrice] => 0 [Opportunity] => stdClass Object ( [Id] => [Name] => Test Opportunity 3 [StageName] => IO Live ) [PricebookEntry] => stdClass Object ( [Id] => [Name] => Test Product 1 ) [Pricing_Model__c] => CPM [Quantity] => 2 [UnitPrice] => 5 )
stdClass Object ( [Id] => [Flight_End_Date__c] => 2011-05-15 [Flight_Start_Date__c] => 2011-03-01 [Impressions__c] => 500000 [ListPrice] => 0 [Opportunity] => stdClass Object ( [Id] => [Name] => Test Opportunity 5 [StageName] => Active Interest ) [PricebookEntry] => stdClass Object ( [Id] => [Name] => Test Product 2 ) [Pricing_Model__c] => CPM [Quantity] => 1 [UnitPrice] => 15 )
stdClass Object ( [Id] => [Flight_End_Date__c] => 2011-12-31 [Flight_Start_Date__c] => 2011-02-01 [Impressions__c] => 2000000 [ListPrice] => 0 [Opportunity] => stdClass Object ( [Id] => [Name] => Test Opportunity 4 [StageName] => Active Interest ) [PricebookEntry] => stdClass Object ( [Id] => [Name] => Test Product ) [Pricing_Model__c] => CPM [Quantity] => 1 [UnitPrice] => 10 )

 

 

I have a custom object called headings__c that is related to Leads.  When I convert the lead, I need all of those heading records to be updated so that they show up under Accounts/Opportunties.

 

I've already created the lookup fields for those objects, but I don't know how to ensure those lookup fields are populated during lead conversion. 

 

I did find a trigger on the appexchange that I tried to use, but it will only move over one record and I need multiple heading records to move to the account/opportunity.

 

Does anyone know of any way to do this?  Is there something on the appexchange or does anyone have code that they've used?  Any ideas on how to make the code below work?

 

Here is the code I tried (but only copies first record from headings related list over):

 

trigger UpdateCustomeObject_Trigger on Lead (before update) {

for (Integer i = 0; i < Trigger.new.size(); i++){
    if (Trigger.new[i].IsConverted == true && Trigger.old[i].isConverted == false){
    Set<Id> leadIds = new Set<Id>();
    for (Lead lead : Trigger.new) {
        leadIds.add(lead.Id);
    }
   
    Map<Id, CustomObject__c> entries = new Map<Id, CustomObject__c>([select Contact__c, Opportunity__c, Account__c, Lead__c from CustomObject__c where lead__c in :leadIds]);       
    if(!Trigger.new.isEmpty()) {
    for (Lead lead : Trigger.new)  {
    for (CustomObject__c CustomObject : entries.values()) {
    if (CustomObject.Lead__c == lead.Id) {
        CustomObject.contact__c = lead.ConvertedContactId;
        CustomObject.opportunity__c = lead.ConvertedOpportunityId;
        CustomObject.account__c = lead.ConvertedAccountId;
        update CustomObject;
        break;
    }
    }
    }
    }
    }
    }
}

Hello!

Does anyone know if Salesforce has a better tool to use with regards revenue recognition other than the Product Schedule option?

The Product Schedule option is clever but not nearly as flexible as it needs to be.  (atleast from what I know)

Pre Salesforce we used a simple excel spreadsheet to forecast monthly revenues from our pipeline. 

So essentially what we need is to set automatic schedules based on formula rates and start dates rather than having to manually edit each record’s start date and rate.

Any Ideas?  Here is an example of what we need and how robust it needs to be

Total Project                      Daily Revenue                                   Formula Start Date      Month 1     Month 2    Momth 3     Momth 4

Revenue                                     Recognition Rate                             

$100,000                                            $2,000                                                                August 31                            2000       60,000            38,000

$300,000                                           $4,000                                                                 August 30                            8000       120,000          120,000         52,000

 

We have all the formula fields needed but we don’t know how to tell Salesforce to use them for forecasting or revenue scheduling. 

Thank you for your help!!!!!

 

Harry