# Button

### Button

controlType button olduğunda tıklandığında yapılabilecek işlemin scripti yazılabillir. Rowaction eklenebilir.

#### Record İçinde Kullanımı:

![](/files/YpQSxuSUVujaOoBrrXAu)

```
     {
              "id": "BarcodeBtn",
              "xSpan": 1,
              "controlType": "button",
              "buttonType": "icon",
              "label": "Barcode Read",
              "svgIcon": "barcode-scan",
              "disabled": false,
              "color": "accent",
              "rowAction": {
                "requirements": [],
                "name": "",
                "icon": "",
                "startupMsg": "Are you sure?",
                "successMsg": "Succsessfully.",
                "failMsg": "Failed!",
                "queue": [
                  {
                    "name": "script",
                    "script": "(async () => {\n  try {\n    let data = this.parent.recordService.formGroup.getRawValue();\n    let insertGrid = this.parent.recordService.grids['insert-quick-invoice']\n      .grid;\n\n    console.log(data.TEXT_BARCODE.length, 'data.TEXT_BARCODE.lenght');\n    let scaleBarcode = 0;\n    let barcodQuantity = 0;\n    if (\n      (data.TEXT_BARCODE.length == 12 || data.TEXT_BARCODE.length == 13) &&\n      data.TEXT_BARCODE.startsWith(28)\n    ) {\n      scaleBarcode = 1;\n    }\n    const newStock = await angus.api\n      .select({\n        Object: 'QA_STOCK_STOCKBARCODE',\n        Select: [\n          'BARCODE',\n          'STOCKID',\n          'STOCKNAME',\n          'QUANTITY',\n          'UNITNAME',\n          'VAT',\n          'UNITPRICE',\n        ],\n        Where: [\n          {\n            Column: 'BARCODE',\n            Operator: '=',\n            Value: scaleBarcode\n              ? data.TEXT_BARCODE.substring(0, 7)\n              : data.TEXT_BARCODE,\n          },\n        ],\n        Paging: {\n          Current: 1,\n          ItemsPerPage: 1,\n        },\n      })\n      .then((resp) => {\n        return resp.ResultSets?.[0]?.[0];\n      });\n    console.log('newStock', newStock);\n\n    if (!newStock) {\n      let msg = angus.languageService.staticTranslator.translate(\n        'Barcode not found. Would you like to assign this barcode?'\n      );\n      let confirmResp = await this.parent.recordService.component.angusDialog\n        .confirm(msg)\n        .toPromise();\n      if (confirmResp) {\n        const newRecordData = await this.parent.recordService.component.popupService\n          .openRecord(\n            'quick-invoice-add-stock-for-barcode',\n            null,\n            {\n              BARCODE: data.TEXT_BARCODE,\n            },\n            null,\n            'full'\n          )\n          .afterClosed()\n          .toPromise();\n        console.log('newRecordData', newRecordData);\n      }\n      this.parent.recordService.formGroup.controls.TEXT_BARCODE.setValue(null);\n      return;\n    }\n    let updated = false;\n    insertGrid.agGrid.api.forEachNode((insertRowNode) => {\n      if (!updated && newStock.STOCKNAME === insertRowNode.data.STOCKID_NAME) {\n        barcodQuantity = parseInt(data.TEXT_BARCODE.substr(7, 5)) / 1000;\n        console.log('barcodQuantity', barcodQuantity);\n        debugger;\n        if (scaleBarcode) {\n          insertGrid.changeCellValue(\n            insertRowNode,\n            'InvoicedQuantity_Value',\n            (insertRowNode.data.InvoicedQuantity_Value || 0) + barcodQuantity\n          );\n        } else {\n          insertGrid.changeCellValue(\n            insertRowNode,\n            'InvoicedQuantity_Value',\n            (insertRowNode.data.InvoicedQuantity_Value || 0) + 1\n          );\n        }\n        insertRowNode.setData(insertRowNode.data);\n        insertGrid._qty(insertRowNode);\n        this.parent.recordService.formGroup.controls.TEXT_BARCODE.setValue(\n          null\n        );\n        updated = true;\n      }\n    });\n  //stok ilk okutulduğunda çalışacak kod\n    if (!updated) {\n      let node = insertGrid.addNewRow();\n      insertGrid.changeCellValue(node, 'STOCKID', newStock.STOCKID);\n      insertGrid.changeCellValue(node, 'STOCKID_NAME', newStock.STOCKNAME);\n      insertGrid.changeCellValue(node, 'STOCKID_UNITNAME', newStock.UNITNAME);\n      insertGrid.changeCellValue(node, 'UNITPRICE', newStock.UNITPRICE);\n      insertGrid.changeCellValue(\n        node,\n        'EXCLUDEVATUNITPRICE',\n        newStock.UNITPRICE / (1 + newStock.VAT / 100)\n      );\n\n      barcodQuantity = parseInt(data.TEXT_BARCODE.substr(7, 5)) / 1000;\n      debugger;\n      console.log(barcodQuantity, 'aaaaa');\n      if (scaleBarcode) {\n        insertGrid.changeCellValue(\n          node,\n          'InvoicedQuantity_Value',\n          barcodQuantity\n        );\n      } else {\n        insertGrid.changeCellValue(node, 'InvoicedQuantity_Value', 1);\n      }\n      insertGrid.changeCellValue(node, 'TaxPercent', newStock.VAT);\n      node.setData(node.data);\n      insertGrid._qty(node);\n      this.parent.recordService.formGroup.controls.TEXT_BARCODE.setValue(null);\n    }\n\n    scaleBarcode = 0;\n  } catch (e) {\n    this.parent.recordService.component.angusDialog.error(e);\n  }\n})();"
                  }
                ]
              }
            }
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://angus.elektraweb.com/group-1/control-types/button.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
