• msimonds
  • NEWBIE
  • 172 Points
  • Member since 2006

  • Chatter
    Feed
  • 7
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 48
    Questions
  • 190
    Replies

Is there a way utilizing the PHP API to read an objects schema and list its meta data.

 

I would like to be able to pass an object name and see all of the field names and their types and even better if the type happens to be a picklist to determine what the available options are.

 

Can someone point me in the right direction or provide a sample?

 

Hi,

 

I manage a website that has a restricted area where you need to sign-in to get the access to download some files.

I would like to use the Leads (SalesForce Object) to store the users that can access this area. So basically, in PHP i would query the salesforce database each time a user would log in, to check his password and email. If this query finds a user, then it would create a session for this private area.

The reason i would use the SalesForce Database instead of a mysql on localhost is to avoid duplication of data (on our website and on SalesForce, because these leads are also our users). So the website's authentication would rely on the SalesForce service to work.

 

But i tryied a small test (Query sample) and when i benchmark (with ab command) i get like 0.94 req/seconds, which is a bit slow for us (at least 5 time slower that our current login page).

 

Right now our login page is accessed about 700 times per day. So i'm wondering if it's a good practice to rely on SalesForce for this kind of feature on a website using the PHP toolkit? Is there a limit of queries that one site can do to the SalesForce API on a daily basis? Is this kind of usage of the SalesForce API is even allowed?

 

Thanks in advance. 

 

Edit: Added some clarifications 

Message Edited by jdesrosiers on 01-13-2010 01:48 PM

I was wondering if anyone should shed some light on a problem I am having. I wrote a script that replicates the information from SalesForce into an Oracle DB. The wierd thing is the Oracle row count is 1 higher then SalesForce. I am using a QueryAll call and can't figure out why there is 1 additional in Account and Contact.

 

I am running a script that is checking the Id's against Sforce, in the meantime I would love it if someone could shed some light on this. I don't think it is a duplicate insert.

 

 

Hi All,

I am looking for a PHP outbound messaging listener sample code. If someone can point me in the right direction. I would appreciate it very much.
  • August 22, 2008
  • Like
  • 0

Greetings!!  

 

I am looking to anyone that has successfully created an automated system that allows for the creation of free chatter users into Salesforce from AD or Oracle via the API.

 

I have been searching the API documentation and was wondering if there was any way that I could do the following:

 

1) Create member groups via the API

2) Create users as chatter free users and assign them to these groups via the API

3) automatically create groups via the API 

4) deactivate users via the API?

 

 

If anyone has created anything automated I would like to start a quick discussion with you based upon what you may have done

 

I would appreciate any feedback on this very generic post

 

TIA!!

~MIke

I have been trying (unsuccessfully)  to update a pricebookentry id (product from one pricebook) on line items using the data loader.  I tried update, but that field is not updateable. I also tried upsert, but i receive an error > Unable to create/update fields: PricebookEntryId. Please check the security settings of this field and verify that it is read/write for your profile.

 

 

Am I doing something wrong or is there another, better way to do this.....

 

 

Thanks in Advance!! I hope this makes sense

 

 

~mike

In the past I was hitting the govenor limit of 21 quieres and have been able to work through that, but after I retooled my trigger and class, I am getting the same error.

 

I have this trigger:

 

trigger UpdateOppChatterFeed on OpportunityLineItem (after update) 
{
      integer size = Trigger.new.size();

      for(integer i = 0; i < size; i++)
      {
            Chatter_Feed cf = new Chatter_Feed();
            cf.updateChatter(Trigger.new[i]);
      }
}

 

 

which calls this class:

 

 

public with sharing class Chatter_Feed 
{

	public void updateChatter(OpportunityLineItem  oli)
	{
            List<FeedPost> posts = new List<FeedPost>();
            List<Opportunity> oppList = new List<Opportunity>();
            List<Opportunity> OppsToBeUpdated = new List<Opportunity>();
            
            oppList = [select Id
            		   from Opportunity 
            		   where id = : oli.OpportunityId];
            		   
						
            id idToUpdate;   
            for(Opportunity opp : oppList)
            {
                  idToUpdate = opp.Id;			
            }
	    System.debug('MIKES OPP ID IS '  + idToUpdate);
            //update OppsToBeUpdated;
            List<OpportunityFeed> opportunityFeedPosts = [SELECT Id, Type, FeedPost.Body
                                                            From OpportunityFeed
                                                            Where ParentID = :idToUpdate
                                                            ORDER BY CreatedDate DESC];
                                                            
                                                            
            String bodyText = 'This is the body ';                                                
            FeedPost opportunityPost = new Feedpost();
            opportunityPost.Type = 'LinkPost';
            opportunityPost.Title = 'THIS IS THE TITLE WILL';
            opportunityPost.Body = bodyText;
            String id = String.valueOf(oli.id).substring(0,15);
            opportunityPost.LinkURL = 'https://cs1.salesforce.com/'+id;
            opportunityPost.ParentID = idToUpdate;
            posts.add(opportunityPost);
            	
            //}                                        
                                                            
            insert posts;                                              

      }
 
  
}

 

 

