Is it possible to receives parameters from a process, in a client module, when run a business process called from Freedom?
Dear colleagues,
In Classic UI when ran a process we can get resultParameterValues in Client Code.
I need to do the same but in Freedom UI client module,
I saw some code like this in Academy, Community and so on, but didn't any who shows us how to get process output paramaters
const handlerChain = sdk.HandlerChainService.instance; const result = await handlerChain.process({ type: "crt.RunBusinessProcessRequest", processName: "UsrSomeProcess", processParameters: { AccountId: await request.$context.Id, InputParameter1: "Some Value 1", InputParameter2: "Some Value 2" }, $context: request.$context }); if (result.success) { // process was sucessfully executed }
Please help
Thanks
Julio Falcón
Like
I saw in the debugging is there some resultParameterValues in the response, but is null and I have one output parameter?
Julio.Falcon_Nodos,
Solved! due the debugging resultParameterNames element I tried and works, here the result
// Inicialize Process input parameters var ClienteObject = await request.$context.NCSDetalleDelPedidoDS_NCSCuenta_kn04jps; var LugarPobladoObject = await request.$context.NCSDetalleDelPedidoDS_NCSLugarPoblado_g8rmatm; var ProductoObject = await request.$context.NCSDetalleDelPedidoDS_NCSProducto_cuzrngv; if ( ClienteObject == null || LugarPobladoObject == null || ProductoObject == null ) { await next?.handle(request); } /// Run process const handlerChain = sdk.HandlerChainService.instance; const result = await handlerChain.process({ type: "crt.RunBusinessProcessRequest", processName: "NCSPrecioFinalProductoPedido", processParameters: { DetallePedidoID: await request.$context.Id, ClienteID: ClienteObject.value, LugarPobladoID: LugarPobladoObject.value, ProductoID: ProductoObject.value }, /* Process Output Paramters */ "resultParameterNames": [ "PrecioFinal", "ProcessesRanOK" ], $context: request.$context }); // Result is OK? if ( result.success && result.resultParameterValues[ "ProcessesRanOK" ] ) { // OK, get price request.$context.NCSDetalleDelPedidoDS_NCSPrecio_leqtalu = result.resultParameterValues[ "PrecioFinal" ]; } else { // Some error msg console.log( "Error getting price" ) }
Julio.Falcon_Nodos,
Julio, excellent find - I assume the start of the process needs to be marked as "run in background" = false? Can you check if your process is marked that way?
Ryan
Ryan Farley,
Hi Ryan,
Yes, I have configured it as you indicate. Happy to help you!
Julio