You need to sign in to do that
Don't have an account?
Sandeep Kumar Gaddam
inserting the value of the field with null value through web service SOAP
Hello All,
I am new to integrations i have craeted a web service inside salesforce for creating an activity. i want to insert an activity into salesforce with some fields value as blank some times . how can i do that .
webservice static ServiceResponse CreateContactOrLeadActivityOutBoundCalls (string RecordID,
string Comentarios,
string grava,
string CampanhaRecordID,
string Status,
string DDD,
string DDI,
Integer CallDurationInSeconds,
Boolean FidelizadoParaAgent,
Datetime Reagendamento,
Datetime StartCallTime,
Datetime EndCallTime){
ServiceResponse response = new ServiceResponse();
try{
Id devRecordTypeId = Schema.SObjectType.Task.getRecordTypeInfosByName().get('Servicecloud').getRecordTypeId();// Sample RecordType on Task with Name Asia.
string CurrentObject;
if(RecordID.startsWith('003')){
CurrentObject = 'Contact';
}
else if(RecordID.startsWith('00Q')){
CurrentObject = 'Lead';
}
else{
CurrentObject = '';
}
if(null != CurrentObject && '' != CurrentObject){
if(null != Status && '' != Status){
if(CurrentObject == 'Contact'){
Contact contactRecord = [select Id, AccountID,FirstName,LastName from Contact where Id =:RecordID];
Campaign CampanhaRecord = [select Id,Name, Status from Campaign where Id =:CampanhaRecordID];
if(null != contactRecord){
Task task = new Task(ActivityDate = Date.today(),
Subject='Call',
Tipo__c = 'Outbound Call',
C_digo_do_Agente__c = AgentCode,
WhatId = CampanhaRecord.ID,
WhoId = contactRecord.ID,
OwnerId = getUserIDFromAgentCode(AgentCode) != '' ? getUserIDFromAgentCode(AgentCode) : UserInfo.getUserId(),
Status = Status,
RecordTypeID = devRecordTypeId,
CV_StartCallTime__c =StartCallTime,
CV_EndCallTime__c = EndCallTime,
CallDurationInSeconds = CallDurationInSeconds,
CV_ScheduleDate__c = Reagendamento,
Fidelizado_Para_Agent__c = FidelizadoParaAgent);
insert task;
in the above code i only want (WhoID and WHATID) as required and all other filed can be blank while inserting.
Please help me
Thanks in Advance
I am new to integrations i have craeted a web service inside salesforce for creating an activity. i want to insert an activity into salesforce with some fields value as blank some times . how can i do that .
webservice static ServiceResponse CreateContactOrLeadActivityOutBoundCalls (string RecordID,
string Comentarios,
string grava,
string CampanhaRecordID,
string Status,
string DDD,
string DDI,
Integer CallDurationInSeconds,
Boolean FidelizadoParaAgent,
Datetime Reagendamento,
Datetime StartCallTime,
Datetime EndCallTime){
ServiceResponse response = new ServiceResponse();
try{
Id devRecordTypeId = Schema.SObjectType.Task.getRecordTypeInfosByName().get('Servicecloud').getRecordTypeId();// Sample RecordType on Task with Name Asia.
string CurrentObject;
if(RecordID.startsWith('003')){
CurrentObject = 'Contact';
}
else if(RecordID.startsWith('00Q')){
CurrentObject = 'Lead';
}
else{
CurrentObject = '';
}
if(null != CurrentObject && '' != CurrentObject){
if(null != Status && '' != Status){
if(CurrentObject == 'Contact'){
Contact contactRecord = [select Id, AccountID,FirstName,LastName from Contact where Id =:RecordID];
Campaign CampanhaRecord = [select Id,Name, Status from Campaign where Id =:CampanhaRecordID];
if(null != contactRecord){
Task task = new Task(ActivityDate = Date.today(),
Subject='Call',
Tipo__c = 'Outbound Call',
C_digo_do_Agente__c = AgentCode,
WhatId = CampanhaRecord.ID,
WhoId = contactRecord.ID,
OwnerId = getUserIDFromAgentCode(AgentCode) != '' ? getUserIDFromAgentCode(AgentCode) : UserInfo.getUserId(),
Status = Status,
RecordTypeID = devRecordTypeId,
CV_StartCallTime__c =StartCallTime,
CV_EndCallTime__c = EndCallTime,
CallDurationInSeconds = CallDurationInSeconds,
CV_ScheduleDate__c = Reagendamento,
Fidelizado_Para_Agent__c = FidelizadoParaAgent);
insert task;
in the above code i only want (WhoID and WHATID) as required and all other filed can be blank while inserting.
Please help me
Thanks in Advance
Below is a sample .net code
private void UpdateDEFieldToNull()
{
SoapClient ExactTargetSOAPClient = new SoapClient();
ExactTargetSOAPClient.ClientCredentials.UserName.UserName = "XXXXX";
ExactTargetSOAPClient.ClientCredentials.UserName.Password = "XXXXX";
string requestID;
string status;
DataExtensionObject DEO = new DataExtensionObject();
DEO.CustomerKey = "ExampleDE";
APIProperty EmailProperty = new APIProperty();
EmailProperty.Name = "EMAIL";
EmailProperty.Value = "example@example.com";
APIProperty NumberProperty = new NullAPIProperty();
NumberProperty.Name = "NumberField";
DEO.Properties = new APIProperty[] { EmailProperty, NumberProperty };
UpdateResult[] cresults = ExactTargetSOAPClient.Update(new UpdateOptions(), new APIObject[] { DEO }, out requestID, out status);
foreach (UpdateResult result in cresults)
{
Console.WriteLine(result.StatusMessage);
}
Console.WriteLine(requestID + ": " + status);
}
Please also follow the below link for more info
https://code.exacttarget.com/apis-sdks/soap-api/updating-a-data-extension-object-with-a-null-field-value.html
Best Regards
Naga kiran
You may already know this ,I think you can do it only by adding those two fields in the if condition and return proper error message .
if(null != contactRecord && WhatId !=null && WhoId != null ){
Let me know if you find any alternative to this.
Regards,
BDatla
i did it when i expose the field strings can have a blank value and for integer if you dont have any value then i inserted with zero. but the problem comes with datetime you have to put some value you there or it will give error . so what i did is i have created a supprate method with out that datetime field and i use it when i have a activity with out this datatine field value to be inserted . problem solved