Question

Hi i got this error on process log while getting file attachments through web form

Error:

system.NullReferenceException: Object reference not set to an instance of an object.
   at Terrasoft.Core.Process.UsrUpdateLeadattachmentFromTempSectionMethodsWrapper.ScriptTask1Execute(ProcessExecutingContext context)
   at Terrasoft.Core.Process.ProcessFlowElement.Execute(ProcessExecutingContext context)

 

code in business process:

var leadtempfileid = Get<Guid>("LeadTempFileId");
var leadid = Get<Guid>("LeadId");

//to get Type column value for  Attachment table
var fileCode = "File";
var selFileType = new Select(UserConnection)
                  .Column("Id")
                .From("FileType")
                .Where("Code").IsEqual(Column.Parameter(fileCode))
                 as Select;

var typeId = selFileType.ExecuteScalar<Guid>();

            
//to get data from Temp Lead attachment where filetypeId equals leadtempfileid 
var attachmentId = Guid.NewGuid();

var selTempAttachment = new Select(UserConnection)
                            .Column("Name")
                            .Column("Data")
                            .Column("UsrTempLeadId")
                          .From("UsrTempLeadFile")
                          .Where("Id").IsEqual(Column.Parameter(leadtempfileid))
                             as Select;
Guid UsrTempleadId = Guid.Empty;
byte[] fileContents = null;
string fileName = null;

using (DBExecutor dbExecutor = UserConnection.EnsureDBConnection())
{
    using (IDataReader dataReader = selTempAttachment.ExecuteReader(dbExecutor))
    {
        while (dataReader.Read())
        {
            fileContents = dataReader.GetColumnValue<byte[]>("Data");
            fileName = dataReader.GetColumnValue<string>("Name");
            UsrTempleadId = dataReader.GetColumnValue<Guid>("UsrTempLeadId");
            break;
        }
    }
}  

//to insert data into Lead attachment
using (DBExecutor dbExecutor = UserConnection.EnsureDBConnection())
            {
              dbExecutor.StartTransaction();
              var insLeadFile = new Insert(UserConnection)
                          .Into("FileLead")
                        .Set("Id", Column.Parameter(attachmentId))
                        .Set("LeadId", Column.Parameter(leadid))
                        .Set("TypeId", Column.Parameter(typeId))
                        .Set("Data", Column.Parameter(fileContents))
                        .Set("Size", Column.Parameter(fileContents.Length))
                        .Set("Name", Column.Parameter(fileName)).Execute();
               dbExecutor.CommitTransaction();
            }
            
Set("UsrTempLeadId",UsrTempleadId);

return true;

 

Can anyone help on this please,

Regards,

praveen

Like 0

Like

1 comments

Dear Praveen,

This is hard to tell the exact reason for the issue. In order to find the cause please consider debugging the business process. Each business process is a C# code, which can be debugged. Here is an instruction on the debug procedure:

https://academy.bpmonline.com/documents/technic-sdk/7-13/server-code-debugging

Regards,

Anastasia

Show all comments