Insert Address along with Contact with Data Service

Hello,

I have developed one service which inserts contact and contact-address from the third party to bpm'online. I have written below code to add contact and its Address simultaneously:

var insertContactQuery = new InsertQuery()

{

                    // Root schema name.

                    RootSchemaName = "Contact",

                    OperationType = QueryOperationType.Insert,

                    // New column values.

                    ColumnValues = new ColumnValues()

                    {

                        // Key-value collection.

                        Items = new Dictionary()

                                 {

                                     {

                                         "Account",

                                         new ColumnExpression()

                                         {

                                             ExpressionType = EntitySchemaQueryExpressionType.Parameter,

                                             ColumnPath = "Account",

                                             Parameter = new Terrasoft.Nui.ServiceModel.DataContract.Parameter()

                                             {

                                                 Value = item.AccountId,

                                                 DataValueType = DataValueType.Lookup

                                             }

                                         }

                                     },

                                     {

                                         "Name",

                                         new ColumnExpression()

                                         {

                                             ExpressionType = EntitySchemaQueryExpressionType.Parameter,

                                             ColumnPath = "Name",

                                             Parameter = new Terrasoft.Nui.ServiceModel.DataContract.Parameter()

                                             {

                                                 Value = item.StoreContactFirstName + " " + item.StoreContactLastName,

                                                 DataValueType = DataValueType.Text

                                             }

                                         }

                                     },

                                     {

                                         "MobilePhone",

                                         new ColumnExpression()

                                         {

                                             ExpressionType = EntitySchemaQueryExpressionType.Parameter,

                                             ColumnPath = "MobilePhone",

                                             Parameter = new Terrasoft.Nui.ServiceModel.DataContract.Parameter()

                                             {

                                                 Value = item.StorePhoneNumber,

                                                 DataValueType = DataValueType.Text

                                             }

                                         }

                                     },

                                     {

                                         "ContactAddress",

                                         new ColumnExpression()

                                         {

                                             ExpressionType = EntitySchemaQueryExpressionType.Parameter,

                                             ColumnPath = "Address",

                                             Parameter = new Terrasoft.Nui.ServiceModel.DataContract.Parameter()

                                             {

                                                 Value = item.StoreStreetAddress,

                                                 DataValueType = DataValueType.Text

                                             }

                                         }

                                     },

                                     {

                                         "ContactCity",

                                         new ColumnExpression()

                                         {

                                             ExpressionType = EntitySchemaQueryExpressionType.Parameter,

                                             ColumnPath = "City",

                                             Parameter = new Terrasoft.Nui.ServiceModel.DataContract.Parameter()

                                             {

                                                 Value = item.StoreCityName,

                                                 DataValueType = DataValueType.Text

                                             }

                                         }

                                     },

                                     {

                                         "ContactZip",

                                         new ColumnExpression()

                                         {

                                             ExpressionType = EntitySchemaQueryExpressionType.Parameter,

                                             ColumnPath = "Zip",

                                             Parameter = new Terrasoft.Nui.ServiceModel.DataContract.Parameter()

                                             {

                                                 Value = item.StoreZipCode,

                                                 DataValueType = DataValueType.Text

                                             }

                                         }

                                     }

                                 }

                    }

                };

am I doing something wrong? Please guide.

Like 0

Like

4 comments

Dear Riddhi,

Unfortunately, it is not possible to add data to the “Contact” and “ContactAddress” tables simultaneously using the approach that was described early. However, we can offer two ways solving the issue:

1. In order to add data via DataService please do the following:

-Create custom columns in the “Contact” object for storing the corresponding address values.

-Create a business process that will take the values from these columns and add them to the corresponding columns from the “ContactAddress” table.

Please note that we do not recommend using DataService for adding data to the database.

2. Create a web service for adding data. This approach is recommended for solving such types of the issues.

Best regards,

Norton

Norton Lingard,

Thanks, Norton. Can you please provide any reference link or example for adding records with web service? It would be really grateful.

Dear Riddhi,

Please find more information by link below:

https://academy.bpmonline.com/documents/technic-sdk/7-14/how-run-bpmonline-processes-web-service

Best regards,

Norton

Norton Lingard,

Thanks

Show all comments