# Smart Views, Smart actions, EmberJS send record data to smart action

**URL:** <https://community.forestadmin.com/t/smart-views-smart-actions-emberjs-send-record-data-to-smart-action/2730>\
**Category:** Help me!\
**Created:** [June 18, 2021, 11:10am UTC](https://community.forestadmin.com/t/smart-views-smart-actions-emberjs-send-record-data-to-smart-action/2730 "2021-06-18T11:10:15Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Benjamin](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/benjamin/32/2127_2.png) [@Benjamin](https://community.forestadmin.com/u/Benjamin)\
**Post date:** [June 18, 2021, 11:10am UTC](https://community.forestadmin.com/t/smart-views-smart-actions-emberjs-send-record-data-to-smart-action/2730/1 "2021-06-18T11:10:15Z")

</div>

Hello,

I have a two questions concerning smart views (using EmberJS) :

- Is it possible to send the product data ( {{ product.name }}, {{ product.price }} … ) in a route using a smart action ? Because i need to send the selected product to my API and i need this data.

- I have a {{ product.price }} and i’ve been trying to divide that number doing {{ product.price / 100 }} but it does not work, is it possible to divide or sum variables in smart views?

Here is how my smartView works:

```javascript
<div class="l-gallery-view-container">
  <section class="c-gallery">
    {{#each @records as |record|}}
    <div class="main-content">
      {{#each-in record.forest-products as |key product|}}
      <div class="row">
        <LinkTo
          class="c-gallery__image-container"
        > 
          <img class="c-gallery__image" src="tshirt.png">
        </LinkTo>
        <div class="select-row"><b>Numéro du produit :</b> {{ product.id }}</div>
      <div class="select-row"><b>Nom du produit :</b> {{ product.name }}</div>
      <div class="select-row"><b>Prix : </b>{{ product.price }} €</div>
        <Button::BetaButton
          @type="primary"
          @text="Ajouter cet article"
          @action={{fn this.triggerSmartAction @collection 'Ajouter cet article' record}}
        />
      </div>
      {{/each-in}}
      </div>
    {{/each}}
  </section>
  
  <Table::TableFooter
    @collection={{@collection}}
    @viewList={{@viewList}}
    @records={{@records}}
    @currentPage={{@currentPage}}
    @numberOfPages={{@numberOfPages}}
    @recordsCount={{@recordsCount}}
    @isLoading={{@isLoading}}
    @fetchRecords={{@fetchRecords}}
  />
</div>

```

```javascript
import Component from '@glimmer/component';
import { action } from '@ember/object';
import { triggerSmartAction, deleteRecords, getCollectionId, loadExternalStyle, loadExternalJavascript } from 'client/utils/smart-view-utils';

export default class extends Component {
  @action
  triggerSmartAction(...args) {
    return triggerSmartAction(this, ...args);
  }

  @action
  deleteRecords(...args) {
    return deleteRecords(this, ...args);
  }
}

```

the record.forest-products in the each-in are provided by an API and displayed in a model table columns as an object :

```javascript
collection('orderProduct', {
    actions: [{
        name: 'Ajouter un article',
        type: 'single',
        endpoint: '/forest/orderProduct/:recordId/addArticle',
    }],
    fields: [{
        field: 'products',
        type: 'Object',
        get: (orders) => {
            return models['service'].findOne({
                where: {id: orders.serviceId}
            }).then((service) => {
                return axios.get(myURL, {
                    headers: {
                        'Content-Type': 'application/json',
                        'Authorization': 'Bearer ' + process.env.SECRET
                    },
                }).then(products => {
                    return products.data.products
                }).catch(err => {
                    console.log(err)
                });
            })
        },
    }],
    segments: [],
});

```

Is there a way to get the data ? Or a way to make an external call inside a smart view with specific data ?

Thanks

---

<div class="post-metadata">

**Author:** ![anon62739609](https://avatars.discourse-cdn.com/v4/letter/a/c2a13f/32.png) [@anon62739609](https://community.forestadmin.com/u/anon62739609)\
**Post date:** [June 18, 2021, 2:42pm UTC](https://community.forestadmin.com/t/smart-views-smart-actions-emberjs-send-record-data-to-smart-action/2730/2 "2021-06-18T14:42:13Z")

</div>

Hello @Benjamin,

For your second question we are using [ember-math-helpers](https://shipshapecode.github.io/ember-math-helpers/docs/api/helpers/div), so you can simply do

```javascript
{{div product.price 100}}

```

for the first one I’ll need more investigation

---

<div class="post-metadata">

**Author:** ![Benjamin](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/benjamin/32/2127_2.png) [@Benjamin](https://community.forestadmin.com/u/Benjamin)\
**Post date:** [June 18, 2021, 3:16pm UTC](https://community.forestadmin.com/t/smart-views-smart-actions-emberjs-send-record-data-to-smart-action/2730/4 "2021-06-18T15:16:37Z")

</div>

Thanks! As for the ember-math, do i have to add an import or anything in my component ?  
It tried using it as below:

```javascript
<div class="select-row"><b>Prix : </b> {{div product.price 100}} </div>

```

but i get an error in my console :

```javascript
Error: Compile Error: Unexpected Helper div @ 0..0

```

---

<div class="post-metadata">

**Author:** ![Benjamin](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/benjamin/32/2127_2.png) [@Benjamin](https://community.forestadmin.com/u/Benjamin)\
**Post date:** [June 22, 2021, 9:11am UTC](https://community.forestadmin.com/t/smart-views-smart-actions-emberjs-send-record-data-to-smart-action/2730/5 "2021-06-22T09:11:21Z")

</div>

Hello, have you been able to investigate ?

---

<div class="post-metadata">

**Author:** ![anon62739609](https://avatars.discourse-cdn.com/v4/letter/a/c2a13f/32.png) [@anon62739609](https://community.forestadmin.com/u/anon62739609)\
**Post date:** [June 22, 2021, 1:05pm UTC](https://community.forestadmin.com/t/smart-views-smart-actions-emberjs-send-record-data-to-smart-action/2730/6 "2021-06-22T13:05:04Z")

</div>

Sorry @Benjamin for the long time to reply I’ve been busy.

So for the `{{div}}` my bad it’s not included 😓. I tried too include them back, I’ll let you know once it gets to production.

For passing parameters to your smart action, it’s on our roadmap. We will let you know once we will have a way to do it

---

<div class="post-metadata">

**Author:** ![Benjamin](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/benjamin/32/2127_2.png) [@Benjamin](https://community.forestadmin.com/u/Benjamin)\
**Post date:** [June 22, 2021, 1:12pm UTC](https://community.forestadmin.com/t/smart-views-smart-actions-emberjs-send-record-data-to-smart-action/2730/7 "2021-06-22T13:12:12Z")

</div>

Alright, understood. Please let me know once it is released, i’m going to need it.

Thanks!

---

<div class="post-metadata">

**Author:** ![anon62739609](https://avatars.discourse-cdn.com/v4/letter/a/c2a13f/32.png) [@anon62739609](https://community.forestadmin.com/u/anon62739609)\
**Post date:** [June 22, 2021, 3:05pm UTC](https://community.forestadmin.com/t/smart-views-smart-actions-emberjs-send-record-data-to-smart-action/2730/8 "2021-06-22T15:05:47Z")

</div>

The `{{div }}` should be now availablke after a refresh 😉

---

<div class="post-metadata">

**Author:** ![Benjamin](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/benjamin/32/2127_2.png) [@Benjamin](https://community.forestadmin.com/u/Benjamin)\
**Post date:** [June 22, 2021, 3:12pm UTC](https://community.forestadmin.com/t/smart-views-smart-actions-emberjs-send-record-data-to-smart-action/2730/9 "2021-06-22T15:12:05Z")

</div>

That part is working now thanks ! I only need a way to pass parameters now ^^

---

<div class="post-metadata">

**Author:** ![Benjamin](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/benjamin/32/2127_2.png) [@Benjamin](https://community.forestadmin.com/u/Benjamin)\
**Post date:** [June 24, 2021, 8:43am UTC](https://community.forestadmin.com/t/smart-views-smart-actions-emberjs-send-record-data-to-smart-action/2730/10 "2021-06-24T08:43:23Z")

</div>

Hello again, sorry to bother you but could I have a quick estimation on how much time it might take to implement the feature (send params to smart action). Just so I can reorganise the rest of my project.

Thanks

---

<div class="post-metadata">

**Author:** ![louis](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/louis/32/4_2.png) [@louis](https://community.forestadmin.com/u/louis)\
**Post date:** [June 24, 2021, 1:05pm UTC](https://community.forestadmin.com/t/smart-views-smart-actions-emberjs-send-record-data-to-smart-action/2730/11 "2021-06-24T13:05:00Z")

</div>

Hi @Benjamin we can’t provide you with an ETA at the moment. It’s not part of our short-term roadmap. I’ll keep you posted once we have good news!

---

<div class="post-metadata">

**Author:** ![anon90145840](https://avatars.discourse-cdn.com/v4/letter/a/ed8c4c/32.png) [@anon90145840](https://community.forestadmin.com/u/anon90145840)\
**Post date:** [August 30, 2021, 10:06am UTC](https://community.forestadmin.com/t/smart-views-smart-actions-emberjs-send-record-data-to-smart-action/2730/12 "2021-08-30T10:06:55Z")

</div>

Hello @Benjamin

We added a possibility to pass the values from the SmartView in the SmartAction. 🎉

Please take into account that the signature of `triggerSmartAction` is as follows

```javascript
function triggerSmartAction(
  context, collection, actionName, records, callback = () => {}, values = null,
)

```

So in order to correctly pass the values, you would need to pass `null` value for the callback as the 5th argument of the function.

Let me know if you need any help.
