isNewMode on save event (ActivityPageV2)

Dear Comunity.

 

When a new activity-record is created (not update) I have to calculate some fields.

Normally I would do this on the server (business-process etc.).

But in this special case I need some information from the client (geo-coordinates).

I found the method "save" method in the "BaseEntityPage". It is possible to overwrite it.

But I have one problem, I could not find a way to find out if it is a new record or not.

I tried following methods/attibutes

  • this.isNewMode();
  • this.get("Operations");
  • this.isNew;

Everything brought the same result, whether I created a new data record or not: 'edit'



 

Like 0

Like

4 comments

You can try

if (!this.isAddMode() && !this.isCopyMode())

Vladimir Sokolov,

Hello. 

Thanks for the quick reply.

Unfortunately, both methods "isAddMode()" and "isCopyMode()" returns every time the same value:  false. sad

Regardless of whether I create a new data record or not.

 

Maybe "save" ist not the right method. 

But I could not finde a method like "onBeforeSave",  or something like that.

Christian Kern,

 

Hi,

 

save client-side method is the same "onBeforeSave" from the server-side logic. There is also onSaved method that is the same as "onRecordSaved" in the server logic. And the this.isAddMode() check that Vladimir mentioned works perfectly if using it both in the save and onSaved methods on the client-side.

 

You need to debug the code and find a way to make it work in the way you need the business task to be completed. Probably if you could share the code of your page and describe the task in details we could take a look at it together.

 

Best regards,

Oscar 

Hello.

 

I found the cause of my problem.

In our project we work with the ActivityMiniPage.

If you expand this AcitvityMiniPage to the normal page (ActivityPageV2)  the record is saved automatically. For this reason it is always a "change" for the system if I click on the "Save" button.

Show all comments