Getting information from other databases

We have a microservice to send us information from other database, for example, a list of contacts, and we want to receive that information and show it in the screen (in the section of contacts) without save it in the BPM's database. How can we do this? Can we use Odata or Odata can only work with information from the BPM's database?

 

We were also trying to get a list of entities from a web service in a business process, but can we show that list on a section without saving it in BPM's database?

 

Best regards

Like 0

Like

11 comments

Dear Carolina,

Please check this article, there you can find the algorithm of how to implement such task within the system. In our development cases we usually create detail which load data from external services, but you can adjust the given example up to your business task. Please note, that it requires development skills:

https://community.bpmonline.com/articles/add-virtual-detail-page

Hope you will find it helpful!

Regrads,

Anastasia

Anastasia Botezat,

We are seeing this article but we have some problems.

 

We have a service, we have a response 200 OK but it seems that you aren't using the code we have in Visual Studio.

The service to call is a POST with two properties (two strings) in request and this struture in response:

{
    "content": [
        {
            "accountId": "IQSB263",
            "productName": "Super Savings",
            "accountStatus": "ACTIVE",
            "activationDate": "2019-07-26T14:00:46Z",
            "amount": 0.09,
            "interestRate": null,
            "maturityDate": null
        },
        {
            "accountId": "SYCQ537",
            "productName": "Fixed Deposit Product",
            "accountStatus": "ACTIVE",
            "activationDate": "2019-07-29T09:12:38Z",
            "amount": 1000.0,
            "interestRate": null,
            "maturityDate": null
        }
    ],
    "errors": []
}

 

Code in VS:

[OperationContract]
        [WebInvoke(Method = "POST", UriTemplate = "GetSavingsAccountByCustomer", RequestFormat = WebMessageFormat.Json,
            BodyStyle = WebMessageBodyStyle.Wrapped, ResponseFormat = WebMessageFormat.Json)]
        public async Task<string> GetSavingsAccountByCustomer(string url, string httpMethod)
        {
            var client = new HttpClient
            {
                BaseAddress = new Uri("http://25.80.134.70:18001/corebanking/")
            };
            //client.BaseAddress = new Uri("http://192.168.1.23:18001/corebanking/");
            client.DefaultRequestHeaders.Accept.Clear();
            client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
 
            //GetCustomers
            UsrCustomerResponse customers = new UsrCustomerResponse();
            HttpResponseMessage result = new HttpResponseMessage();
 
            result = await client.PostAsync("", new StringContent(
                new JavaScriptSerializer().Serialize(new CustomerRequest()
                {
                    Url = url,
                    HttpMethod = httpMethod
                    //Url = "GET",
                    //HttpMethod = "/account/savings/customer/8a80cb816b6a4de2016b6a52565a0000?page=0&size=5"
                })));
 
            if (result.IsSuccessStatusCode)
            {
                customers = JsonConvert.DeserializeObject<UsrCustomerResponse>(await result.Content.ReadAsStringAsync());
            }
 
            var res = new SelectQueryResponse
            {
                RowsAffected = customers.Customers.Count,
                Success = (customers.Message == "CallCenterServices.Success." ? true : false),
                Rows = customers.Customers,
                RowConfig = RowConfig,
                ErrorInfo = new ErrorInfo
                {
                    Message = customers.Message
                }
            };
 
            return JsonConvert.SerializeObject(res);
        }

 

On virtual detail in bpm, we have this code:

