• MartinHaagen
  • NEWBIE
  • 105 Points
  • Member since 2011

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

Hi,

 

I'm currently looking for the best way to allow an external application to create or requet on Salesforce Leads&Contacts.
I already read all the documentation , i've done the integration_workbook but i still don't understand one thing.

In the workbook or the online documentation they are talking about connected app and consumer key and secret key.

But it's sounds pretty weird for me that we automatically need to set the key to my server for every Salesforce environment.

The only thing that i want it's to let the customer approve (or not) the autorisation my external app to request on Salesforce.

 

My example is Cirrus insight, when the user allow the application(from gmail)  to communicate with Salesforce the user can create lead from this app. Nothing about connected app, remote site or all those kind of things.

Maybe i wasn't looking about the good documentation (rest,soap).

 

Thanks a lot for you help

 

I have the folllowing code and i get the invalid session Id exception.  How to remove it ? Can someone please assist? I am new to use salesforce metadata API. The line highlighted in RED  is where the exception is raised.

 

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.IO.Compression;
using System.Text;
using WebApplication1.WebReference;
using WebApplication1.SFMetadata;

namespace WebApplication1
{
    public partial class _Default : System.Web.UI.Page
    {

        public const double API_VERSION = 23.0;

        private WebApplication1.WebReference.SforceService sf { get; set; }
        private WebApplication1.WebReference.LoginResult lr { get; set; }
        private GetUserInfoResult userInfo { get; set; }

        private MetadataService metaService { get; set; }
        private List<FileProperties> lstFp { get; set; }
        private RetrieveResult result { get; set; }



        private List<String> lstSObjects = new List<String>();
        private List<CustomField> lstFields = new List<CustomField>();



        // Retrieve all SObjects
        private void retrieveSObjects()
        {
            try
            {
                DescribeGlobalResult dgr = sf.describeGlobal();

                DescribeGlobalSObjectResult[] dgsr = dgr.sobjects;
                foreach (DescribeGlobalSObjectResult d in dgr.sobjects)
                {
                    lstSObjects.Add(d.name);
                    Response.Write("object name:" + d.name);
                }
            }
            catch (Exception e)
            {
                Response.Write("Could not retrieve the Sobjects from Salesforce. " + e.Message);
            }
            //check

            //check
        }