The only for() loop that I have is in the class and does not query any sObjects.

 

This trigger/class works when I edit 1 OpportunityLineItem, but our Org has an option to edit all and in some cases, there are more than 21 line items on an Opportunity.

 

Why is this failing?  Can someone please give me some guidance here?

 

 

I would appreciate any feedback

 

Thanks!!

 

~Mike

I am trying to get this trigger to update a new, test field (TEXT FIELD, 18 bytes) with the ID of the Opportunity Line Item and the error that I am receiving is Id not specified in the update call.

 

 

 

 

trigger New_Feed_Update on OpportunityLineItem (after update) 
{
	//setup a feedpost array
	List<FeedPost> posts = new List<FeedPost>();
	
	//Create a new, empty list to add the Socket ID's to update
	List<OpportunityLineItem> oppGetIds = new List<OpportunityLineItem>();
	//mike_test__c
	for(OpportunityLineItem oppids : Trigger.new)
	{
		OpportunityLineItem Opp = new OpportunityLineItem();
		Opp.will_test__c = oppids.id;
		OppGetIds.add(Opp);
	}
    Database.update(OppGetIds);



}

 

 

I thought that the ID was already identified in the update call

 

Can someone please help me fix this trigger

I am in need of assistance, any help would be appreciated;


We have a trigger that updates information on Chatter feeds when a product is chaged on an Opportunity Line Item.

 

We are now receiving exception errors due to the governing limit on queries. 

 

The code:

 

