Question

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

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"#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.

 

Log in or register to comment