        protected void Button1_Click(object sender, EventArgs e)
        {

            SforceService sfService = new SforceService();
            MetadataService ms = new MetadataService();
            LoginResult lResult = new LoginResult();
            GetUserInfoResult uInfo = new GetUserInfoResult();

            sf = new WebApplication1.WebReference.SforceService();
            lr = new WebApplication1.WebReference.LoginResult();
            metaService = new MetadataService();
            userInfo = new GetUserInfoResult();
          loginresult is obtained here
            sfService.Url = lResult.serverUrl;
            Response.Write("URL : " + lResult.serverUrl);
            WebReference.SessionHeader hd = new WebReference.SessionHeader();
            hd.sessionId = lResult.sessionId;
            sfService.SessionHeaderValue = hd;
            Response.Write("\nSessionID"+lResult.sessionId+"\n");

            this.sf = sfService;
            this.lr = lResult;
            this.userInfo = uInfo;
            this.metaService = ms;
            Response.Write("logged in");


            // getProfile();
            // getUser();
            retrieveSObjects();
           String strFolder = "Profile";
            String pckgType = "Profile";

            List<ProfileObjectPermissions> lstProfObjPerm = new List<ProfileObjectPermissions>();
            List<PackageTypeMembers> lstPtm = new List<PackageTypeMembers>();
            foreach (String s in lstSObjects)
            {
                SFMetadata.ProfileObjectPermissions profObjPerm = new SFMetadata.ProfileObjectPermissions();
                profObjPerm.@object = s;
                lstProfObjPerm.Add(profObjPerm);

                SFMetadata.PackageTypeMembers objPckTypMembers = new SFMetadata.PackageTypeMembers();
                List<String> lstMembers = new List<String>();
                lstMembers.Add(s);
                objPckTypMembers.members = lstMembers.ToArray();
                lstPtm.Add(objPckTypMembers);

            }

            Package pck = new Package();
            pck.types = lstPtm.ToArray();

            SFMetadata.Profile objProfile = new SFMetadata.Profile();

            objProfile.objectPermissions = lstProfObjPerm.ToArray();

            // Call the methods to retrieve the profiles and zip file
            // REPLACED  THE LIST PACKAGE METHOD

            // can't use wildcards with reports, so need to fetch the list
            // of ReportFolders first, then fetch all the reports in
            // each folder.
            ListMetadataQuery q = new ListMetadataQuery();
            q.type = strFolder;
            Response.Write("\nSessionID"+lResult.sessionId+"\n");
            FileProperties[] fp = metaService.listMetadata(new ListMetadataQuery[] { q }, API_VERSION);
            /*
            if (fp == null)
            {
                Console.WriteLine("No profile folders returned");
                return ;
            }

            List<String> packageFiles = new List<String>();
            q.type = pckgType;
            foreach (FileProperties p in fp)
            {
                q.folder = p.fullName;
                // listMetadata can take more than one item at a time
                // left as an exercise for the reader to batch up these calls.
                FileProperties[] rps = metaService.listMetadata(new ListMetadataQuery[] { q }, API_VERSION);
                if (fp == null) continue;
                foreach (FileProperties rp in rps)
                {
                    Console.WriteLine("{0}", rp.fileName);
                    packageFiles.Add(rp.fullName);
                }
            }

            String[] profileFiles = packageFiles.ToArray(); ;

            // RETRIEVEPACKAGE METHOD CODE

            // build up an unpackaged retrieve request for the list of reports.
            RetrieveRequest r = new RetrieveRequest();
            r.apiVersion = API_VERSION;
            //r.unpackaged = new Package();
            r.unpackaged = pck;

            PackageTypeMembers m = new PackageTypeMembers();
            m.name = pckgType;
            m.members = profileFiles;
            r.unpackaged.types = new PackageTypeMembers[] { m };

            // start the retrieve request
            AsyncResult ar = metaService.retrieve(r);

            // wait for it to complete, sleeping as necassary.
            while (!ar.done)
            {
                System.Threading.Thread.Sleep(1000);
                ar = metaService.checkStatus(new String[] { ar.id })[0];
            }

            // did it work ?
            if (ar.state == AsyncRequestState.Error)
                Console.WriteLine("{0} {1}", ar.statusCode, ar.message);
            else
            {
                // now actually go get the results
                RetrieveResult rr = metaService.checkRetrieveStatus(ar.id);
                if (rr.messages != null)
                    foreach (RetrieveMessage rm in rr.messages)
                        Console.WriteLine("{0} : {1}", rm.fileName, rm.problem);

                // write the zipFile out to a disk file.
                using (System.IO.FileStream fs = new System.IO.FileStream("c:\\" + pckgType + ".zip", System.IO.FileMode.Create))
                    fs.Write(rr.zipFile, 0, rr.zipFile.Length);
            }
            */
            Response.Write("Extraction Complete.");
            Response.Write("RetrievedSObjects");

        }



    }
}

Hi all!,

 

I'm trying to add a pricebook entry for each of the products I'm setting as active, but at the time of executing the scheduled code, the System Log gives me the error "PricebookEntry.Product2Id field is not writeable". How can I insert a pricebook entry then? I supose It is possible using Apex...

 

Here is my code:

 

 	List<Product2> prods=Database.query(queryStr1);
         
        for(Product2 p:prods){
            
            p.isActive=TRUE;

            PricebookEntry pricebookEntryItem = new PricebookEntry(Pricebook2Id='01s20000000Hfx5AAC');
            pricebookEntryItem.Product2Id=p.Id;
            pricebookEntryItem.UnitPrice=0;
            pricebookEntryItem.UseStandardPrice=TRUE;
            insert pricebookEntryItem;
            
        } update prods;

 

Any ideas/work arounds are more than welcome.

 

Thank you,

 

MGA

Hi,

I created a new Apex trigger in Account object.

 

trigger AccountTrigger on Account (before insert) {
    if(Trigger.IsInsert) {

        List<Account> AccountList = new List<Account>();
        Map<Id,Account> AccountMap = new Map<Id, Account>();
        Map<Id, Boolean> UsersActiveMap = new Map<Id, Boolean>();
        
        for(Account AccountNew : Trigger.New) {
            AccountMap.put(AccountNew.OwnerId, AccountNew);
        }
        system.debug('Account Map Values '+ AccountMap);
        system.debug('Account Map SIZE Values '+ AccountMap.size());
        
        List<User> UserList = [select Id, name, Username, IsActive from user where Id IN : AccountMap.Keyset()];
        for(User Users : UserList) {
            UsersActiveMap.put(Users.Id, Users.IsActive);
        }
        system.debug('UsersActiveMap Values '+ UsersActiveMap);
        
        for(Account Acc : AccountMap.Values()) {
            system.debug('AccountMap Size()' + AccountMap.size() + ' '+ Acc.OwnerId );
            if(UsersActiveMap.get(Acc.OwnerId)) {
                AccountList.add(Acc);
                system.debug('AccountList' + AccountList.size());    
            }
        }
        system.debug('AccountList Values '+ AccountList);
        if(Trigger.IsBefore) {
            system.debug('SSS AccountList Size()' + AccountList.size());
            AccountTriggerClass.UpdateCallFrequency(AccountList);
        }
    }    
}   