trigger LineItemToOpportunityFeedUpdate on OpportunityLineItem (after update) {
    List<FeedPost> posts = new List<FeedPost>();
    Set<Id> pbeIds = new Set<Id>();
    
    for(OpportunityLineItem newOLI : Trigger.new) {
        OpportunityLineItem oldOLI = Trigger.oldMap.get (newOLI.id);
        //System.debug('New: '+newOLI.Part_Outcome__c+' Old: '+oldOLI.Part_Outcome__c);
        
        if(newOLI.Part_Outcome__c != oldOLI.Part_Outcome__c) {
            
            List<OpportunityFeed> opportunityFeedPosts = [SELECT Id, Type, FeedPost.Body
                                                            From OpportunityFeed
                                                            Where ParentID = :newOLI.OpportunityID
                                                            ORDER BY CreatedDate DESC];
                       
            pbeIds.add(newOLI.PricebookEntryId);
            Map<Id, PricebookEntry> entries = new Map<Id, PricebookEntry>([select Product2.ProductCode from PricebookEntry where id in :pbeIds]);

            pbeIds.add(newOLI.opportunityid);
            Map<Id, Opportunity> Opp = new Map<Id, Opportunity>([select Account.Name, Account.ID from Opportunity where id in :pbeIds]);
                                                                            
            //String bodyText = 'Got here....'+Opp.get(newOLI.OpportunityId).Account.Name+'';                                                               
            String bodyText = 'has updated the '+entries.get(newOLI.Pricebookentryid).Product2.ProductCode+' from '+oldOLI.Part_Outcome__c+' to '+newOLI.Part_Outcome__c+' at '+opp.get(newOLI.OpportunityId).Account.Name+'';    
            
            if(opportunityFeedPosts.size() == 0 || opportunityFeedPosts[0].FeedPost.Body != bodyText) {
                //System.debug('OpportunityFeed Posts: '+opportunityFeedPosts[0]);

               
                FeedPost opportunityPost = new Feedpost();
                opportunityPost.Type = 'LinkPost';
                opportunityPost.Title = ''+entries.get(newOLI.Pricebookentryid).Product2.ProductCode+' socket details';
                opportunityPost.Body = bodyText;
                String id = String.valueOf(newOLI.Id).substring(0,15);
                opportunityPost.LinkURL = 'https://na2.salesforce.com/'+id;
                opportunityPost.ParentID = newOLI.opportunityid;
                posts.add(opportunityPost);
                System.Debug('Got Here but did not post');
                
                /*@Version 1.3 - removed because I could not get it to display one feedpost with 2 links in the Opportunity Post Title
                FeedPost opportunityPost2 = new FeedPost ();
                opportunityPost2.Type = 'LinkPost';
                opportunityPost2.Title = 'Account Details';
                opportunityPost2.Body = bodyText;
                String id2 = String.valueOf(opp.get(newOLI.OpportunityId).Account.Id).substring(0,15);
                opportunityPost2.LinkURL = 'https://na2.salesforce.com/'+id2;
                opportunityPost2.ParentID = newOLI.opportunityid;
                posts.add(opportunityPost2);
                system.debug('got here and it should have posted twice');
                */
                }
            }
         
        //This section will trigger a feed update to the Opportunity if the Max Potential of any given socket is increased by $1,000,000           
        if(newOLI.Max_Potential__c >= oldOLI.Max_Potential__c + 1000000){
            
            List<OpportunityFeed> opportunityFeedPosts = [Select Id, Type, FeedPost.Body
                                                            From OpportunityFeed
                                                            Where ParentId = :newOLI.OpportunityID
                                                            ORDER BY CreatedDate DESC];
        
            //@1.1 Code that will traverse the Pricebookentry ID and pull back the part number. We could not directly access the part number from the opportunitylineitem.productcode field
            pbeIds.add(newOLI.PricebookEntryId);    
            Map<Id, PricebookEntry> entries = new Map<Id, PricebookEntry>([select Product2.ProductCode from PricebookEntry 
                                                                            where id in :pbeIds]);
                                                                            
            //Traverse the opportunity object to return the Account detail and get the account name                                                                
            pbeIds.add(newOLI.opportunityid);
            Map<Id, Opportunity> Opp = new Map<Id, Opportunity>([select Account.Name, Account.ID from Opportunity where id in :pbeIds]);                                                                
            
            //Round the dollar values to whole numbers
            decimal NewWholeMaxPotential = newOLI.Max_Potential__c;
            decimal maxpotentialdifference = newOLI.Max_Potential__c/1.0 - oldOLI.Max_Potential__c/1.0;                                                             
            
            String bodyText = 'has increased the Max Potential of the '+entries.get(newOLI.Pricebookentryid).Product2.ProductCode+' by $'+maxpotentialdifference+' at '+opp.get(newOLI.OpportunityId).Account.Name+'';
                                                                                                
        if(opportunityFeedPosts.size() == 0 || opportunityFeedPosts[0].FeedPost.Body != bodyText) {
                //System.debug('OpportunityFeed Posts: '+opportunityFeedPosts[0]);
                
                FeedPost opportunityPost = new FeedPost ();
                opportunityPost.Type = 'LinkPost';
                opportunityPost.Title = ''+entries.get(newOLI.Pricebookentryid).Product2.ProductCode+' socket details';
                opportunityPost.Body = bodyText;
                String id = String.valueOf(newOLI.id).substring(0,15);
                opportunityPost.LinkURL = 'https://na2.salesforce.com/'+id;
                opportunityPost.ParentID = newOLI.opportunityid;
                posts.add(opportunityPost);
                }    
            }
          
        //This section will update the Chatter feed when the PS3 checkbox is marked true
        //if(newOLI.Socket_Strategy_Required__c == true && oldOLI.Socket_Strategy_Required__C == false){
        if(newOLI.Socket_Strategy_Required__c == true && oldOLI.Socket_Strategy_Required__c == false){  
            List<OpportunityFeed> opportunityFeedPosts = [Select Id, Type, FeedPost.Body
                                                            From OpportunityFeed
                                                            Where ParentId = :newOLI.OpportunityID
                                                            ORDER BY CreatedDate DESC];
                                                      
            pbeIds.add(newOLI.PricebookEntryId);

            Map<Id, PricebookEntry> entries = new Map<Id, PricebookEntry>([select Product2.ProductCode from PricebookEntry 
                                                                            where id in :pbeIds]);
            
            
            //OppOwnerFirstName = get.FirstName;
            //OppOwnerLastName = get.LastName;
                                                                            
            String bodyText = ' has required a PS3 for the '+entries.get(newOLI.Pricebookentryid).Product2.ProductCode+'.';                                             
            //String bodyText = ''+opportunity.OwnerId+' has required a PS3 for the '+entries.get(newOLI.Pricebookentryid).Product2.ProductCode+'.';
            
        if(opportunityFeedPosts.size() == 0 || opportunityFeedPosts[0].FeedPost.Body != bodyText) {
                //System.debug('OpportunityFeed Posts: '+opportunityFeedPosts[0]);
                
                FeedPost opportunityPost = new FeedPost ();
                opportunityPost.Type = 'LinkPost';
                opportunityPost.Title = 'Click here for the PS3';
                opportunityPost.Body = bodyText;
                String id = String.valueOf(newOLI.id).substring(0,15);
                opportunityPost.LinkURL = 'https://na2.salesforce.com'+newOLI.PS3_Link__c+'';
                opportunityPost.ParentID = newOLI.opportunityid;
                posts.add(opportunityPost);
                }    
            }*/         
        }
        insert posts;
}

 

Error:

 

Trigger.LineItemToOpportunityFeedUpdate: line 40, column 65

 

 

That line of code is:

 

Map<Id, Opportunity> Opp = new Map<Id, Opportunity>([select Account.Name, Account.ID from Opportunity where id in :pbeIds]);

 I know that the query should be outside the for loop and please understand that I am still fairly new to APEX. 

 

