You need to sign in to do that
Don't have an account?
Integer to Text In Apex code error
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
can you please try the following line of code and let me know the error you are getting
user[0].National_Code__c = Registration.UserId;
All Answers
I hope the data type of user[0].National_Code__c is string. correct me if wrong.
can you please try the following line of code.
user[0].National_Code__c=(String)Registration.UserId;
Hi srikanth,
Actually the National_Code__c is a text field. and also tried with (String), but not working
1)can you please check if the following query is running properly
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
because National_Code__c and Registration.UserId are of different datatypes
2) can you comment the line user[0].Nationa..... and check what error you are getting
Hi Srikanth,
ya tried with that, everything is fine when i comment that line.
can you please try the following line of code and let me know the error you are getting
user[0].National_Code__c = Registration.UserId;
Hi Srikanth,
Thanx for your precious time. Its solved, i changed the webservice field to ID. thankyou man