I run via data loader I have 20 records in CSV file.

I got only One record on line 12

system.debug('Account Map SIZE Values '+ AccountMap.size());

but I want 20.

Is anything I am missing..

 

 

 

Hi,

 

am recently installing Force.com platform to Eclipse Helios 3.6 , getting instalation error as below

An error occurred while collecting items to be installed
session context was:(profile=epp.package.jee, phase=org.eclipse.equinox.internal.p2.engine.phases.Collect, operand=, action=).
Problems downloading artifact: osgi.bundle,com.salesforce.ide,28.0.1.201309101331.
MD5 hash is not as expected. Expected: 5fc867b480a95c996f042dc4954181b6 and found b14985d88c9dcc5378383dcf2bad22b7.
Problems downloading artifact: osgi.bundle,com.salesforce.ide.deployment,28.0.1.201309101331.
MD5 hash is not as expected. Expected: 8e92bfd537c5247cd12f2d34e0432120 and found 27f91dae3aa520fcaba218dad6e2ab84.
Unable to read repository at http://adnsandbox.com/tools/ide/install/plugins/com.salesforce.ide.documentation_28.0.0.201309101331.jar.
Read timed out

 Please suggest

 

Thanks Regards

Raja

 

Hi there,

 

I have a requirement where I am trying to access/update the salesforce data from javascript/jquery written in a Gmail Context Gadget. Please let me know if any one has come across this.

 

Any help/guidance will be appreciated.

 

Thanks

Sujit

Hi

I am new to Salesforce

I have a bulk api code in C# which reads data from sql server database and imports it to Salesforce.This code works fine in the Visual Studio 2008.

But my requirement is to call the code from Salesforce,so i am using Soap Api for it.

I have created a webservice in C# and in a function named getbulkdata() i have pasted my bulk api code there.

Now this code works fine in the Webservice test client i.e. it imports data from sql server to salesforce.

But now when i m calling the same code from Salesforce it gives me the following error:

 

System.CalloutException: Web service callout failed: WebService returned a SOAP Fault: Unable to connect to the remote server faultcode=a:InternalServiceFault faultactor=

Error is in expression '{!getSaveToObjectPage}'

 

 

 

 

The wsdl2Apex class getbulkdata() method is as below:

 

 public String Getbulkdata(String tablename,String databasename,String Objectname) {
            sqlServerConnector23.Getbulkdata_element request_x = new sqlServerConnector23.Getbulkdata_element();
            sqlServerConnector23.GetbulkdataResponse_element response_x;
            request_x.tablename = tablename;
            request_x.databasename = databasename;
            request_x.Objectname = Objectname;
            Map<String, sqlServerConnector23.GetbulkdataResponse_element> response_map_x = new Map<String, sqlServerConnector23.GetbulkdataResponse_element>();
            response_map_x.put('response_x', response_x);
            WebServiceCallout.invoke(
              this,
              request_x,
              response_map_x,
              new String[]{endpoint_x,
              'http://tempuri.org/IService1/Getbulkdata',
              'http://tempuri.org/',
              'Getbulkdata',
              'http://tempuri.org/',
              'GetbulkdataResponse',
              'sqlServerConnector23.GetbulkdataResponse_element'}
            );
            response_x = response_map_x.get('response_x');
            return response_x.GetbulkdataResult;
        }

 

The method is called from salesforce in the following way:

 

 public PageReference getSaveToObjectPage() {
     sqlArray23.ArrayOfstring a = new sqlArray23.ArrayOfstring();
     sqlServerConnector23.BasicHttpBinding_IService1 stub = new sqlServerConnector23.BasicHttpBinding_IService1();
     String operation='insert';
     stub.timeout_x = 120000; 
     
       
    String Message= stub.Getbulkdata(tablename,databasename,obj name);
   
           PageReference newpage = new PageReference('/apex/SqlServer2005Login_Import6');
            newpage.setRedirect(false); 
              return newpage;  
     
     }

 

 Can some one please tell me y am i getting the Soap Fault unable to connect to remote server.

