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
Reddy@SFDCReddy@SFDC 

INVALID_FIELD_FOR_INSERT_UPDATE, Account: bad field names on insert/update call

Hi, i am getting the error in the follwing code .....plzz help

 

global class InboundLinxUserRegistration {
     global class dtRegistrationInput {
       webservice ID UserId;
       webservice String First_Name;
       webservice String Last_Name;
       webservice String Email_Address;
       webservice String Status;
       webservice ID Workplace_Id;
       webservice String Workplace_Name;
       webservice String Workplace_Province;
       webservice String Workplace_City;
       webservice String Workplace_Postal_Code;
       webservice String Workplace_Address;
       webservice String Speciality;
       webservice String Record_Type;
      }
     global class dtRegistrationOutput {
       webservice date mydate;
       webservice String added;
       webservice String status;
       webservice String Message_Text;
      
      }
     
      public webservice static dtRegistrationOutput userregistration(dtRegistrationInput userregistration){
           dtRegistrationOutput retvalue=new dtRegistrationOutput();
           Account acc=new Account();
           acc.National_Code__c=userregistration.UserId;
           acc.FirstName=userregistration.First_Name;
           acc.LastName=userregistration.Last_Name;
           acc.PersonEmail=userregistration.Email_Address;
           acc.Account_Status_NES__c=userregistration.Status;
           acc.Primary_Parent_vod__c=userregistration.Workplace_Id;
           acc.Primary_Province_NES__c=userregistration.Workplace_Province;
           acc.Primary_City_NES__c=userregistration.Workplace_City;
           acc.Primary_Postal_Code_NES__c=userregistration.Workplace_Postal_Code;
           acc.Primary_Address_1_NES__c=userregistration.Workplace_Address;
           acc.Specialty_1_vod__c=userregistration.Speciality;
           acc.RecordTypeId=userregistration.Record_Type;
           try{
                insert acc;
               } catch(DMLException e) {
                     retvalue.mydate=system.today();
                     retvalue.added='false';
                     retvalue.Message_Text=e.getMessage();
                }catch (Exception e){
                      //HttpResponse res = http.send(req);

                      retvalue.mydate=system.today();
                      //retvalue.statuscode=res.getStatusCode();
                 }
                                          
          return retvalue;
       }
  }

kiranmutturukiranmutturu

never create a field with webservice keyword make that as public....

Rahul SharmaRahul Sharma

Hello,

Put a debug to check what value is been assigned to the name.