You need to sign in to do that
Don't have an account?

checking NULL and BLANK values
Hi.......am working with webservices. In That i have to check one field ...if it is null or blank also it should insert that record...
The filed name is Workplace_Id and in sfdc it is picklist datatype....see the code below ...and when i insert the record with space ...i am getting error like 'malformed Id'....
global class InboundLinxUserRegistration
{
global class dtRegistrationInput
{
webservice String UserId;
webservice String First_Name;
webservice String Last_Name;
webservice String Email_Address;
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;
}
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();
List<Account> account = [select National_Code__c,PersonEmail from Account where National_Code__c=:userregistration.UserId OR PersonEmail=:userregistration.Email_Address];
RecordType rec=[Select Id from RecordType where Name='NVS Profesional WEB'];
Id RT=rec.Id;
If(account.size()>0)
{
retvalue.mydate=system.today();
retvalue.added='false';
retvalue.Message_Text='Duplicate';
}else{
Account acc=new Account();
If((userregistration.Workplace_Id!=NULL)||(userregistration.Workplace_Id!=''))
{
acc.Primary_Parent_vod__c=userregistration.Workplace_Id;
}
String Med='MED-';
acc.National_Code__c=Med+userregistration.UserId;
acc.FirstName=userregistration.First_Name;
acc.LastName=userregistration.Last_Name;
acc.PersonEmail=userregistration.Email_Address;
acc.Account_Status_NES__c='Pending Approval';
acc.Primary_Address_2_NES__c=userregistration.Workplace_Name;
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=RT;
try{
insert acc;
retvalue.added='True';
retvalue.Message_Text='Registration Successfull';
} catch (Exception e){
retvalue.mydate=system.today();
retvalue.added='false';
retvalue.Message_Text=e.getMessage();
}
}
return retvalue;
}
}
what is the datatype of the account field "Primary_Parent_vod__c" ? If its of relationship type then It can only assigned with 15/18 digit salesforce ids.