As the same code is working fine in webservice (WCF) Test Client.

 

 

Thanks in advance.

Please let me know if you require anythg more like the bulk api code or something else.

 

 

 

 

 

 

 

 

 

 

Hi,

 

I'm currently looking for the best way to allow an external application to create or requet on Salesforce Leads&Contacts.
I already read all the documentation , i've done the integration_workbook but i still don't understand one thing.

In the workbook or the online documentation they are talking about connected app and consumer key and secret key.

But it's sounds pretty weird for me that we automatically need to set the key to my server for every Salesforce environment.

The only thing that i want it's to let the customer approve (or not) the autorisation my external app to request on Salesforce.

 

My example is Cirrus insight, when the user allow the application(from gmail)  to communicate with Salesforce the user can create lead from this app. Nothing about connected app, remote site or all those kind of things.

Maybe i wasn't looking about the good documentation (rest,soap).

 

Thanks a lot for you help

 

Hi, 

 

I am using the Beatbox py library. Using the examples a script creates a new client with a new login every time the skript is called.

My usage pattern will cause a skript to be called every 5 Minutes in average (maybe 2-5 times per minute in rare peaks).

 

Is this behaviour ok (for SFDC's watchdogs and for the client's performance)?

Are there other patterns to use (e.g. oauth like key retrieval once and no new logins with every call)?

 

Thanks for comments!

 

Thomas

 

 

After creating an entry in a custom object the returned ID has AA2 appended to the end. Is this normal?

 

The ID as you see has AA2 added to the end, when I view this entry in the dashboard the URL only shows a00i0000009cDXN which is the ID of the entry. The entry displays even if AA2 is added.

 

Upserting Contact (existing) Array ( [0] => stdClass Object ( [id] => a00i0000009cDXNAA2 [success] => 1 ) )

 

Just wondering if this is normal with the API and PHP Toolkit. I'm using a developer account and the SOAP client.

 

Thanks

  • November 11, 2013
  • Like
  • 0
public class dynamicApex5 {

   public list<SelectOption> selectedobject { get; set; }

    public String objectName { get; set; }    
    public set<string> flds{get;set;}
    
    Map<String, Schema.SObjectType> schemaMap = Schema.getGlobalDescribe();
    public dynamicApex5(){
                   
                selectedobject = new list<SelectOption>();  
                  selectedobject.add(new selectoption('','-None-'));
                  list<schema.SobjectType> lst=schemaMap.values();
                  for(schema.SobjectType ss:lst){
                      selectedobject.add(new selectoption(ss.getDescribe().getLocalName(),ss.getDescribe().getLabel()));
                      selectedobject.sort();
               }
                 flds= new set<string>();
                  lsps=new list<SelectOption>();
    }
 
      
      public String fields { get; set; }
      
       public list<SelectOption> lsps{get;set;}
      
       public void function() {
       
         if(objectName!=null || objectName!=''){
           Map<string,Schema.SObjectField> mpConField=schemaMap.get(objectName).getDescribe().fields.getMap();
               flds=mpConField.keySet();
                                
                   for(string name:flds){
                   Schema.DescribeFieldResult fldResult=mpConField.get(name).getDescribe();
                    lsps.add(new SelectOption(fldResult.getName(),fldResult.getName()));
                    lsps.sort();                    
                   }
                }        
    }
    
        

}

I am not a developer; hence my posting this here. I have a workflow that I want to fire when a formula field evaluates to a certain value. The problem is, standard workflow will only trigger on record edits, and I'm not updating the record. 

 

Surely there is an Apex Trigger 'recipe' out there that I could use for this? Any guidance appreciated. 

  • February 19, 2013
  • Like
  • 0

Hi Folks,

 

I was able to generate the PPT from salesfoce ...still i am having problem to add the images and tables in the PPT. Is there any way which i can achieve using this method..Please help me..

 