Where can I place these queries and still have this trigger work as designed.

 

Thanks to anyone in advance!!

 

~Mike

Along with a co-worker, we are trying to write a trigger to update the chatter on our Opportunities with the ProductCode from the line item. We are not having much success. We do have a working trigger

 

 

trigger LineItemToOpportunityFeedUpdate on OpportunityLineItem (after update) {
    List<FeedPost> posts = new List<FeedPost>();
    
    for(OpportunityLineItem newOLI : Trigger.new) {
        OpportunityLineItem oldOLI = Trigger.oldMap.get (newOLI.id);
        System.debug('New: '+newOLI.Part_Outcome__c+' Old: '+oldOLI.Part_Outcome__c);
        
        if(newOLI.Part_Outcome__c != oldOLI.Part_Outcome__c) {
            
            List<OpportunityFeed> opportunityFeedPosts = [SELECT Id, Type, FeedPost.Body
                                                            From OpportunityFeed
                                                            Where ParentID = :newOLI.OpportunityID
                                                            ORDER BY CreatedDate DESC];
            
                                                                     
            String bodyText = 'Socket outcome was changed from '+oldOLI.Part_Outcome__c+' to '+newOLI.Part_Outcome__c+'.';     
            
            //I would put in the '+lineitem.UnitPrice+' command before the .'; in line 19.
            
            if(opportunityFeedPosts.size() == 0 || opportunityFeedPosts[0].FeedPost.Body != bodyText) {
                //System.debug('OpportunityFeed Posts: '+opportunityFeedPosts[0]);
                
                FeedPost opportunityPost = new FeedPost ();
                opportunityPost.Type = 'LinkPost';
                opportunityPost.Title = 'Socket XYZ has been set to '+newOLI.Part_Outcome__c+'';
                opportunityPost.Body = bodyText;
                String id = String.valueOf(newOLI.id).substring(0,15);
                opportunityPost.LinkURL = 'https://cs2.salesforce.com/'+id;
                opportunityPost.ParentID = newOLI.opportunityid;
                posts.add(opportunityPost);
               }
            }
        }
        insert posts;
}

 

 

If you notice, we have a custom field called the part_outcome__c , which is updating, but we are trying to get the Product code and when we attempt to get the Product Code or part number on the chatter area;

 

Currently chatter using the part_outcome__c looks like this:

 

 

Can someone please help me correct this trigger so we can get the productcode on the chatter. Just for Clarification, our socket = ProductCode

 

 

I was not sure where to post this so I am sorry if this is the wrong area.  I need some ideas on what the best solution would be.

 

We want to alert a user when they view an opportunity if the CloseDate is less than today and do not know the best way to go about it.

 

Could someone please give me an idea or an example of where this is done.

 

I hope this makes sense

 

~Mike 

I followed this tutorial and was wondering if there are anymore examples that could expand on the callouts.  I was wondering if there was a way to send out the actual ID and Name of the new account that is created.  The trigger:

 

 

//This is the trigger from the tutorial that sends calls the APEX class AccountUpdater //as you can see it sends the ID and the Name of the account trigger descriptionUpdater on Account (after insert) { System.debug('Making future call to update account'); for (Account acc : Trigger.New) { //Call future method to update account //with data from external server. //This is a async calls, it returns right away, after //enqueuing the request. AccountUpdater.updateAccount(acc.Id, acc.Name); } }

 

This sends the ID and NAME of the account to the AccountUpdater class

 

The class creates the web service call to a local server I have and it works perfectly.

 

 

 

//This is the class from the tutorial that processes the ID and Name //and set's up the http request public class AccountUpdater { //Future annotation to mark the method as async. @Future(callout=true) public static void updateAccount(String id, String name) { //construct an HTTP request HttpRequest req = new HttpRequest(); req.setEndpoint('http://mapsdev.maxim-ic.com/data.php'); req.setMethod('GET'); //send the request Http http = new Http(); HttpResponse res = http.send(req); //check the response if (res.getStatusCode() == 200) { //update account Account acc = new Account(Id=id); acc.Description = res.getBody(); update acc; } else { System.debug('Callout failed: ' + res); } } }

 

 

 

 

 

What I was wondering if there is a way to actually send out the ID and/or name of the account that was created in the http request method in APEX

 

 

Thanks and I hope this makes sense!!

 

~Mike

 

 

