When SelectQuery returns zero records call a business process
Hi,
We have a environment where Creatio is System of engagement and core processing is done by backend system. When we query in the Creatio (say using Search field) Creatio invokes SelectQuery -- so how can trap the row count it returns and call a business process if it is zero -- the business process will invoke a API which gets the data from backend application and updates creatio
Just business process with ability to inovke API and load Creatio objects is ready and working fine just how to invoke from Search (from Freedom UI)
Thanks and Regards
Like
The list component has a couple of attributes you can use for this. You'll add a handler for the "crt.HandleViewModelAttributeChangeRequest" request and listen for changes to these attributes. There are a few attributes you could use, one that is ListName_NoItems (boolean) (or "DataTable_NoFilteredItems" for when the list is filtered) or ListName_Items (array of items). If your list component is named "DataGrid_ysopiif", your attribute names would be "DataGrid_ysopiif_NoItems", etc.
Add something like the following to the handlers of the page with the list:
{ request: "crt.HandleViewModelAttributeChangeRequest", handler: async (request, next) => { if (request.attributeName === "DataTable_NoItems" || request.attributeName === "DataTable_NoFilteredItems") { if (request.value) { // no records returned for list Terrasoft.showInformation("No results returned!"); } } return next?.handle(request); } }
Ryan
The list component has a couple of attributes you can use for this. You'll add a handler for the "crt.HandleViewModelAttributeChangeRequest" request and listen for changes to these attributes. There are a few attributes you could use, one that is ListName_NoItems (boolean) (or "DataTable_NoFilteredItems" for when the list is filtered) or ListName_Items (array of items). If your list component is named "DataGrid_ysopiif", your attribute names would be "DataGrid_ysopiif_NoItems", etc.
Add something like the following to the handlers of the page with the list:
{ request: "crt.HandleViewModelAttributeChangeRequest", handler: async (request, next) => { if (request.attributeName === "DataTable_NoItems" || request.attributeName === "DataTable_NoFilteredItems") { if (request.value) { // no records returned for list Terrasoft.showInformation("No results returned!"); } } return next?.handle(request); } }
Ryan
Ryan thanks -- moved to Data_grid and used the following code and it works.
Now to see how to fix a filter which can show only records which are modified in last 5 mins (out of box gives in hours only)
handlers: /**SCHEMA_HANDLERS*/[
{
request: "crt.RefreshedDataGrid",
handler: async (request, next) => {
const context = await request.$context;
const list = await context.DataGrid_cdjhzhp;
const listCount = list?.length ?? 0;
if ( listCount == 0 && await request.$context.SearchFilter_fvbn39g_SearchValue.__zone_symbol__value
!= null ){
const uxClaimID= await request.$context.SearchFilter_fvbn39g_SearchValue.__zone_symbol__value
;
console.log("Claim Id = " + uxClaimID);
const result = await request.$context.executeRequest({
type: "crt.RunBusinessProcessRequest",
processName: "HC_ClaimACID",
processParameters: { ClaimID: uxClaimID },
//resultParameterNames: ["HC_ClaimGUID"],
$context: request.$context
});
//if (await result.success) {
// }
}
return next?.handle(request);
}
}