Messaging.EmailFileAttachment csvAttc = new Messaging.EmailFileAttachment();
List<Account > acclist = [Select id,name from Account limit 10];
string header = 'Record Id, Name \n';
string finalstr = header ;
for(Account a: acclist)
{
string recordString = a.id+','+a.Name+'\n';
finalstr = finalstr +recordString;
}
blob csvBlob = Blob.valueOf(finalstr);
string csvname= 'Venki.ppt';
csvAttc.setFileName(csvname);
csvAttc.setBody(csvBlob);
Messaging.SingleEmailMessage email =new Messaging.SingleEmailMessage();
String[] toAddresses = new list<string> {'test@gmail.com'};
String subject ='Account PPT';
email.setSubject(subject);
email.setToAddresses( toAddresses );
email.setPlainTextBody('Account PPT ');
email.setFileAttachments(new Messaging.EmailFileAttachment[]{csvAttc});
Messaging.SendEmailResult [] r = Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email});

 

Thanks,

Venki

Hi,
I have been working for the last 3 days on a couple of trigger and test classes in the Sandbox. Which I got 100% and was working all fine in Sandbox. Now when I move it too production it doesn't work. 
I did a refresh of the sandbox before moving it so the fields / val rules are the same. 
I have turned on the debug logs (I am no expert) but can not even see them firing. 
I tried to edit the code in sandbox by just removing white space in case thats why it wasn't working and now it is isn't working in the sandbox either. 
Even when I put the original code back. 

Can any help?

 