I have two triggers:

  

 trigger CleanDRLineItem on Opportunity_Tracker_Products__c (before delete) {

    for (Integer i = 0; i < Trigger.old.size(); i++) {

        try {

            //replace OppLineId__c with actual refference name.

            List<Design_Registration__c> oDRs = [select id, DP_reg_id__c, OwnerID, Inactive__c from Design_Registration__c where Opp_tracker_line_ID__c = :trigger.old[i].id];

            for (Design_registration__c dr: oDRs)

            {

             dr.OwnerId = '00540000000oJjiAAE';

             dr.Inactive__c = true;

             string old_dr_number = dr.DP_reg_id__c;

             dr.DP_reg_id__c = 'IN-' + old_dr_number;

             update dr;

            }

            

            

        } catch (System.QueryException ex) {

            //Do Nothing - There must not have been any to delete.

        }

    }

}

 

 and 

 

 trigger CleanOppTrackerLineItem on Opportunity_Trackers__c (before delete) {

    for (Integer i = 0; i < Trigger.old.size(); i++) {

        

            //replace OppLineId__c with actual refference name.

            Opportunity_Tracker_Products__c[] oTRs = [select id from Opportunity_Tracker_Products__c where Opportunity_Tracker__c = :trigger.old[i].id];

            //System.Debug('Removing the following: '+oTRs.id);

            delete oTRs;

        

    }

}

  Now I am receiving errors and i do not understand why they are getting them, Here is the text of one of the emails I am receiving:

 

 

Apex script unhandled trigger exception by user/organization: 00540000000yFVO/00D300000006AVjCleanOppTrackerLineItem: execution of BeforeDeletecaused by: System.DmlException: Delete failed. First exception on row 0 with id a0B4000000282XlEAI; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, CleanDRLineItem: execution of BeforeDeletecaused by: System.Exception: Too many SOQL queries: 21Trigger.CleanDRLineItem: line 5, column 49: []Trigger.CleanOppTrackerLineItem: line 7, column 13

 

 

 

 I would appreciate any feedback and help, 

 

Thanks,

Mike Simonds 

 

 

 

Message Edited by msimonds on 01-06-2010 07:40 PM
I wanted to understand the APEX web services a little more and I am trying to find some answers. I was hoping someone here could see if I am on the right track.

the example for APEX web services and callouts, http://wiki.developerforce.com/index.php/Apex_Web_Services_and_Callouts, shows an example of this but I wanted to ask a few questions about the callout functionality.

Could this senario take place?

1) Opportunity Trigger:  Write an after update or before update trigger on the opporntunity object that would call a APEX class

2) Opportunity APEX class - could be designed and coded to send the data from that updated record from the trigger to an external web service or callout

3) External web service could be a script that parses the data and then processes it (sticking it into a database, updating a spread sheet, etc...)


I wanted to know if I am understanding this correctly?


Thanks!!

~Mike

Is there a way to create a NDA in Salesforce that would require a user to check the box stating that they read the NDA agreement and if they did not, log them out.

 

If they do click the checkbox, then set a custom field on the user table that shows that they already read or checked it?  

 

I doubt it, but wanted to find out if anyone has done something similiar

 

 

Thanks,

 

~Mike 

I have a custom object called opportunity_tracker_products__c that is associated to another custom object called design_registration__c.

 

Currently there is a trigger in place that will delete any DR's that have an opp_tracker_product.id on them.

 

Here is the trigger:

 