define("UsrSchema8Detail", ["ServiceHelper"], function(ServiceHelper) {
    return {
        entitySchemaName: "UsrEntitySavingAccount",
        methods: {
            sortColumn: this.Terrasoft.emptyFn,
            loadGridData: this.Terrasoft.emptyFn,
            init: function() {
                this.callParent(arguments);
 
                this.set("IsGridEmpty", true);
                this.set("IsGridDataLoaded", true);
 
                this.loadSearchItems();
            },
            loadSearchItems: function() {
                this.set("MaskId", Terrasoft.Mask.show({timeout: 0}));
                this.set("IsGridEmpty", true);
                this.set("IsGridLoading", true);
                this.set("IsGridDataLoaded", false);
                var url = "/account/savings/customer/8a80cb816b6a4de2016b6a52565a0000?page=0&size=5";
                var httpMethod = "POST";
                var serviceConfig = {
                    serviceName: "UsrServiceSavingsAccountByCustomer",
                    methodName: "GetSavingsAccountByCustomer",
                    timeout: 120000,
                    data: {
                    	Url: url,
                    	HttpMethod: httpMethod
                    }
                };
                this.callService(serviceConfig, function(responseJson) {
                    this.set("IsGridLoading", false);
                    this.set("IsGridDataLoaded", true);
                    if (!this.Ext.isEmpty(responseJson)) {
                        var response = this.Ext.decode(responseJson);
                        if (response.success) {
                            if (response.rowsAffected > 0) {
                                this.set("IsGridEmpty", false);
                                var esq = this.Ext.create("Terrasoft.EntitySchemaQuery", {
                                    rootSchemaName: "UsrEntitySavingAccount"
                                });
                                esq.parseResponse(response, function(result) {
                                    if (result.success) {
                                        var gridData = this.getGridData();
                                        gridData.clear();
                                        gridData.loadAll(result.collection);
                                        Terrasoft.Mask.hide(this.get("MaskId"));
                                    } else {
                                        this.showInformationDialog(result.errorInfo);
                                        Terrasoft.Mask.hide(this.get("MaskId"));
                                    }
                                }, this);
                            }
                        } else {
                            this.showInformationDialog(response.errorInfo.message);
                            Terrasoft.Mask.hide(this.get("MaskId"));
                        }
                    }
                }, this);
            }
        },
        diff: /**SCHEMA_DIFF*/[
            {
                "operation": "merge",
                "name": "DataGrid",
                "values": {
                    "type": this.Terrasoft.GridType.LISTED,
                    "listedConfig": {
                        "name": "DataGridListedConfig",
                        "items": [
                            {
                                "name": "AccountId",
                                "bindTo": "UsrAccountId",
                                "caption": "Account Id",
                                "type": Terrasoft.GridCellType.TEXT,
                                "position": {"column": 1, "colSpan": 2}
                            },
                            {
                                "name": "ProductNameCode",
                                "bindTo": "UsrProductNameCode",
                                "caption": "Product Name/Code",
                                "type": Terrasoft.GridCellType.TEXT,
                                "position": {"column": 3, "colSpan": 3}
                            },
                            {
                                "name": "AccountStatusListedGridColumn",
                                "bindTo": "UsrAccountStatus",
                                "caption": "Account Status",
                                "type": Terrasoft.GridCellType.TEXT,
                                "position": {"column": 6, "colSpan": 4}
                            },
                            {
                                "name": "ApprovedDateListedGridColumn",
                                "bindTo": "UsrApprovedDate",
                                "caption": "Approved Date",
                                "type": Terrasoft.GridCellType.DATE,
                                "position": {"column": 10, "colSpan": 4}
                            },
                            {
                                "name": "DepositAmountListedGridColumn",
                                "bindTo": "UsrDepositAmount",
                                "caption": "Deposit Amount",
                                "type": Terrasoft.GridCellType.NUMBER,
                                "position": {"column": 14, "colSpan": 4}
                            },
                            {
                                "name": "InterestRateListedGridColumn",
                                "bindTo": "UsrInterestRate",
                                "caption": "Interest Rate",
                                "type": Terrasoft.GridCellType.NUMBER,
                                "position": {"column": 18, "colSpan": 3}
                            },
                            {
                                "name": "MaturityDateListedGridColumn",
                                "bindTo": "UsrMaturityDate",
                                "caption": "Maturity Date",
                                "type": Terrasoft.GridCellType.DATE,
                                "position": {"column": 21, "colSpan": 3}
                            }
                        ]
                    },
                    "activeRowActions": [],
                    "activeRowAction": {"bindTo": "onActiveRowAction"},
                    "tiledConfig": {
                        "name": "DataGridTiledConfig",
                        "grid": {"columns": 24, "rows": 1},
                        "items": []
                    }
                }
            }/*, { "operation": "remove", "name": "ToolsButton" }*/
        ]/**SCHEMA_DIFF*/
    };
});

 