trigger cloneElecAMsignOff on Electricity_Meter__c (before update) {


     List<Electricity_Meter__c> myList = new List<Electricity_Meter__c>();
      

     for(Electricity_Meter__c a: trigger.new) {

        // insert Elec meter if Deal Done
        if (
        a.Account_Manager_Sign_Off_Date_Time__c != Null &&
        a.Clone_Date_Time_Stamp__c == Null && 
        (
        a.Deal_Done_Not__c == 'Deal Done (Existing client / Existing meter)' ||
        a.Deal_Done_Not__c == 'Deal Done (New Meter, New Client)' || 
        a.Deal_Done_Not__c == 'Deal Done (New Meter, Exisiting Client)')) {
        
        Electricity_Meter__c b = new Electricity_Meter__c();                
        b.Name = a.Name; 
        b.Site_name__c = a.Site_name__c;
        b.Contract_arranged_under_the_name_of__c = a.Winning_Contract_Arranged_Under_Name_of__c;
        b.Account__c = a.Account__c; 
        b.Linked_Basket__c = a.Linked_Basket__c;
        b.Linked_Monitor_Line__c = a.Linked_Monitor_Line__c;
        b.Current_Supplier__c = a.Winning_Supplier__c;
        b.Previous_Supplier__c = a.Current_Supplier__c;
        b.Meter_Status__c = '(2) Active (Not yet live)';
        b.COT_Disc_Deenerg_Date__c = a.COT_Disc_Deenerg_Date__c;       
        b.Auto_Manual_Term__c = a.Auto_Manual_Term__c;
              
        b.Linked_Affiliate_1__c = a.Linked_Affiliate_1__c;    
        b.Aff_1_Profit_Split__c = a.Aff_1_Profit_Split__c;
        b.Linked_Affiliate_2__c = a.Linked_Affiliate_2__c;    
        b.Aff_2_Profit_Split__c = a.Aff_2_Profit_Split__c;        
        b.Linked_Affiliate_3__c = a.Linked_Affiliate_3__c;    
        b.Aff_3_Profit_Split__c = a.Aff_3_Profit_Split__c;
        
        b.Site_Address_New__c = a.Site_Address_New__c;
        b.Site_Postcode__c = a.Site_Postcode__c;
        b.Co_Reg_FULL_Partnership_LLP_Sole_Trader__c = a.Co_Reg_FULL_Partnership_LLP_Sole_Trader__c;
        b.Billing_Address_New__c = a.Billing_Address_New__c;
        b.Billing_Postcode__c = a.Billing_Postcode__c;
        b.Number_of_employees__c = a.Number_of_employees__c;
        b.Annual_turnover_Euros__c = a.Annual_turnover_Euros__c;
        
        b.Profile_Class__c = a.Profile_Class__c;
        b.MTC_LLF__c = a.MTC_LLF__c;
        b.Meter_Details__c = a.Meter_Details__c; 
        b.MOP_CED__c = a.MOP_CED__c;
        b.Voltage_HV_LV_LVS__c = a.Voltage_HV_LV_LVS__c;
        
        b.Contract_start_date__c = a.Winning_Contract_Start_Date__c;
        b.Contract_expiry__c = a.Winning_Contract_End_Date__c;
        b.Payment_Method__c = a.Payment_Method__c;
        b.DD_Type__c = a.DD_Type__c;
        b.VAT__c = a.VAT__c;
        b.Monthly_Quarterly_Billing__c = a.Monthly_Quarterly_Billing__c;
        b.Copy_of_the_bills__c = a.Copy_of_the_bills__c;
        b.AQ__c = a.Winning_Supply_AQ__c;
        b.Total_KVA__c = a.Total_KVA__c; 
        b.Commission_p__c = a.Winning_Commision_p_kwh__c;
        b.Commission_per_year__c = a.Winning_Commission_year__c;
        b.Commission_Percent__c = a.Winning_Commission_Contract__c;  
        myList.add(b);  
        
        }


               
        // insert Elec meter if Deal Not Done
        else if (a.Account_Manager_Sign_Off_Date_Time__c != Null && 
        a.Clone_Date_Time_Stamp__c == Null && 
        (
        a.Deal_Done_Not__c == 'Deal not done / Not responding - Client retained' ||
        a.Deal_Done_Not__c == 'Deal not done / Not responding - Client lost' ||
        a.Deal_Done_Not__c == 'Deal not done / Went direct with supplier - Client retained' ||
        a.Deal_Done_Not__c == 'Deal not done / Went direct with supplier - Client lost' ||
        a.Deal_Done_Not__c == 'Deal not done / Went with another consultant - Client retained' ||
        a.Deal_Done_Not__c == 'Deal not done / Went with another consultant - Client lost' ||
        a.Deal_Done_Not__c == 'Deal not done / Meter removed - Client retained' ||
        a.Deal_Done_Not__c == 'Deal not done / Meter removed - Client lost')) {
        
        Electricity_Meter__c c = new Electricity_Meter__c();                
        c.Name = a.Name; 
        c.Site_name__c = a.Site_name__c;
        c.Contract_arranged_under_the_name_of__c = a.Winning_Contract_Arranged_Under_Name_of__c; 
        c.Account__c = a.Account__c; 
        c.Linked_Basket__c = a.Linked_Basket__c;
        c.Linked_Monitor_Line__c = a.Linked_Monitor_Line__c;
        c.Current_Supplier__c = a.Winning_Supplier__c;
        c.Previous_Supplier__c = a.Current_Supplier__c;
        c.Meter_Status__c = '(5) Active';
        c.COT_Disc_Deenerg_Date__c = a.COT_Disc_Deenerg_Date__c;        
        c.Auto_Manual_Term__c = a.Auto_Manual_Term__c;
              
        c.Linked_Affiliate_1__c = a.Linked_Affiliate_1__c;    
        c.Aff_1_Profit_Split__c = a.Aff_1_Profit_Split__c;
        c.Linked_Affiliate_2__c = a.Linked_Affiliate_2__c;    
        c.Aff_2_Profit_Split__c = a.Aff_2_Profit_Split__c;        
        c.Linked_Affiliate_3__c = a.Linked_Affiliate_3__c;    
        c.Aff_3_Profit_Split__c = a.Aff_3_Profit_Split__c;
        
        c.Site_Address_New__c = a.Site_Address_New__c;
        c.Site_Postcode__c = a.Site_Postcode__c;
        c.Co_Reg_FULL_Partnership_LLP_Sole_Trader__c = a.Co_Reg_FULL_Partnership_LLP_Sole_Trader__c;
        c.Billing_Address_New__c = a.Billing_Address_New__c;
        c.Billing_Postcode__c = a.Billing_Postcode__c;
        c.Number_of_employees__c = a.Number_of_employees__c;
        c.Annual_turnover_Euros__c = a.Annual_turnover_Euros__c;
        
        c.Profile_Class__c = a.Profile_Class__c;
        c.MTC_LLF__c = a.MTC_LLF__c;
        c.Meter_Details__c = a.Meter_Details__c; 
        c.MOP_CED__c = a.MOP_CED__c;
        c.Voltage_HV_LV_LVS__c = a.Voltage_HV_LV_LVS__c;
        
        c.Contract_start_date__c = a.Winning_Contract_Start_Date__c;
        c.Contract_expiry__c = a.Winning_Contract_End_Date__c;
        c.Payment_Method__c = a.Payment_Method__c;
        c.DD_Type__c = a.DD_Type__c;
        c.VAT__c = a.VAT__c;
        c.Monthly_Quarterly_Billing__c = a.Monthly_Quarterly_Billing__c;
        c.Copy_of_the_bills__c = a.Copy_of_the_bills__c;
        c.AQ__c = a.Winning_Supply_AQ__c;
        c.Total_KVA__c = a.Total_KVA__c; 
        c.Commission_p__c = a.Winning_Commision_p_kwh__c;
        c.Commission_per_year__c = a.Winning_Commission_year__c;
        c.Commission_Percent__c = a.Winning_Commission_Contract__c;
        myList.add(c);           
        
        }

   

        
    }
       

        
        
}

