
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.
Note, you can also set values in the detail that aren’t based on columns in the master record as well. As a simple example, let’s say you want to set a date column named UsrMyDate to the current date. That would look like the following:
details: { MyDetail: { schemaName: "UsrMyObjectDetailSchema", entitySchemaName: "UsrMyObject", filter: { masterColumn: "Id", detailColumn: "Account" }, defaultValues: { UsrMyDate: { value: new Date() } } } }
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!