Passing Values from a Page to a New Record in a Detail in Creatio

If you have a page with a detail and you need to pass values to the detail page when creating new records, you have two main choices. First, you could use an EntitySchemaQuery on the onEntityInitialized of the detail page to read the values from the record for the page. A second, better route, is to simply set the values on the new detail record automatically from the page without the need for a query or any additional code.

When you add a detail to a page, the wizard will add an entry into the page code in the details section. It looks something like this (this sample is a detail added to an account page):

details: {
    MyDetail: {
        schemaName: "UsrMyObjectDetailSchema",
        entitySchemaName: "UsrMyObject",
        filter: {
            masterColumn: "Id",
            detailColumn: "Account"
        }
    }
}

Let’s say we want to pass the account’s Type column value to the detail when we are creating new records in the detail and put it into a column named UsrDetailType in the detail. We can simply add the following to do this.

details: {
    MyDetail: {
        schemaName: "UsrMyObjectDetailSchema",
        entitySchemaName: "UsrMyObject",
        filter: {
            masterColumn: "Id",
            detailColumn: "Account"
        },
        defaultValues: {
            UsrDetailType: {masterColumn: "Type"}
        }
    }
}

What the above is saying is take the value from Type on the “master” record (in this case the Account) and put it in the column named UsrDetailType on the detail record. Note, this only applies when creating a new record in the detail. If you’re editing a record the current value in UsrDetailType won’t get overwritten. Also, keep in mind that the “defaultValues shown in the code above can have multiple sets of values you’d like to pass from the page to the detail record. For example, if we also wanted to pass Industry, in addition to Type, it would look like this:

details: {
    MyDetail: {
        schemaName: "UsrMyObjectDetailSchema",
        entitySchemaName: "UsrMyObject",
        filter: {
            masterColumn: "Id",
            detailColumn: "Account"
        },
        defaultValues: {
            UsrDetailType: {masterColumn: "Type"},
            UsrDetailIndustry: {masterColumn: "Industry"},
        }
    }
}

Of course, all of this only works if there’s a corresponding column in the detail record. This could mean an actual column in the detail object, but it could also mean an attribute on the detail page as well. Of course, if you need more flexibility, you could resort to using an EntitySchemaQuery from the detail page to read any values you need.

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!