now I have a silverlight application that holds all the invoices of my client. However,the application that i am building for my client is on Salesforce.com What i need to be able to do is send a request from salesforce in the form of a URL with orderid appeneded and get a response(i.e. the corresponding invoice) from the silverlight app and display it in a visualforce page. How exactly do i go about acheiving this?

I have the folllowing code and i get the invalid session Id exception.  How to remove it ? Can someone please assist? I am new to use salesforce metadata API. The line highlighted in RED  is where the exception is raised.

 

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.IO.Compression;
using System.Text;
using WebApplication1.WebReference;
using WebApplication1.SFMetadata;

namespace WebApplication1
{
    public partial class _Default : System.Web.UI.Page
    {

        public const double API_VERSION = 23.0;

        private WebApplication1.WebReference.SforceService sf { get; set; }
        private WebApplication1.WebReference.LoginResult lr { get; set; }
        private GetUserInfoResult userInfo { get; set; }

        private MetadataService metaService { get; set; }
        private List<FileProperties> lstFp { get; set; }
        private RetrieveResult result { get; set; }



        private List<String> lstSObjects = new List<String>();
        private List<CustomField> lstFields = new List<CustomField>();



        // Retrieve all SObjects
        private void retrieveSObjects()
        {
            try
            {
                DescribeGlobalResult dgr = sf.describeGlobal();

                DescribeGlobalSObjectResult[] dgsr = dgr.sobjects;
                foreach (DescribeGlobalSObjectResult d in dgr.sobjects)
                {
                    lstSObjects.Add(d.name);
                    Response.Write("object name:" + d.name);
                }
            }
            catch (Exception e)
            {
                Response.Write("Could not retrieve the Sobjects from Salesforce. " + e.Message);
            }
            //check

            //check
        }








