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
Does anybody know which version of Creatio this works from? I'm seeming to get errors thrown when trying what Julio showed, and can't seem to track down what's causing it. We're currently running on 8.1.3, so was wondering if that might be the cause - what version were you running where it worked Julio? The error we see in the Network tab:
And the error text for reference:
The server encountered an error processing the request. The exception message is 'There was an error deserializing the object of type Terrasoft.Core.ServiceModelContract.RunProcessRequest. End element 'value' from namespace '' expected. Found element 'value' from namespace ''.'. See server logs for more details.
Checking the server logs, I don't see anything that gives much more information. I've tried using Output only and Bidirectional parameters, same result. To me, the error message seems to be saying it found what it was looking for, so I don't really understand why it should be throwing an error!
I've double checked that I'm using the right Parameter Code, and tried creating a new Parameter with a different Code to be requested to return and still get the same error.
Harvey Adcock,
I had tried this in an earlier version of Creatio and it definitely did not work, but I can't remember what version it was when I originally tried. I don't recall getting an error however, just didn't get any values back fore the params. Either way, I believe this was something that started working along the way, but I don't have any specifics.
Ryan
Thanks Ryan, yes just discovered that I was accidentally passing a Lookup, rather than the Lookup's value (the actual Id!). So user error, and the data is being returned as expected in 8.1.3 I can confirm for anyone else looking. Not the clearest error for identifying the issue!