On Visual Studio, after attach to process, we can't debug.

 

Best regards.

 

Carolina Silva,

Please check the following article on server code debugging, particularly the section in the end of the article on possible debug issues.

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

Regards,

Anastasia

Anastasia Botezat,

I checked the article, but I still with the same problem.

 

 

We have this response:

{"GetSavingsAccountByCustomerResult":"{\"rowConfig\":{\"UsrAccountId\":{\"dataValueType\":1},\"UsrProductNameCode\":{\"dataValueType\":1},\"UsrAccountStatus\":{\"dataValueType\":1},\"UsrApprovedDate\":{\"dataValueType\":7},\"UsrDepositAmount\":{\"dataValueType\":5},\"UsrInterestRate\":{\"dataValueType\":5},\"UsrMaturityDate\":{\"dataValueType\":7}},\"rows\":[],\"notFoundColumns\":null,\"responseStatus\":null,\"rowsAffected\":0,\"nextPrcElReady\":false,\"success\":false,\"errorInfo\":{\"errorCode\":null,\"message\":null,\"stackTrace\":null}}"}

 

Thank you

Carolina Silva,

Please try to do the following:

1. Re-compile all items the application once more.

2. Check that you have debug settings set as in the article here:

https://academy.bpmonline.com/documents/technic-sdk/7-13/visual-studio-settings-development-file-system

3. Try not to create a project, but just upload files into the Visual Studio and go through the process once again.

Regards,

Anastasia

Anastasia Botezat,

I open Visual Studio with Terrasoft.Configuration.sln and I'm editing and  the file UsrServiceSavingsAccountByCustomer.cs

 

I tried but I'm still with the same problem.

Can you help me?

Thank you :)

Carolina Silva,

Unfortunately, it is hard to tell what exactly could cause such issue. Please capture a video of how you start the process from the very beginning, so we can check steps taken and advise with the solution.

Regards,

Anastasia

Carolina Silva,

Please start the process not from connecting to the w3wp process, but from creating a new project, adding files, compiling system, then attaching to process.

Regards,

Anastasia

Anastasia Botezat,

I'm seeing this article: https://academy.bpmonline.com/documents/technic-sdk/7-13/server-code-debugging

 

On step 3, when I add existing item, my code is different.

My code:

namespace Terrasoft.Configuration.UsrServiceSavingsAccountByCustomer
{
    using System;
    using System.Collections.Generic;
    using System.Runtime.Serialization;
    using System.ServiceModel;
    using System.ServiceModel.Activation;
    using ErrorInfo = Terrasoft.Nui.ServiceModel.DataContract.ErrorInfo;
    using SelectQueryResponse = Terrasoft.Nui.ServiceModel.DataContract.SelectQueryResponse;
    using DataValueType = Terrasoft.Nui.ServiceModel.DataContract.DataValueType;
    using EntityCollection = Terrasoft.Nui.ServiceModel.DataContract.EntityCollection;
    using Newtonsoft.Json;
    using System.Threading.Tasks;
    using System.Net.Http;
    using System.Web.Script.Serialization;
    using System.ServiceModel.Web;
    using System.Net.Http.Headers;
    using System.Text;
 