        protected void Button1_Click(object sender, EventArgs e)
        {

            SforceService sfService = new SforceService();
            MetadataService ms = new MetadataService();
            LoginResult lResult = new LoginResult();
            GetUserInfoResult uInfo = new GetUserInfoResult();

            sf = new WebApplication1.WebReference.SforceService();
            lr = new WebApplication1.WebReference.LoginResult();
            metaService = new MetadataService();
            userInfo = new GetUserInfoResult();
          loginresult is obtained here
            sfService.Url = lResult.serverUrl;
            Response.Write("URL : " + lResult.serverUrl);
            WebReference.SessionHeader hd = new WebReference.SessionHeader();
            hd.sessionId = lResult.sessionId;
            sfService.SessionHeaderValue = hd;
            Response.Write("\nSessionID"+lResult.sessionId+"\n");

            this.sf = sfService;
            this.lr = lResult;
            this.userInfo = uInfo;
            this.metaService = ms;
            Response.Write("logged in");


            // getProfile();
            // getUser();
            retrieveSObjects();
           String strFolder = "Profile";
            String pckgType = "Profile";

            List<ProfileObjectPermissions> lstProfObjPerm = new List<ProfileObjectPermissions>();
            List<PackageTypeMembers> lstPtm = new List<PackageTypeMembers>();
            foreach (String s in lstSObjects)
            {
                SFMetadata.ProfileObjectPermissions profObjPerm = new SFMetadata.ProfileObjectPermissions();
                profObjPerm.@object = s;
                lstProfObjPerm.Add(profObjPerm);

                SFMetadata.PackageTypeMembers objPckTypMembers = new SFMetadata.PackageTypeMembers();
                List<String> lstMembers = new List<String>();
                lstMembers.Add(s);
                objPckTypMembers.members = lstMembers.ToArray();
                lstPtm.Add(objPckTypMembers);

            }

            Package pck = new Package();
            pck.types = lstPtm.ToArray();

            SFMetadata.Profile objProfile = new SFMetadata.Profile();

            objProfile.objectPermissions = lstProfObjPerm.ToArray();

            // Call the methods to retrieve the profiles and zip file
            // REPLACED  THE LIST PACKAGE METHOD

            // can't use wildcards with reports, so need to fetch the list
            // of ReportFolders first, then fetch all the reports in
            // each folder.
            ListMetadataQuery q = new ListMetadataQuery();
            q.type = strFolder;
            Response.Write("\nSessionID"+lResult.sessionId+"\n");
            FileProperties[] fp = metaService.listMetadata(new ListMetadataQuery[] { q }, API_VERSION);
            /*
            if (fp == null)
            {
                Console.WriteLine("No profile folders returned");
                return ;
            }

            List<String> packageFiles = new List<String>();
            q.type = pckgType;
            foreach (FileProperties p in fp)
            {
                q.folder = p.fullName;
                // listMetadata can take more than one item at a time
                // left as an exercise for the reader to batch up these calls.
                FileProperties[] rps = metaService.listMetadata(new ListMetadataQuery[] { q }, API_VERSION);
                if (fp == null) continue;
                foreach (FileProperties rp in rps)
                {
                    Console.WriteLine("{0}", rp.fileName);
                    packageFiles.Add(rp.fullName);
                }
            }

            String[] profileFiles = packageFiles.ToArray(); ;

            // RETRIEVEPACKAGE METHOD CODE

            // build up an unpackaged retrieve request for the list of reports.
            RetrieveRequest r = new RetrieveRequest();
            r.apiVersion = API_VERSION;
            //r.unpackaged = new Package();
            r.unpackaged = pck;

            PackageTypeMembers m = new PackageTypeMembers();
            m.name = pckgType;
            m.members = profileFiles;
            r.unpackaged.types = new PackageTypeMembers[] { m };

            // start the retrieve request
            AsyncResult ar = metaService.retrieve(r);

            // wait for it to complete, sleeping as necassary.
            while (!ar.done)
            {
                System.Threading.Thread.Sleep(1000);
                ar = metaService.checkStatus(new String[] { ar.id })[0];
            }

            // did it work ?
            if (ar.state == AsyncRequestState.Error)
                Console.WriteLine("{0} {1}", ar.statusCode, ar.message);
            else
            {
                // now actually go get the results
                RetrieveResult rr = metaService.checkRetrieveStatus(ar.id);
                if (rr.messages != null)
                    foreach (RetrieveMessage rm in rr.messages)
                        Console.WriteLine("{0} : {1}", rm.fileName, rm.problem);

                // write the zipFile out to a disk file.
                using (System.IO.FileStream fs = new System.IO.FileStream("c:\\" + pckgType + ".zip", System.IO.FileMode.Create))
                    fs.Write(rr.zipFile, 0, rr.zipFile.Length);
            }
            */
            Response.Write("Extraction Complete.");
            Response.Write("RetrievedSObjects");

        }



    }
}

Hello, I am new to this but I am trying to create a custom button with javascript that will delete a few fields and copy one into another.

 

I would like to delete fields A, B and C.  Copy D to E. Both on a custom object Machine (Machine__c)

 

Any help would be appreciated.

I want to create a web interface that allows a customer to login and view their SF record. I will manually create the users using their first name and the unique key assigned to their record in SF as their password. When they click login, this will run a query and match up their unique key with their SF record and thus show all the fields i want them to see in the web interface. Once the user is setup, everything is dynamically created on the web interface

Is this logical way to do it?

If someone could point me in the right direction as to which API to use that sould be great.

 

I am knowledgable at PHP, MySQL, HTML, CSS and also use JavaScript and Jquery as our website runs on WordPress, So if I could use my PHP skill to this advantage it would be great.

Hi

We are trying to use WebService callout, and need a working example.

 

I've tried working through the example 'Apex Web Services and Callouts' at http://wiki.developerforce.com/page/Apex_Web_Services_and_Callouts but can't get it to work - I think it may be because we don't have an Amazon S3 account - when I key http://s3.amazonaws.com/doc/2006-03-01/ I get:

<Error>
<Code>AccessDenied</Code>
<Message>Access Denied</Message>
<RequestId>D0553BA616766C71</RequestId>
<HostId>It4ZN5WnKCGiqdT7ryrP28BPOWWlsLA/N4l4PWFPtimNOTea+CuPOBY1/KjLkw4G</HostId>
</Error>

 

This means we can't get the WSDL to generate the apex method

 

Does anybody have a simple HelloWorld type example that we can work through?

 

Thanks!

Pablo

  • January 08, 2013
  • Like
  • 0

Hello there,

 

Im having trouble on how to create a listener of salesforce outbound message. Do you have a step-by-step lesson on how to create a salesforce outbound listener ? specially in java and php language ? Please help me.

 

Kind Regards,

 

John