• Reddy@SFDC
  • NEWBIE
  • 0 Points
  • Member since 2011

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 22
    Questions
  • 11
    Replies

How to avoide the error in the following code................actually when i am testing this webservice with xmlspy it is giving the error

 

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;
       webservice String error;
      
      }
     
      public webservice static dtRegistrationOutput userregistration(dtRegistrationInput userregistration){
           dtRegistrationOutput retvalue=new dtRegistrationOutput();
           for(List<Account> account :[select National_Code__c,PersonEmail from Account]){
              for(Account acc : account) {
                 if((acc.National_Code__c==userregistration.UserId)||(acc.PersonEmail==userregistration.Email_Address)){
                         retvalue.status='Failure';
                         retvalue.error='Duplicate';
                    }else {    
                     account[0].National_Code__c=userregistration.UserId;
                     account[0].FirstName=userregistration.First_Name;
                     account[0].LastName=userregistration.Last_Name;
                     account[0].PersonEmail=userregistration.Email_Address;
                     account[0].Account_Status_NES__c=userregistration.Status;
                     account[0].Primary_Parent_vod__c=userregistration.Workplace_Id;
                     account[0].Primary_Province_NES__c=userregistration.Workplace_Province;
                     account[0].Primary_City_NES__c=userregistration.Workplace_City;
                     account[0].Primary_Postal_Code_NES__c=userregistration.Workplace_Postal_Code;
                     account[0].Primary_Address_1_NES__c=userregistration.Workplace_Address;
                     account[0].Specialty_1_vod__c=userregistration.Speciality;
                     account[0].RecordTypeId=userregistration.Record_Type;
                     try{
                         insert acc;
                         retvalue.added='True';
                         retvalue.Message_Text='Registration Successfull';
                        } /*catch(DMLException e) {
                             retvalue.mydate=system.today();
                             retvalue.added='false';
                             retvalue.Message_Text=e.getMessage();
                        }*/
                        catch (Exception e){
                          retvalue.mydate=system.today();
                          retvalue.added='false';
                          retvalue.Message_Text=e.getMessage();
                         }
                    
                 }
              }
             return retvalue;
           }
            
                                 
          return retvalue;
       }
  }

Hi all....how to fix this error in the below code.....

 

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;
       webservice integer statuscode;
      }
     
      public webservice static dtRegistrationOutput userregistration(dtRegistrationInput userregistration){
           dtRegistrationOutput retvalue=new dtRegistrationOutput();
           HttpRequest req=new HttpRequest();
           Http http=new Http();
           HttpResponse res = http.send(req);
           retvalue.status='Success';
           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.statuscode=res.getStatusCode();
                     retvalue.added='false';
                     retvalue.Message_Text=e.getMessage();
                }catch (Exception e){
                      retvalue.mydate=system.today();
                      retvalue.statuscode=res.getStatusCode();
                 }
                                          
          return retvalue;
       }
  }

here is my code::::::

 

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();
           retvalue.status='Success';
                         
                    List<Account> acc=[select National_Code__c,FirstName,LastName,PersonEmail,Account_Status_NES__c,Primary_Parent_vod__c,Primary_Province_NES__c,Primary_City_NES__c,Primary_Postal_Code_NES__c,Primary_Address_1_NES__c,Specialty_1_vod__c,RecordTypeId from Account where National_Code__c=:userregistration.UserId];
                    if(acc.size()==0){      
                     acc[0].National_Code__c=userregistration.UserId;
                     acc[0].FirstName=userregistration.First_Name;
                     acc[0].LastName=userregistration.Last_Name;
                     acc[0].PersonEmail=userregistration.Email_Address;
                     acc[0].Account_Status_NES__c=userregistration.Status;
                     acc[0].Primary_Parent_vod__c=userregistration.Workplace_Id;
                     acc[0].Primary_Province_NES__c=userregistration.Workplace_Province;
                     acc[0].Primary_City_NES__c=userregistration.Workplace_City;
                     acc[0].Primary_Postal_Code_NES__c=userregistration.Workplace_Postal_Code;
                     acc[0].Primary_Address_1_NES__c=userregistration.Workplace_Address;
                     acc[0].Specialty_1_vod__c=userregistration.Speciality;
                     acc[0].RecordTypeId=userregistration.Record_Type;
                     try{
                     insert acc;
                 } catch(DMLException e) {
                                retvalue.status='Failure';
                                retvalue.mydate=system.today();
                                retvalue.added='false';
                                retvalue.Message_Text=e.getMessage();
                 }catch (Exception e){
                            retvalue.mydate=system.today();
                            HttpRequest req=new HttpRequest();
                            Http http=new Http();
                            HttpResponse res = http.send(req);
                            System.debug('STATUS:'+res.getStatus());
                            System.debug('STATUS_CODE:'+res.getStatusCode());
                            retvalue.Status='Failure';
                            retvalue.Message_text=e.getMessage();
                         }
                   }else {
                              retvalue.status='Failure';
                              retvalue.mydate=system.today();
                              retvalue.added='false';
                           }
                       
                    return retvalue;
       }
  }

