Hello,



I'm trying to learn the new Studio 8.0.6 front end development way of doing things as it is very different from the 7 versions.  I started by creating a list and I want an action menu that calls a process that will update some fields on the record and then opens it. 

 

I found this article Set up a custom action menu for list and list records | Creatio Academy that explains how to add custom actions from a list, but I cannot find a reference that shows how to do the same but instead of opening the page, to run a process and the opening a page. Is there a reference to all the existing handlers? 



I found some of them on the SysUerProfilePage but not one to run a process.

 

Thanks, 

Jose

Like 0

Like

2 comments

Hello,



You can find the answer in this community post:

https://community.creatio.com/questions/call-business-process-action-it…

Cherednichenko Nikita,

Thanks for the link but the information there works for the 7.x versions but not for the Freedom UI pages on the 8.0.6 version.

 

I figured it out how to accomplish that on a Freedom UI page by looking at the code generated by Studio when adding a button in the page that calls a process, this article Set up a custom action menu for list and list records | Creatio Academy and by the information on this link Receiving Server-Side Messages in Client-Side Code on a Creatio Freedom UI Page | Customer FX



The code looks something like this:

viewConfigDiff: /**SCHEMA_VIEW_CONFIG_DIFF*/[

    ...

    {

        "operation": "merge",

        "name": "DataTable",

        "values": {

            ...

            "fitContent": true,

            "rowToolbarItems": [

                {

                    "type": "crt.MenuItem",

                    "caption": "#ResourceString(LockAndOpenButton_caption)#",

                    "icon": "lock-button-icon",

                    "clicked": {

                        "request": "usr.LockAndOpenRecordRequest",

                        "params": {

                            "recordId": "$Items.PDS_Id",

                            "someOtherParameter": false

                        }

                    }

                }

            ]

        }                

    },

    ...

]/**SCHEMA_VIEW_CONFIG_DIFF*/,

viewModelConfig: /**SCHEMA_VIEW_MODEL_CONFIG*/

{

...

}**SCHEMA_VIEW_MODEL_CONFIG*/,

modelConfig: /**SCHEMA_MODEL_CONFIG*/

{

}/**SCHEMA_MODEL_CONFIG*/,

handlers: /**SCHEMA_HANDLERS*/[

    {

        request: "usr.LockAndOpenRecordRequest",

        /* Implementation of the custom query handler. */

        handler: async (request, next) => {

            /* Get an instance of the singleton service that opens pages. */

            const handlerChain = sdk.HandlerChainService.instance;

            /* Send a crt.RunBusinessProcessRequest system query that runs a process. */

            result = await handlerChain.process({

                type: 'crt.RunBusinessProcessRequest',

                processName: "UsrProcessToRunName",

                processRunType: "RegardlessOfThePage",

                processParameters: {

                    "RecordId": request.recordId,

                    "SomeOtherParameter": request.someOtherParameter

                },

                resultParameterNames: ["ErrorMessage"],

                $context: request.$context

            });

            if (!result.success)  {

                //display error

                Terrasoft.showErrorMessage(request.$context.get("Resources.Strings.UnableTo_caption"));

            }                            

            /* Call the next handler if it exists and return its result. */

            return next?.handle(request);

        }

    },

    {

        request: "crt.HandleViewModelInitRequest",

        handler: async (request, next) => {            

            /* handle message from process */

            request.$context.ServerMessageReceivedFunc = async function(event, message) {

                if (message && message.Header && message.Header.Sender === "ProcessFailed") {                            

                    Terrasoft.showErrorMessage(Ext.decode(message.Body).MessageText);

                }        

                if (message && message.Header && message.Header.Sender === "OpenRecord") {        

                    var recordId = Ext.decode(message.Body).MessageText;                            

                    const handlerChain = request.$context.handlerChain;

                    await handlerChain.process({

                        type: 'crt.UpdateRecordRequest',

                        itemsAttributeName: "Items",

                        recordId: recordId,

                        $context: request.$context

                    });

                }

                else if (message && message.Header && message.Header.Sender === "RefreshPage") {

                    const handlerChain = request.$context.handlerChain;                            

                    await handlerChain.process({

                        type: "crt.LoadDataRequest",

                        $context: request.$context,

                        config: {

                            loadType: "reload"

                        },

                        dataSourceName: "PDS"

                    });

                }

            };

            Terrasoft.ServerChannel.on(Terrasoft.EventName.ON_MESSAGE, (await request.$context.ServerMessageReceivedFunc), request.$context);

            return next?.handle(request);

        }

    },

    {

        request: "crt.HandleViewModelDestroyRequest",

        handler: async (request, next) => {

            Terrasoft.ServerChannel.un(Terrasoft.EventName.ON_MESSAGE, (await request.$context.ServerMessageReceivedFunc), request.$context);

            return next?.handle(request);

        }

    }

] /**SCHEMA_HANDLERS*/,

converters: /**SCHEMA_CONVERTERS*/{}/**SCHEMA_CONVERTERS*/,

validators: /**SCHEMA_VALIDATORS*/{}/**SCHEMA_VALIDATORS*/

Show all comments