    [ServiceContract]
    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Required)]
    public class UsrServiceSavingsAccountByCustomer
    {
        [OperationContract]
        [WebInvoke(Method = "POST",
                    UriTemplate = "/GetSavingsAccountByCustomer",
                    RequestFormat = WebMessageFormat.Json,
                    BodyStyle = WebMessageBodyStyle.Wrapped,
                    ResponseFormat = WebMessageFormat.Json)]
        public async Task<string> GetSavingsAccountByCustomer(string url, string httpMethod)
        {
            var client = new HttpClient
            {
                BaseAddress = new Uri("http://192.168.1.23:18001/corebanking/")
            };
            client.DefaultRequestHeaders.Accept.Clear();
            client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
 
            //GetCustomers
            UsrCustomerResponse customers = new UsrCustomerResponse();
            HttpResponseMessage result = new HttpResponseMessage();
 
            result = await client.PostAsync("", new StringContent(
                new JavaScriptSerializer().Serialize(new CustomerRequest()
                {
                    Url = url,
                    HttpMethod = httpMethod
                    //Url = "GET",
                    //HttpMethod = "/account/savings/customer/8a80cb816b6a4de2016b6a52565a0000?page=0&size=5"
                })));
 
            if (result.IsSuccessStatusCode)
            {
                customers = JsonConvert.DeserializeObject<UsrCustomerResponse>(await result.Content.ReadAsStringAsync());
            }
 
            var res = new SelectQueryResponse
            {
                RowsAffected = customers.Customers.Count,
                Success = (customers.Message == "CallCenterServices.Success." ? true : false),
                Rows = customers.Customers,
                RowConfig = RowConfig,
                ErrorInfo = new ErrorInfo
                {
                    Message = customers.Message
                }
            };
 
            return JsonConvert.SerializeObject(customers);
        }
 
        public Dictionary<string, object> RowConfig = new Dictionary<string, object> {
            //{"Id", new { dataValueType = DataValueType.Guid }},
            {"UsrAccountId", new { dataValueType = DataValueType.Text }},
            {"UsrProductNameCode", new { dataValueType = DataValueType.Text }},
            {"UsrAccountStatus", new { dataValueType = DataValueType.Text }},
            {"UsrApprovedDate", new { dataValueType = DataValueType.DateTime }},
            {"UsrDepositAmount", new { dataValueType = DataValueType.Float }},
            {"UsrInterestRate", new { dataValueType = DataValueType.Float }},
            {"UsrMaturityDate", new { dataValueType = DataValueType.DateTime }}
        };
    }
 
    [DataContract]
    public class CustomerRequest
    {
        [DataMember]
        public string HttpMethod { get; set; }
        [DataMember]
        public string Url { get; set; }
    }
 
 
    [DataContract]
    public class UsrCustomerResponse
    {
        [DataMember]
        public string Message { get; set; }
        [DataMember]
        public EntityCollection Customers { get; set; }
        public UsrCustomerResponse()
        {
            Customers = new EntityCollection();
        }
    }
 
    public class Customer
    {
        public string accountId { get; set; }
        public string productName { get; set; }
        public string accountStatus { get; set; }
        public DateTime activationDate { get; set; }
 
        public float amount { get; set; }
        public DateTime interestRate { get; set; }
        public DateTime maturityDate { get; set; }
    }
}

Code in file UsrServiceSavingsAccountByCustomerSchema.Dev_Entity.cs

namespace Terrasoft.Configuration
{
 
	using System;
	using System.Collections.Generic;
	using System.Collections.ObjectModel;
	using System.Globalization;
	using Terrasoft.Common;
	using Terrasoft.Core;
	using Terrasoft.Core.Configuration;
 
	#region Class: UsrServiceSavingsAccountByCustomerSchema
 
	/// <exclude/>
	public class UsrServiceSavingsAccountByCustomerSchema : Terrasoft.Core.SourceCodeSchema
	{
 
		#region Constructors: Public
 
		public UsrServiceSavingsAccountByCustomerSchema(SourceCodeSchemaManager sourceCodeSchemaManager)
			: base(sourceCodeSchemaManager) {
		}
 
		public UsrServiceSavingsAccountByCustomerSchema(UsrServiceSavingsAccountByCustomerSchema source)
			: base( source) {
		}
 
		#endregion
 
		#region Methods: Protected
 
