Unable to get Parent Section Id in child detail page

Hey,

I am currently working on Creatio Energy 8.2 development tasks. As per my development task, I have done the following points:

  •  created section 'Concert'

“Performances” detail

 

  • set system variable: i.e. max duration = 150 minute
  •  
  • Web Service


But I'm facing issue while implementing Business logic for validating Performance Detail: "if the total duration of the concert performances exceeds the system setting value (see above), saving a performance record should not be permitted. Instead, a user should receive a message informing that no more than “N” total performances duration is allowed. “N” is the system setting value."
 

As per my approach, In 'UsrPerformanceDetailFormPage', I'm trying to get Concert Id, so that I can fetch all performance details mapped to this concert-id & calculate sum of duration of "existing performance + new performance". But unfortunately, I am unable to fetch concert id.

Please suggest me how can I validate adding new performance detail record.

Like 0

Like

1 comments

Hello,

Your task can be achieved with two approaches: client-side and backend. In both cases, it would be better to create a new column in the Concert object in which you will store a value of the current combined duration of all Performances.
1) Client-side: to put it simply, you need to create a customization of a crt.CreateRecordRequest in which depending on your logic cancel the request (just not call next?.handle(request)) or allow it. In this customized CreateRecordRequest you need to read the current value of the created column (you can use ESQ or other mechanics) and the value of your system setting (const value = await sysSettingsService.getByCode('UsrSomeSetting');). if the first value is greater than the SysSetitng then cancel the request and display a message, if not, then run a next?.handler and increase the value of a column.

2) Backend: you need to write your own logic on onSaving event using the object designer or your own EventListener. In it just like in the first variant check the value of a column and SysSetting (you can also use ESQ) and cancel the request (do not run base.OnSaving) or allow it and increase the value of a column accordingly.

Show all comments