trigger CleanDRLineItem on Opportunity_Tracker_Products__c (before delete) { for (Integer i = 0; i < Trigger.old.size(); i++) { try { //replace OppLineId__c with actual refference name. Design_Registration__c[] oDRs = [select id from Design_Registration__c where Opp_tracker_line_ID__c = :trigger.old[i].id]; delete oDRs; } catch (System.QueryException ex) { //Do Nothing - There must not have been any to delete. } }}

 What I need to do is to not delete the records but update a boolean field and set the OwnerId to a specific user on the design_registration__c 

 

this is what i have so far:

 

 

trigger CleanDRLineItem on Opportunity_Tracker_Products__c (before delete) { List<Design_registration__c> updateDRs = [select dr.id, dr.Inactive__c, OwnerId from Design_Registration__c dr where Opp_tracker_line_ID__c IN :Trigger.new FOR UPDATE]; for(Design_Registration__c dr: updateDRs) { dr.Inactive__c = true; dr.OwnerId = '00540000000oJjiAAE'; } update updateDRs;}

 

 

 

 but I am getting an error 

 

 

Save error: Invalid bind expression type of SOBJECT:Opportunity_Tracker_Products__c for column of type String

 

 I am new to triggers and APEX (as I have stated in prior messages) and need help please.  I know that I am visiably doing something wrong, I would appreciate any feedback or ideas 

 

 

TIA  

 

~Mike 

 

 

ALL,

 

I am not new to developing on Salesforce using the API and PHP, but  I am new to APEX so please bare with me.

 

I wrote this simple trigger that deletes records on a custom object when another custom object record is deleted.

 

 

trigger CleanOppTrackerLineItem on Opportunity_Trackers__c (before delete) { for (Integer i = 0; i < Trigger.old.size(); i++) { try { //Get all the line items to delete when the parent is removed Opportunity_Tracker_Products__c[] oTRs = [select id from Opportunity_Tracker_Products__c where Opportunity_Tracker__c = :trigger.old[i].id]; delete oTRs; } catch (System.QueryException ex) { //Do Nothing - There must not have been any to delete. } } }

 

 I was trying to go over some of the examples so I can test this and I am kind of lost. 

 

 

Do I need to write a custom APEX class to test this trigger because I need to get it into production as fast as possible.

 

We have run some tests in our sandbox on the trigger and it works perfectly.

 

Can someone please help me with what is the simplest way to create a test case and get it tested for this very simple trigger

 

 

I would appreciate it

 

~Mike

 

We have experienced a change in the SFDC environment with respect to accounts and opportunities. Currently and in the past, we have a PHP process which transfers accounts to various owners based on an outside system we have for master accounts.

In the past, the opportunities that were active would automatically move over with the change via the API. Now, they are not. Is this a change in the way that SFDC handles these ownership changes? Is there anything we can do to mitigate it? It’s causing a lot of data integrity issues on our end.

We think the change occurred around Mindfully to Mid-August. However, it took us until September to realize that it was happening though, after a bunch of records weren't being swapped over

I cannot find anything in the API documentation about this.  This is really urgent and is causing us to have to fix these issues manually when it has never happened in the past.

I know that i asked this before and wanted to see if this is something that can be done now. 

 

Can a trigger (after delete, after insert, after update) kick off a workflow and/or and outbound message.

 

 

Thanks,

Mike Simonds

I was wondering if anyone has come across this API return message:

 

 

[message] => field integrity exception: PricebookEntryId, unknown (versions 3.0 and higher must specify pricebook entry id; others must specify product id)

 

 I have not seen this, but I do understand what is asking. The reason why I am posting this is because:

 

How are we supposed to know what the version is when we are creating an opportunity line item?

 

If somone could please share that with me, I will be greatful

 

 

Thanks,

~Mike 

 

We have a report that is generated in Salesforce and would like to know if it is possible to access or download the report via the API?

I doubt it, but I thought that I would ask anyway

Thanks
~Mike
Can we modify the clone functionality on an object to limit what what is cloned?

Example:

If we have an opportunity line item that has 4 products in a "won"status and we clone it, is there a way to keep the "status" field from being copied as "Won" but rather be set to the default field value of "Open".


Thanks,
Mike
1) Can they be triggered when a new record is inserted into an object, whether it is custom or not

and


2) can they be triggered when record is deleted on an object, whether it is custom or not

I would appreciate any insight to this

Thanks,
Mike
Nick,

I wanted to bring this up in the public forum because I am a little worried about the future of the toolkit.  I know that you have spent countless hours developing it and probably not all work time.  I am however worried about the future development and changes to the API.  I know that there is not a PHP session at DF 08' this year and when you told me that is when I started to worry.  I understand that Salesforce is moving forward with the technology that is available on your platform, but there a lot of developers that depend on the toolkit.  I understand that the toolkit is somewhat open source, but there has been no discussion on it's future development. 

I would like to get other developers feedback on this and your input too, it would greatly appreciated.

Thanks,
Mike Simonds
Senior Developer
Maxim Int Products
The other day I released an Oracle version of this script and now I have completed the MySQL version.  You can check it out here!


Thanks,
Mike

Is there a way utilizing the PHP API to read an objects schema and list its meta data.

 

I would like to be able to pass an object name and see all of the field names and their types and even better if the type happens to be a picklist to determine what the available options are.

 

Can someone point me in the right direction or provide a sample?

 

Hi,

 

What I need to do is so simple in theory, otherwise I would not be writing this post!

 

The point is that I have an HTML registration form, where the action parameter triggers a PHP script which already executes some stuff. What I need to do, is additionally create a new load in the salesforce system with this form information, maybe writing some PHP code at the end of this script to generate an XML file for example, send this file to salesforce and create the lead. That's all.

 

I don't have any problem to write the PHP code, but I don't know the procedure to do the integration with the salesforce system, could you help me with that?

 

Thanks a lot!

 

 

Hi,


I know there are a few threads on this already - believe me I have been reading them. I am using the latest version of the PHP Toolkit I could find (13.1) and trying to I am attempting to access the Sandbox.

 

Here's what I have done:

 

  • Got a fresh enterprise and partner wsdl from the sandbox site and tried them both.
  • Made sure to include the sandbox name or whatever it's called at the end of the username, so email@address.com.thing
  • Refreshed the security token and appended that to the password.
  • Tried to use the WSDLs which come with the Toolkit instead, changing the endpoint to be test.salesforce.com/etc..

I noticed the endpoint in the Toolkit included "13" - since the toolkit is version 13, is there a more up to date version of the Toolkit to go with the latest API since the endpoint in the fresh WSDLs from my Sandbox is uses "20" instead of "13"?


All I'm doing so far is...

 

$sf = new SforceEnterpriseClient();
$sf->createConnection(WSDL_PATH);
$sf->login(array('username' => USERNAME, 'password' => PASSWORD . '.' . TOKEN));

 

And I get an error response of...

 

INVALID_LOGIN: Invalid username, password, security token; or user locked out.

 

I can login ok if I bypass the Toolkit...

 

$sf = new SoapClient(WSDL_PATH);
$result = $sf->login(array('username' => USERNAME, 'password' => PASSWORD . '.' . TOKEN));

 

But the only problem then is obviously spending the time working out how to do what I need to do (create leads) without the Toolkit's helper methods, so I'd obviously rather rather use the Toolkit if I can.


Any advice would be gratefully received!

 

EDIT: forgot to mention that I have used ini_set("soap.wsdl_cache_enabled", "0"); too but that didn't help.

  • October 21, 2010
  • Like
  • 0

Hi all,

Very new to Saleforce API here. As a first step I'm trying to connect to salesforce using a connection string as it's done in php. I have found some sample codes, but there are references to files that I don't have. I assume they exist somewhere on the developmerforce, but I can't find them. Would you be able to let me know where?

Thanks.

Sia44

  • October 20, 2010
  • Like
  • 0

How can I get Query More to return a result set in XML rather than arrary of objects? I am using PHP.

Hi there,

 

I would like to know how can get the user information (like the Saleforce userid email address) using php?? Thanks!

  • September 17, 2010
  • Like
  • 0

i have this error. and i cant solve it for now. im using a php toolkit 11. and xampp.

 

Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: Couldn't find <definitions> in 'C:/xampp/htdocs/phptoolkit/soapclient/partner.wsdl.xml' in C:\xampp\htdocs\phptoolkit\soapclient\SforceBaseClient.php:121 Stack trace: #0 C:\xampp\htdocs\phptoolkit\soapclient\SforceBaseClient.php(121): SoapClient->SoapClient('C:/xampp/htdocs...', Array) #1 C:\xampp\htdocs\phptoolkit\samples\integration.php(17): SforceBaseClient->createConnection('C:/xampp/htdocs...') #2 {main} thrown in C:\xampp\htdocs\phptoolkit\soapclient\SforceBaseClient.php on line 121

 

 

please help me.. tnx :)

  • September 14, 2010
  • Like
  • 0

Hi

I am using following script to send data into the SF. This is working properly for me but the script does not update Google Lead Tracking. What can be the reason? Please help...

 

<?php
//do quality checks on the incoming data here.

//then bundle the request and send it to Salesforce.com
$req  = "&lead_source=". urlencode($_REQUEST["leadSource"]);
$req .= "&first_name=" . urlencode($_REQUEST["firstName"]);
$req .= "&last_name=" . urlencode($_REQUEST["lastName"]);
$req .= "&title=" . urlencode($_REQUEST["title"]);
$req .= "&company=" . urlencode($_REQUEST["company"]);
$req .= "&email=" . urlencode($_REQUEST["email"]);
$req .= "&phone=" . urlencode($_REQUEST["phone"]);
$req .= "&street=" . urlencode($_REQUEST["street"]);
$req .= "&city=" . urlencode($_REQUEST["city"]);
$req .= "&state=" . urlencode($_REQUEST["state"]);
$req .= "&zip=" . urlencode($_REQUEST["zip"]);
$req .= "&debug=" . urlencode("0");
$req .= "&oid=" . urlencode("<Your Salesforce Org Id here>");
$req .= "&retURL=" . urlencode("<Your return url here>");
$req .= "&debugEmail=" . urlencode("<email for debugging>");

$header  = "POST /servlet/servlet.WebToLead?encoding=UTF-8 HTTP/1.0\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Host: www.salesforce.com\r\n";
$header .= "Content-Length: " . strlen($req) . "\r\n\r\n";
$fp = fsockopen ('www.salesforce.com', 80, $errno, $errstr, 30);
if (!$fp) {
echo "No connection made";
} else {
fputs ($fp, $header . $req);
while (!feof($fp)) {
$res = fgets ($fp, 1024);
echo $res;
}
}
fclose($fp);
?>

 

I have been tasked with getting this up and running and haven't done anything quite this involved yet.  On the salesforce side in particular  I am not sure what  I need in the http/php class to get the login to function.

 

Any thoughts on where to go from that? 

 

thank you,

 

 

  • June 29, 2010
  • Like
  • 0

In the past I was hitting the govenor limit of 21 quieres and have been able to work through that, but after I retooled my trigger and class, I am getting the same error.

 

I have this trigger:

 

trigger UpdateOppChatterFeed on OpportunityLineItem (after update) 
{
      integer size = Trigger.new.size();

      for(integer i = 0; i < size; i++)
      {
            Chatter_Feed cf = new Chatter_Feed();
            cf.updateChatter(Trigger.new[i]);
      }
}

 

 

which calls this class:

 

 

public with sharing class Chatter_Feed 
{

	public void updateChatter(OpportunityLineItem  oli)
	{
            List<FeedPost> posts = new List<FeedPost>();
            List<Opportunity> oppList = new List<Opportunity>();
            List<Opportunity> OppsToBeUpdated = new List<Opportunity>();
            
            oppList = [select Id
            		   from Opportunity 
            		   where id = : oli.OpportunityId];
            		   
						
            id idToUpdate;   
            for(Opportunity opp : oppList)
            {
                  idToUpdate = opp.Id;			
            }
	    System.debug('MIKES OPP ID IS '  + idToUpdate);
            //update OppsToBeUpdated;
            List<OpportunityFeed> opportunityFeedPosts = [SELECT Id, Type, FeedPost.Body
                                                            From OpportunityFeed
                                                            Where ParentID = :idToUpdate
                                                            ORDER BY CreatedDate DESC];
                                                            
                                                            
            String bodyText = 'This is the body ';                                                
            FeedPost opportunityPost = new Feedpost();
            opportunityPost.Type = 'LinkPost';
            opportunityPost.Title = 'THIS IS THE TITLE WILL';
            opportunityPost.Body = bodyText;
            String id = String.valueOf(oli.id).substring(0,15);
            opportunityPost.LinkURL = 'https://cs1.salesforce.com/'+id;
            opportunityPost.ParentID = idToUpdate;
            posts.add(opportunityPost);
            	
            //}                                        
                                                            
            insert posts;                                              

      }
 
  
}

 

 

The only for() loop that I have is in the class and does not query any sObjects.

 

This trigger/class works when I edit 1 OpportunityLineItem, but our Org has an option to edit all and in some cases, there are more than 21 line items on an Opportunity.

 

Why is this failing?  Can someone please give me some guidance here?

 

 

I would appreciate any feedback

 

Thanks!!

 

~Mike

I am trying to get this trigger to update a new, test field (TEXT FIELD, 18 bytes) with the ID of the Opportunity Line Item and the error that I am receiving is Id not specified in the update call.

 

 

 

 

trigger New_Feed_Update on OpportunityLineItem (after update) 
{
	//setup a feedpost array
	List<FeedPost> posts = new List<FeedPost>();
	
	//Create a new, empty list to add the Socket ID's to update
	List<OpportunityLineItem> oppGetIds = new List<OpportunityLineItem>();
	//mike_test__c
	for(OpportunityLineItem oppids : Trigger.new)
	{
		OpportunityLineItem Opp = new OpportunityLineItem();
		Opp.will_test__c = oppids.id;
		OppGetIds.add(Opp);
	}
    Database.update(OppGetIds);



}

 

 

I thought that the ID was already identified in the update call

 

Can someone please help me fix this trigger

Hi all,

 

Sorry but this may be another really basic question that I can't find the answer too, does anyone have the code which uses the PHP toolkit API connections, and allows for a user to register on the SalesForce site?

 

Also what are the minimum amount of fields necessary for a user to register?

 

Thanks in advance, for any help or advice.

I have a custom object in our Salesforce setup called AgentProducts, when I do a query (code running in php) via the API the only field I can get back is Id;

 

select Id, User_Id__c from AgentProducts__c

 

returns a record for every one of the entries in AgentProducts, but only with the Id field;

Array
(
    [0] => stdClass Object
        (
            [Id] => a0350000008xWWKAA2
        )

    [1] => stdClass Object
        (
            [Id] => a0350000008xWWLAA2
        )
etc. 

 

Even worse, if I filter the query by something like my custom email field, I get back the correct Id for the correct account, but still, no further data;

select Id, User_Id__c from AgentProducts__c where Email__c='xxx@xxxxx.xxx'

 

returns:

stdClass Object
(
    [Id] => a0350000008xWWMAA2
)

 

Any ideas?  I've been looking through the online documentation but I can't find anything on custom objects needing special treatment.

 

Hi all.

 

We have a PHP web app talking to SF.  We have converted a Lead to an Account, and are then trying to update the account and getting the error when playing in the sandbox:

Sales Force Update object Failed: attempt to violate hierarchy constraints

 

Unfortunately, there's no documentation on this error anywhere, and it seems like we're the only ones getting it.

 

Can anyone shed some light on what this means?  The same code works fine when talking to the live SalesForce.

 

Thanks

Todd

 

  • May 01, 2009
  • Like
  • 0
I have a query that returns info that I need to paginate. I can return all records or limit to however many records I'd like, but I'd like to set up a page system that allows me to return a specified number of records and then dynamically create a page numbering system of links at the bottom of the report to go to additional pages of records. I have the whole system set up and working, but cannot figure out how to retrieve records starting after the records I've already retrieved.
 
For example,...
 
Page one shows the first 20 records.
 
Page two should show the next 20, but I need something equivilent to SQL's LIMIT 20,20 to start my query at record #20 and then retrieve 20 records. Does SOQL have a function like this?
 
Thank you all very much in advance.