		protected override void InitializeProperties() {
			base.InitializeProperties();
			UId = new Guid("0358a0de-530f-40e1-bd81-5f19e4041bdd");
			Name = "UsrServiceSavingsAccountByCustomer";
			ParentSchemaUId = new Guid("50e3acc0-26fc-4237-a095-849a1d534bd3");
			CreatedInPackageId = new Guid("9fd09801-35cc-459d-9248-28c0060f0297");
			ZipBody = new byte[] { 31,139,8,0,0,0,0,0,4,0,237,89,91,79,219,72,20,126,71,234,127,24,249,97,101,87,200,14,236,130,216,82,168,66,104,129,74,1,74,210,237,195,106,31,38,246,9,184,56,182,59,51,14,155,141,242,223,247,140,103,124,119,130,211,74,93,173,68,30,136,51,115,174,223,185,204,241,16,210,25,240,152,186,64,198,192,24,229,209,84,216,131,40,156,250,247,9,163,194,143,66,251,51,103,35,96,115,223,133,17,157,251,225,61,239,187,110,148,132,226,108,49,72,184,136,102,192,118,150,59,4,63,9,199,93,50,90,112,1,179,227,198,10,74,13,2,112,165,72,110,95,64,8,204,119,91,168,238,80,178,63,3,27,85,250,52,240,255,73,109,104,161,211,38,13,35,15,130,103,182,237,62,106,157,55,4,189,103,44,98,87,225,52,34,39,37,223,175,19,191,202,124,78,5,69,64,4,163,174,176,115,158,138,74,144,126,125,74,128,45,238,16,75,244,15,182,16,217,194,93,22,46,105,255,160,65,2,227,69,188,141,216,10,95,197,109,196,87,44,138,96,108,227,125,141,181,44,246,26,158,4,218,46,133,124,228,173,17,27,63,48,160,30,46,216,99,202,31,121,11,197,53,8,251,82,136,184,101,235,11,76,236,145,203,252,88,108,149,25,146,111,131,34,251,18,45,2,198,143,95,181,152,11,127,11,92,87,59,127,106,161,25,20,127,169,213,62,143,81,212,32,154,197,104,204,196,15,16,157,59,248,150,248,12,102,16,10,110,150,127,72,123,16,235,103,88,36,149,173,23,60,75,169,137,147,73,224,187,196,13,40,231,164,67,53,74,30,85,145,169,145,55,49,168,74,174,26,159,238,33,60,87,225,60,122,4,115,8,226,33,242,208,64,227,246,102,52,54,118,115,154,242,231,51,243,199,48,139,3,42,164,43,134,115,1,98,157,21,107,36,72,215,128,139,15,17,155,81,129,50,208,128,33,112,78,239,65,45,165,201,211,206,122,22,121,139,145,88,4,80,97,203,87,237,47,140,198,49,120,235,244,170,210,218,172,216,42,160,209,160,83,190,8,93,34,19,246,45,23,12,61,61,37,27,156,54,21,13,73,88,176,75,244,243,3,230,153,2,215,202,133,47,43,54,206,41,195,224,250,24,126,180,43,132,39,34,83,115,144,46,84,232,150,13,207,206,40,135,190,231,49,116,68,179,98,132,76,67,170,124,227,56,123,191,239,219,123,135,71,246,158,189,255,235,155,189,163,94,111,207,113,35,6,19,26,62,162,97,142,97,85,228,173,142,43,63,149,65,246,57,76,105,18,8,29,54,93,46,216,80,93,192,74,28,4,64,153,105,109,207,136,54,155,210,218,33,120,62,149,13,234,139,47,30,62,37,84,86,131,34,77,91,151,105,96,68,49,10,105,246,58,95,49,64,134,133,218,42,234,28,153,132,25,254,188,178,133,165,146,109,228,125,217,205,40,51,188,154,52,117,135,100,52,178,61,157,50,4,17,71,231,74,225,170,17,152,117,51,115,6,250,68,125,145,129,116,27,113,209,151,25,102,26,198,110,42,107,148,38,141,172,84,220,55,27,1,151,36,31,233,156,170,86,152,117,66,76,60,43,111,139,144,34,91,56,149,226,111,90,13,81,205,108,74,49,99,1,26,41,243,183,117,251,50,79,102,164,42,50,187,149,214,113,148,48,227,226,253,186,126,226,56,21,129,134,67,85,69,57,92,21,152,147,133,203,57,162,71,61,119,114,180,119,56,57,164,191,121,176,223,75,159,14,246,15,14,15,104,15,63,239,98,68,253,164,247,11,71,0,78,14,140,134,182,149,213,200,28,127,74,76,21,22,251,138,143,18,204,76,206,71,130,138,132,15,176,9,91,207,148,94,57,145,100,235,192,144,205,129,201,188,231,89,32,110,38,95,241,156,124,219,146,98,167,166,74,3,173,94,135,27,251,62,245,250,92,165,128,74,11,171,150,139,171,157,70,231,64,25,58,15,91,38,137,103,156,184,139,158,120,127,58,69,46,144,248,231,62,217,131,226,73,198,163,25,61,141,23,50,153,5,87,86,29,39,24,202,1,13,130,1,58,5,217,113,197,109,205,99,27,228,29,17,44,1,242,134,76,105,192,193,106,138,151,134,181,27,212,74,171,6,86,100,200,159,155,100,229,113,79,162,149,255,238,88,25,185,115,164,225,112,51,219,234,157,181,214,11,68,194,194,74,214,140,170,57,83,96,218,236,35,41,111,215,244,41,178,167,148,57,250,104,59,247,211,33,142,178,133,62,218,118,73,148,106,63,173,64,42,177,218,64,186,172,117,227,165,113,229,233,94,182,36,94,109,120,173,12,165,246,69,226,123,100,181,170,134,106,105,96,189,232,131,181,179,36,57,171,181,75,186,101,145,151,184,226,26,223,114,100,85,255,176,60,109,153,234,19,63,46,45,142,89,52,7,15,233,187,154,38,73,199,248,130,212,46,240,28,226,136,251,162,63,147,70,118,148,248,33,136,232,26,251,174,100,253,226,241,113,215,221,190,13,210,134,136,25,195,19,254,251,188,45,50,185,84,18,206,235,173,199,219,244,52,170,79,178,27,7,217,239,25,90,187,14,171,63,107,48,253,207,103,207,94,126,182,63,64,16,68,47,195,231,79,28,62,29,167,24,52,49,72,40,32,197,5,31,119,85,188,213,1,66,92,245,109,213,78,156,182,201,21,253,214,131,107,215,128,103,170,176,232,64,66,122,19,167,183,75,153,237,58,72,242,12,123,25,212,94,6,181,255,203,160,134,65,45,15,89,175,157,29,37,86,221,15,149,111,207,90,238,114,106,47,105,245,139,27,201,61,132,217,4,88,163,251,235,187,133,210,219,211,146,220,131,56,38,92,254,89,109,35,67,190,164,53,153,209,131,244,219,113,90,156,112,156,250,149,84,189,110,52,217,82,127,183,154,162,150,171,198,100,177,107,26,212,69,72,227,106,51,79,198,181,2,53,103,107,39,46,145,149,29,145,159,65,173,147,215,53,103,109,92,113,100,10,117,90,116,2,111,185,38,92,235,17,250,14,32,94,213,25,91,113,40,168,150,175,42,245,209,1,133,130,65,43,107,195,96,205,205,101,213,113,154,189,19,108,118,93,83,199,197,220,223,137,158,150,231,250,205,28,249,76,74,243,127,43,200,165,26,83,157,107,154,206,197,52,29,204,59,202,247,75,211,119,71,150,89,105,196,110,173,234,213,191,144,50,186,246,240,25,0,0 };
		}
 
		#endregion
 
		#region Methods: Public
 
		public override void GetParentRealUIds(Collection<Guid> realUIds) {
			base.GetParentRealUIds(realUIds);
			realUIds.Add(new Guid("0358a0de-530f-40e1-bd81-5f19e4041bdd"));
		}
 
		#endregion
 
	}
 
	#endregion
 
}

 Is it normal?

I have access to source code on ..\Terrasoft.WebApp\Terrasoft.Configuration\Autogenerated\Src

 

Thank you

Carolina Silva,

System exports schemas as they are in the configuration. Seems you either have not saved the source code, or you are referring to two different schemas.

 

Show all comments