I'm looking to add a calculated field to a detail on a Section Edit page. I can find plenty of articles describing how calculated fields on section edit pages are implemented, but I'm not able to find any for a detail.

How I'm imagining this working is a trigger from the detail on load to calculate the column when the Edit Page is loaded. The column will be a object column, as I don't think virtual columns can be revealed in the column setup menu.

Has anyone been able to implement this functionality?

Like 0

Like

2 comments

Hi Morgan,



Indeed, there are no articles about calculated fields on a detail.



When a detail is created, there are two schemas created: detail schema and page schema. On the page schema of the detail you are able to work with attributes just like in the section. For example, you have a detail with editable list, you can create a calculated field logic (attribute with dependencies) on the detail page and logic will be working properly when you are modifying records in the detail grid.



If we are talking about your case, when you need to update some values based on a page field after detail is loaded, I think the best approach will be following:

1. Pass the value from the page to the detail. You can do that using sandbox messages or default values of the detail. Default values - is property that is passed from the page to the detail and is specified in defaultValues block. For example:

 

"UsrSchema7Detailff9f268f": {
	"schemaName": "UsrDetailSchema",
	"entitySchemaName": "usrDetailObject",
	"filter": {
		"detailColumn": "UsrMainObject",
		"masterColumn": "Id"
	},
	"defaultValues": {
		"SectionAttributeName": {
			"masterColumn": "DefaultValueName"
		}
	}
}

On the detail, you can handle both message and default value on the init function. DefaultValueName you will be able to get from this.get("DefaultValues") object. Once you get the value, set its value to some attribute.



2. Once you have the value that is used for calculations, you can override function prepareResponseCollection and use your value for calculations. This sample is on the community here.



Hope it helps!

Regards,

Dmytro

Thanks Dmytro, I'll try this method out

Show all comments