Save a Record on Button Click

Hello Community!

I want to save a record on button click. How is this done from the front-end. What is the line of code that I am missing. Best Regards!

Like 0

Like

6 comments
Best reply

Petrika,

 

It doesn't save the record since the click event is handled not by the onCardAction method, but by your custom one:

click": {
						"bindTo": "onGenerateReferencePriceClick"
					},

According to your need you can use another approach of saving a record: you can call the save function directly (save method parent implementation can be found in the BaseEntityPage module):

this.save();

just add it at the beginning of the code for your button click handling.  And also you can execute methods synchronously using Terrasoft.chain method (an example of the usage can be found in this community post).

 

Best regards,

Oscar

Hi Petrika,

 

Please study the logic of the SaveRecordButton element in the BaseDataView module and the logic of the onCardAction method and the "save" tag of the button and apply the same logic to your button.

 

Best regards,

Oscar

Oscar Dylan,

Dear Oscar!

I have added the save tag , in the button diff ( image below )

I am uncertain of the lines of code I have to put in the body of the Method, that the button calls(image below)

Your help is much appreciated Oscar! Thank you

Petrika,

 

Simply add:

"tag": "save",
"markerValue": "SaveButton",
...
"click": {
						"bindTo": "onCardAction"
					}

To your button "values" and refresh the page. This will do the trick.

 

Best regards,

Oscar

Oscar,

Still Its not working.

I will give a full explanation of the problem.

I have created a button Generate Reference Price (marked with Red), which calls a web-service that populates the Collateral Price indicator detail(marked with yellow).

In the moment That I click the Generate Reference Price button i want that the information entered in the page is saved (just like clicking the Save button marked with brown). You can get a better understanding from the image below.

This is the code from the button

"operation": "insert",
				"name": "FzGeneratePrecalButton",
				"values": {
					"itemType": 5,
					"style": "blue",
					"id": "74a20850-7021-4e0a-a2e6-98bdc419f323",
					"tag": "save",
					"markerValue": "SaveButton",
					"caption": "Generate Reference Price",
                     ...
					"click": {
						"bindTo": "onGenerateReferencePriceClick"
					},
					"visible": {
						"bindTo": "FZButtonVisible"
					},
					"enabled": true
				},

And this is part of the code, of the Method that the button calls

onGenerateReferencePriceClick: function()
			{
				const tag = arguments[0] || arguments[3];
				const cardModuleSandboxId = this.getCardModuleSandboxId();
				this.sandbox.publish("onGenerateReferencePriceClick", tag, [cardModuleSandboxId]);

This is the result from the debugger

I cant find a reaon why this is not working.

Petrika,

 

It doesn't save the record since the click event is handled not by the onCardAction method, but by your custom one:

click": {
						"bindTo": "onGenerateReferencePriceClick"
					},

According to your need you can use another approach of saving a record: you can call the save function directly (save method parent implementation can be found in the BaseEntityPage module):

this.save();

just add it at the beginning of the code for your button click handling.  And also you can execute methods synchronously using Terrasoft.chain method (an example of the usage can be found in this community post).

 

Best regards,

Oscar

Thanks very much Oscar!

Show all comments