Hi all, please help me.....i want to throw http error messages in this code with the status code.....

 

 

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 String status;
       webservice String Message_Text;
      }
     
      public webservice static dtRegistrationOutput userregistration(dtRegistrationInput userregistration){
           dtRegistrationOutput retvalue=new dtRegistrationOutput();
           retvalue.status='Success';
                          
            Account account=new Account();
                             
                     account.National_Code__c=userregistration.UserId;
                     account.FirstName=userregistration.First_Name;
                     account.LastName=userregistration.Last_Name;
                     account.PersonEmail=userregistration.Email_Address;
                     account.Account_Status_NES__c=userregistration.Status;
                     account.Primary_Parent_vod__c=userregistration.Workplace_Id;
                     account.Primary_Province_NES__c=userregistration.Workplace_Province;
                     account.Primary_City_NES__c=userregistration.Workplace_City;
                     account.Primary_Postal_Code_NES__c=userregistration.Workplace_Postal_Code;
                     account.Primary_Address_1_NES__c=userregistration.Workplace_Address;
                     account.Specialty_1_vod__c=userregistration.Speciality;
                     account.RecordTypeId=userregistration.Record_Type;
                     try{
                          insert account;
                         } catch (Exception e){
                            retvalue.Status='Failure';
                            retvalue.Message_text=e.getMessage();
                           
                           }
                  
          return retvalue;
       }
  }

Hi, my code as follows

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 String status;
       webservice String Message_Text;
      }
     
      public webservice static dtRegistrationOutput Registration(dtRegistrationInput Registration){
           dtRegistrationOutput retvalue=new dtRegistrationOutput();
           retvalue.status='Success';
                          
            List<Account> account=new List<Account>();
                             
                     account[0].National_Code__c=Registration.UserId;
                     account[0].FirstName=Registration.First_Name;
                     account[0].LastName=Registration.Last_Name;
                     account[0].PersonEmail=Registration.Email_Address;
                     account[0].Account_Status_NES__c=Registration.Status;
                     account[0].Primary_Parent_vod__c=Registration.Workplace_Id;
                     account[0].Primary_Province_NES__c=Registration.Workplace_Province;
                     account[0].Primary_City_NES__c=Registration.Workplace_City;
                     account[0].Primary_Postal_Code_NES__c=Registration.Workplace_Postal_Code;
                     account[0].Primary_Address_1_NES__c=Registration.Workplace_Address;
                     account[0].Specialty_1_vod__c=Registration.Speciality;
                     account[0].RecordTypeId=Registration.Record_Type;
                     try{
                          insert account[0];
                         } catch (Exception e){
                            retvalue.Status='Failure';
                            retvalue.Message_Text= e.getMessage();
                           }
                  
          return retvalue;
       }
  }   

 

when i am trying this code with xmlspy i am getting the error

<

faultcode>soapenv:Client</faultcode><faultstring>System.ListException: List index out of bounds: 0

Class.InboundLinxUserRegistration.Registration: line 28, column 30

External entry point

</faultstring>

Hi All,   please help with the following code

 

            global class InboundLinxUserRegistration {
   global class dtRegistrationInput {
      webservice Integer UserId;
      webservice String First_Name;
      webservice String Last_Name;
      webservice String Email_Address;
      webservice String Status;
      webservice String 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 String status;
       webservice String Message_Text;
      }
     
      public webservice static dtRegistrationOutput Registration(dtRegistrationInput Registration){
           dtRegistrationOutput retvalue=new dtRegistrationOutput();
           retvalue.status='Success';
         return retvalue;
        
         List<Account> user=[select National_Code__c, FirstName,LastName,PersonEmail,Account_Status_NES__c,Primary_Parent_vod__c,Primary_Province_NES__c,Primary_City_NES__c,Primary_Postal_Code_NES__c,Primary_Address_1_NES__c,Specialty_1_vod__c, RecordtypeId from Account where National_Code__c=:Registration.UserId];
           if(user.size()==0) {
                 retvalue.status='Failur';
                 retvalue.Message_Text='Record Not Found';
              }else {
                    
                    
                     user[0].National_Code__c=String.valueOf(Registration.UserId); // HERE THE ERROR
                     user[0].FirstName=Registration.First_Name;
                     user[0].LastName=Registration.Last_Name;
                     user[0].PersonEmail=Registration.Email_Address;
                     user[0].Account_Status_NES__c=Registration.Status;
                     user[0].Primary_Parent_vod__c=Registration.Workplace_Id;
                     user[0].Primary_Province_NES__c=Registration.Workplace_Province;
                     user[0].Primary_City_NES__c=Registration.Workplace_City;
                     user[0].Primary_Postal_Code_NES__c=Registration.Workplace_Postal_Code;
                     user[0].Primary_Address_1_NES__c=Registration.Workplace_Address;
                     user[0].Specialty_1_vod__c=Registration.Speciality;
                     user[0].recordtypeId=Registration.Record_Type;
                     try{
                          insert user[0];
                         } catch (Exception e){
                            retValue.Status='Failure';
                            retValue.Message_Text= e.getMessage();
                           }
             }
          return retvalue;
       }
 } 

a

nd the error is 

                                  Error: Compile Error: Invalid bind expression type of Integer for column of type String at line 27 column 296

Hi,

 

         In apex class ,

 

    webservice Integer UserId;

      then i want to insert this value in to SFDC Account field which is text datatype, how can i do this