Opening an Edit Page to Add or Edit a Record from Client Code in Creatio (formerly bpm’online)

If you need to open an edit page programmatically to add or edit a record in bpm’online, this can be easily done using the built-in openCardInChain method. This allows you to specify an edit page and indicate if you want to add a new record, or edit an exiting one. If you’re adding a record, you can supply default values for the new record. If you’re editing a record, you can supply the ID of the record you want to open in edit mode.

This allows you to do things like programmatically open the add activity screen to add a new task and automatically relate it to the record the user is on. Or, programmatically open an address record in edit mode. Or, to open the add screen for a detail programmatically based on some condition that has happened on the screen.

To edit an existing record, we will open the edit page like this. In this example, we are passing the ID of the record we want to edit as theIdToEdit variable in the code:

this.openCardInChain({
    schemaName: "UsrMyPage",
    operation: ConfigurationEnums.CardStateV2.EDIT,
    id: theIdToEdit,
    moduleId: this.sandbox.id + "_UsrMyPage"
});

You’ll also need to add ConfigurationEnums to the modules list. This means you’ll add ConifurationEnums to the module/page you’re using this code above from:

define("UsrMyCurrentPageV2", ["ConfigurationEnums"], function(ConfigurationEnums) {
 
    //....
 
});

To add a new record, we can open our edit page in add mode. We can also (optionally) supply default values for our new record. So, if our edit page has a lookup to Case (property name UsrCase), we can default the selected case by passing the case in the default values. Since this is a lookup, we need to provide the case ID and the display value, the case number. For a simple example, we’ll also default a string property on the edit page named UsrTextField to a value as well. The code would look like this:

this.openCardInChain({
    schemaName: "UsrMyPage",
    operation: ConfigurationEnums.CardStateV2.ADD,
    id: this.Terrasoft.GUID_EMPTY,
    defaultValues: [ // include default values if wanted
        {
            name: "UsrCase",
            value: myCaseId,
            displayValue: myCaseNumberText
        },
        {
            name: "UsrTextField",
            value: "This is default text"
        }
    ],
    moduleId: this.sandbox.id + "_UsrMyPage"
});

The page will open in add mode, with the default values filled in.

ABOUT THE AUTHOR

Ryan Farley

Ryan Farley is the Director of Development for Customer FX and creator of slxdeveloper.com. He's been blogging regularly about SalesLogix, now Infor CRM, since 2001 and believes in sharing with the community. His new passion for CRM is Creatio, formerly bpm'online. He loves C#, Javascript, web development, open source, and Linux. He also loves his hobby as an amateur filmmaker.

Submit a Comment

Your email address will not be published. Required fields are marked *

Subscribe To Our Newsletter

Join our mailing list to receive the latest Infor CRM (Saleslogix) and Creatio (bpm'online) news and product updates!

You have Successfully Subscribed!