You need to sign in to do that
Don't have an account?
Vasundhara Velgoti 4
Flow error:Error Occurred During Flow "PSA_Order_Processes": Formula result is data type (Object), incompatible with expected data type(Text)
We are getting flow error when an integration user runs a script( C sharp code) from his environment, to insert or update data into Salesforce. Can anyone suggest us where would be the error and the resolution Please? It is a high priority task for us now
* Write scripts using Microsoft Visual C# 2008.
* ScriptMain is the entry point class of the script.*/
using System;
using System.Data;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using Microsoft.SqlServer.Dts.Pipeline.Wrapper;
using Microsoft.SqlServer.Dts.Runtime.Wrapper;
using SC_3ebc86ed4b93471e8d747bc30447ea75.csproj.WebReference;
[Microsoft.SqlServer.Dts.Pipeline.SSISScriptComponentEntryPointAttribute]
public class ScriptMain : UserComponent
{
private const int BATCH_SIZE = 10;
private static SforceService SFDC = new SforceService();
private static String strModule = "SFDC PurchaseOrder__c Update Script";
private static List<PurchaseOrder__c> listPurchaseOrder__cUpsert = new List<PurchaseOrder__c>();
private static int RowsAdded = 0;
private static int RowsUpdated = 0;
public override void FinishOutputs()
{
SendBatchToSFDC();
}
public override void PreExecute()
{
base.PreExecute();
//first create a session head object
SFDC.SessionHeaderValue = new SessionHeader();
//set the sessionId property on the header object using
//the value from the login result
SFDC.SessionHeaderValue.sessionId = Variables.SalesforceSessionId;
//reset the url endpoint property, this will cause subsequent calls
//to made to the serverURL from the login result
SFDC.Url = Variables.SalesforceEndPoint;
}
private Boolean SendBatchToSFDC()
{
String msg = "";
bool pbCancel = false;
base.PostExecute();
UpsertResult res;
PurchaseOrder__c ip;
try
{
if (listPurchaseOrder__cUpsert.Count > 0)
{
// List to Array
PurchaseOrder__c[] arrPurchaseOrder = listPurchaseOrder__cUpsert.ToArray();
// Update SF with array of PurchaseOrder
msg = "SFDC.update(arrPurchaseOrder__c)";
UpsertResult[] arrResults = SFDC.upsert("id", arrPurchaseOrder);
if (arrResults.GetUpperBound(0) != arrPurchaseOrder.GetUpperBound(0))
{
msg = "SFDC.update(arrPurchaseOrder__c) array size mismatch";
pbCancel = true;
base.ComponentMetaData.FireError(1, strModule, msg, "", 0, out pbCancel);
return(false);
}
// Check results
msg = "SFDC.update.UpsertResult[]";
for (int ii = 0; ii <= arrResults.GetUpperBound(0); ii++)
{
msg = "SFDC.update.UpsertResult[" + ii.ToString() + "]";
res = arrResults[ii];
ip = arrPurchaseOrder[ii];
// Check results
if (res.success)
{
msg = "SFDC.update.UpsertResult[" + ii.ToString() + "] succ";
if (res.created)
RowsAdded++;
else
RowsUpdated++;
UpdatedPOBuffer.AddRow();
UpdatedPOBuffer.salesforceId = res.id;
}
else
{ // Log errors
msg = "SFDC.update.UpsertResult[" + ii.ToString() + "] fail";
foreach (Error error in res.errors)
{
if (error.statusCode == StatusCode.ENTITY_IS_DELETED)
{
msg = "[" + ip.Id + "]" + error.statusCode.ToString() + ": " + error.message;
base.ComponentMetaData.FireInformation(1, strModule, msg, "", 0, ref pbCancel);
}
else
{
msg = "[" + ip.Id + "]" + error.statusCode.ToString() + ": " + error.message;
if (error.fields != null)
msg += " [" + error.fields.ToString() + "]";
base.ComponentMetaData.FireError(1, strModule, msg, "", 0, out pbCancel);
}
}
}
}
listPurchaseOrder__cUpsert.Clear();
}
return (true);
}
catch (Exception ex)
{
msg += ": " + ex.Message;
base.ComponentMetaData.FireError(1, strModule, msg, "", 0, out pbCancel);
return (false);
}
}
public override void PostExecute()
{
Variables.RowsAdded = RowsAdded;
Variables.RowsUpdated = RowsUpdated;
}
public override void PurchaseOrder_ProcessInputRow(PurchaseOrderBuffer Row)
{
String msg;
bool pbCancel = false;
msg = "";
string[] arrFieldsToNull = new string[20];
int numFieldsToNull = 0;
PurchaseOrder__c[] arrPurchaseOrder = new PurchaseOrder__c[1];
try
{
// Add each updated currency to the list
msg = "List.Add[" + Row.salesforceId + "]";
PurchaseOrder__c po = new PurchaseOrder__c();
po.Id = Row.salesforceId;
// Only set Commissionable DV if not currently Approved
if (Row.Approved == false)
{
if (!Row.CommissionableDV_IsNull)
{
po.Adj_Commissionable_DV__c = Row.CommissionableDV;
po.Adj_Commissionable_DV__cSpecified = true;
}
}
if (!Row.TotalUserCap_IsNull)
{
po.Current_UBP_Count__c = Row.TotalUserCap;
po.Current_UBP_Count__cSpecified = true;
}
if (!Row.GracePeriodEndDate_IsNull)
{
po.Grace_Period_End_Date__c = Row.GracePeriodEndDate;
po.Grace_Period_End_Date__cSpecified = true;
}
else
arrFieldsToNull[numFieldsToNull++] = "Grace_Period_End_Date__c";
if (!Row.ContractEndDateFullService_IsNull)
{
po.Contract_End_Date_Full_Service__c = Row.ContractEndDateFullService;
po.Contract_End_Date_Full_Service__cSpecified = true;
}
else
arrFieldsToNull[numFieldsToNull++] = "Contract_End_Date_Full_Service__c";
if (!Row.DLPEndDate_IsNull)
{
po.DLP_End_Date__c = Row.DLPEndDate;
po.DLP_End_Date__cSpecified = true;
}
else
arrFieldsToNull[numFieldsToNull++] = "DLP_End_Date__c";
if (!Row.OnlineArchiveEndDate_IsNull)
{
po.Online_Archive_End_Date__c = Row.OnlineArchiveEndDate;
po.Online_Archive_End_Date__cSpecified = true;
}
else
arrFieldsToNull[numFieldsToNull++] = "Online_Archive_End_Date__c";
if (!Row.RollingBilling_IsNull)
{
po.Rolling_Billing__c = Row.RollingBilling;
po.Rolling_Billing__cSpecified = true;
}
if (Row.ContractStatus_IsNull)
arrFieldsToNull[numFieldsToNull++] = "Contract_Status__c";
else
if (Row.ContractStatus == "")
arrFieldsToNull[numFieldsToNull++] = "Contract_Status__c";
else
po.Contract_Status__c = Row.ContractStatus;
if (Row.ContractReviewStatus_IsNull)
arrFieldsToNull[numFieldsToNull++] = "Contract_Review_Status__c";
else
if (Row.ContractReviewStatus == "")
arrFieldsToNull[numFieldsToNull++] = "Contract_Review_Status__c";
else
po.Contract_Review_Status__c = Row.ContractReviewStatus;
if (Row.debtOver90DaysAUD_IsNull)
po.Debtors_90_Days_Amount_AUD__c = 0;
else
po.Debtors_90_Days_Amount_AUD__c = Row.debtOver90DaysAUD;
po.Debtors_90_Days_Amount_AUD__cSpecified = true;
if (Row.TCVcurr_IsNull)
po.TCV__c = 0;
else
po.TCV__c = (double)Row.TCVcurr;
po.TCV__cSpecified = true;
// These fields need to be removed from SF - until then just blank them out
arrFieldsToNull[numFieldsToNull++] = "Services_Order_End_Date__c";
arrFieldsToNull[numFieldsToNull++] = "Contract_End_Date__c";
// Set fields to null
if (numFieldsToNull > 0)
{
string[] arrFieldsToNullSized = new string[numFieldsToNull];
for (int ii = 0; ii < numFieldsToNull; ii++)
arrFieldsToNullSized[ii] = arrFieldsToNull[ii];
po.fieldsToNull = arrFieldsToNullSized;
}
msg = "List.Add[" + po.Id + "]";
listPurchaseOrder__cUpsert.Add(po);
// Batch ready ?
if (listPurchaseOrder__cUpsert.Count >= BATCH_SIZE || Row.EndOfRowset())
if (!SendBatchToSFDC())
{
Exception exc = new Exception("SendBatchToSFDC() failed");
}
}
catch (Exception ex)
{
msg += ": " + ex.Message;
base.ComponentMetaData.FireError(1, strModule, msg, "", 0, out pbCancel);
}
}
}