function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
dragan loncardragan loncar 

How I can update specific record in salesforces

Hi
I am using integrafion salesforces with c# .I established connection  salesforces with C  using WSDL
I want to update   last name  where firstname =d
please  help 
That  is my code  SOAP
String soqlQuery = "SELECT firstname__c,lastname__c FROM members__c where   firstname__c='d'";
            QueryResult qr = binding.query(soqlQuery);
in this record i want to update  lastname__c
PLEASE HELP 
 
VamsiVamsi
Hi,

You need to create a web service class in salesforce and then generate a WSDL file and then make use of it in an external application. 

Please go through the following link: https://trailhead.salesforce.com/modules/apex_integration_services/units/apex_integration_webservices

If you would like to perform an update in apex then its as follows 
 
global with sharing class MySOAPWebService
 {
    Webservice static members__c getRecord(String name) 
    {
       // below code is for update 
      
       list<members__c > Updatingrecords = new List<members__c >();
       for(members__c  m : [select lastname from members__c where firstname__c =: name])  
   {
         m.lastname = 'please specify a value for lastname here'; 
         Updatingrecords.add(m);
    }

update Updatingrecords;

    }
}

Hope this helps 

Please mark as best answer if the above helps ....!!!
 
dragan loncardragan loncar
What  i doing wrong  PLEASE HELP
I am using  SOAP  and want  to call  web service   from salesforces   to  update table using WebServiceCallout
i create  WEB SERVICE file in visual studio
namespace WebApplication79
{
    /// <summary>
    /// Summary description for WebService1
    /// </summary>
    [WebService(Namespace = "http://step23.ca")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
    // [System.Web.Script.Services.ScriptService]
    public class WebService1 : System.Web.Services.WebService
    {

        [WebMethod]
        public void updatedatabase()
        {
            string constr = ConfigurationManager.ConnectionStrings["strconnection"].ConnectionString;
            SqlConnection con = new SqlConnection(constr);

            SqlCommand comm = new SqlCommand();
            comm.CommandText = "Insert into Branch(branch) values('dragan')";
           
            con.Open();
            comm.Connection = con;
            comm.ExecuteNonQuery();
            con.Close();


            //  return "Hello World";
        }
    }
}
after that  i  generate  apex class from wsdl
//Generated by wsdl2apex

public class step23Ca {
    public class updatedatabaseResponse_element {
        private String[] apex_schema_type_info = new String[]{'http://step23.ca','true','false'};
        private String[] field_order_type_info = new String[]{};
    }
    public class updatedatabase_element {
        private String[] apex_schema_type_info = new String[]{'http://step23.ca','true','false'};
        private String[] field_order_type_info = new String[]{};
    }
    public class WebService1Soap {
        public String endpoint_x = 'http://184.154.149.230/WebService1.asmx';
        public Map<String,String> inputHttpHeaders_x;
        public Map<String,String> outputHttpHeaders_x;
        public String clientCertName_x;
        public String clientCert_x;
        public String clientCertPasswd_x;
        public Integer timeout_x;
        private String[] ns_map_type_info = new String[]{'http://step23.ca', 'step23Ca'};
        public void updatedatabase() {
            step23Ca.updatedatabase_element request_x = new step23Ca.updatedatabase_element();
            step23Ca.updatedatabaseResponse_element response_x;
            Map<String, step23Ca.updatedatabaseResponse_element> response_map_x = new Map<String, step23Ca.updatedatabaseResponse_element>();
            response_map_x.put('response_x', response_x);
            WebServiceCallout.invoke(
              this,
              request_x,
              response_map_x,
              new String[]{endpoint_x,
              'http://step23.ca/updatedatabase',
              'http://step23.ca',
              'updatedatabase',
              'http://step23.ca',
              'updatedatabaseResponse',
              'step23Ca.updatedatabaseResponse_element'}
            );
            response_x = response_map_x.get('response_x');
        }
    }
}
and  I   cretae  trigger 
trigger AdoDetailTrigger on members__c (before update,after update) {
List<members__c> pcsDetail = [Select Id,firstname__c From members__c Where Id IN :Trigger.new];

//Set<Id> resultIds = (new Map<Id,SObject>(pcsDetail)).keySet();
InvokeWebServiceOnAdoptionStatusChange.callWebService();
}
and call class  to call  web service 
public class InvokeWebServiceOnAdoptionStatusChange {

       @future(callout=true)
        public static void callWebService() {
        try {            
        step23Ca.WebService1Soap x = new step23Ca.WebService1Soap();
            x.updatedatabase();          
        }
        catch(System.AsyncException e) {
            System.debug('Exception' +e);    
        }
    }
}
WHEN I RUNNING CODE    NOTHING  HAPPENED IN DATABASE  TO UPDATE  RECORD
what i am doing wrong 
PLEASE HELP  please 
regards