Creatio development guide
PDF
This documentation is valid for Creatio version 7.16.0. We recommend using the newest version of Creatio documentation.

How to save the record without closing the edit page which is opened by the business process

Glossary Item Box

Introduction

If the record edit page is opened by the [Open edit page] business process element, the saving of the record (by clicking the [Save] button or by the this.save() method in the schema source code) will cause the closing of the page. Edit page is being closed even if the [Open edit page] element is not complete (configured in the [When is the element considered complete?] element property).

If you need to save the record several times without closing the edit page, pass the configuration object with the isSilent property set to true to the this.save() method. Example:

this.save({isSilent : true});

Case description

Create a business process that will open the invoice edit page. Save the Id of the edited record in the process parameter. In the source code of the edit page schema implement the program logic of saving the record each time the [Product in invoice] detail is being modified. Ensure the ability to edit detail records without closing the invoice edit page.

Case implementation

1. Business process creation

To do so, execute the following steps.

1.1 Create business process

In the [Configuration] section execute the [Add] – [Business process] action (Fig. 1).

Fig. 1. [Add] – [Business process] action

In the opened process designer set the following values for the properties (Fig. 2):

  • [Title] – "Open Invoice Page".
  • [Code] – "UsrOpenInvoicePage".

Fig. 2. The properties of the business process

1.2 Add parameter

Add the parameter to the business process created on the previous step. This parameter will store the Id of the opened order record. Set following properties for the parameter (Fig. 3):

  • [Title] – "Invoice Id".
  • [Code] – "InvoiceId".
  • [Data type] – "Unique identifier".

Fig. 3. The properties for the parameter of the business process

1.3 Add the [ScriptTask] element

You can find the value of the invoice record Id from the browser navigation bar by opening a record for editing (Fig. 4).

Fig. 4. Getting the record Id

This value can be saved to the InvoiceId parameter by the program code executed by the [ScriptTask] element.

For this add the [ScriptTask] element to the business process. The [Title] property of the element can be set to "Set Invoice Id". The element can execute following program code

Set<Guid>("InvoiceId", new Guid("3c2b6d9f-4c1e-4364-99f2-53956562b606"));
return true;

The InvoiceId parameter is set here. The instance of the Guid class is created on the basis of the string with the invoice record Id obtained from the browser navigation bar (Fig. 5).

Fig. 5. [ScriptTask] element properties

The Id can be obtained by the instance of the EntitySchemaQuery class (see “The use of EntitySchemaQuery for creation of queries in database”).

1.5. Add the [Open edit page] element

Use the [Open edit page] element to open the page for editing during the process execution. Set following properties for this element (Fig. 6):

  • [Title] – "Open invoice Page".
  • [Which page to open?] [Which page to open?] – "Invoice".
  • [Editing mode] – "Edit existing record".
  • [Record Id] – select the [Invoice Id] process parameter added on the Step 1.2.
  • [Recommendation for filling in the page] – "Edit product in invoice detail".
  • [When element is considered complete?] – "Immediately after saving the record".

Fig. 6. [Open edit page] element properties

Save the business process to apply changes.

The start of the business process will open the record edit page which will be automatically closed when saving (Fig. 7).

Fig. 7. Edit page opened by the business process

2. Add the program logic to the edit page schema

To save the record when modifying the [Product in invoice] detail without closing the edit page, execute the following steps.

2.1 Add a replacing schema of the invoice edit page

The procedure for creating a replacing schema of the edit page is covered in the “Creating a custom client module schema” article. Select the "Invoice edit page" (InvoicePageV2) schema as a parent object.

2.2 Override the onDetailChanged() method

In the replacing schema of the invoice edit page override the onDetailChanged() method implemented in the BaseEntityPage base schema. This method is the handler of the received message about modification of the detail on the edit page.

To ensure editing of the records of the [Product in invoice] detail without closing the invoice edit page, add the following source code to the schema.

define("InvoicePageV2", [], function() {
    return {
        entitySchemaName: "Invoice",
        methods: {
            // The handler for the detail change message.
            onDetailChanged: function(detail, args) {
                this.callParent(arguments);
                // Only for the [Products in invoice] detail
                if (detail.schemaName === "InvoiceProductDetailV2") {
                    // Save a record with the automatic closing of the edit page.
                    //this.save();
                    // Save the record without closing the edit page.
                    this.save({isSilent : true});
                }
            }
        },
        diff: /**SCHEMA_DIFF*/[
        ]/**SCHEMA_DIFF*/
    };
});

Save the schema to apply changes.

As a result, after start of the business process the record edit page will open (Fig. 7). The page will be closed only after clicking the [Save] button. The record opened for edit will be saved after each modification of the [Product in invoice] detail without closing the edit page.

© Creatio 2002-2020.

Did you find this information useful?

How can we improve it?