Deduct credits

hello everyone to glide.
I have this situation that I cannot resolve.
I have a table with requests for quotations and one with registered companies.
I would like companies that are subscribers to have 10 credits that are deducted as they view a request and when they reach 0 the subscription is canceled.
I can’t get an action that works on two tables but I can only do it on one table.

If you need to do a Set Column Values or Increment action on a column in another table, then the usual way to do that is to first create a single relation between the two tables, and then you can perform the action through that relation.

thanks @Darren_Murphy then in table A I create a column with relation to a column of table B if I understand correctly with the action of scaling 1 credit

Not exactly.
You cannot assign actions directly to relations, but you can perform actions through relations.

For example, in your case you may have a relation that joins your Requests table to your Companies table. When a user submits a request, you can assign an action that will increment (by -1) the credits column in your Companies table via that relation.

@Darren_Murphy hmmm ci provo

@Darren_Murphy I found the report but I can’t :sob:

I imagine you have an inline list of requests? Create a conditional custom action for the inline list that increments a “viewedRequests” column by 1 when viewedRequests < 6 else some other action like Show Notification > “You’ve used all your requests”

@Ferdinando_Fogacci , riepilogando:

  1. Richieste: è la tabella in cui gli utenti privati inseriscono le richieste di preventivo.
  2. Imprese: è la tabella in sui sono registrate le imprese che possono fare offerte visualizzando le richieste.

Per prima cosa, a prescindere da tutto, nota bene questo:
→ la tabella imprese corrisponde alla tabella utenti della tua applicazione, questo perché tu hai bisogno che un’azienda sia registrata per poterle concedere il diritto di visualizzare le richieste; inoltre, l’azienda dispone di crediti, finiti i quali non può visualizzare ulteriori richieste

  • le richieste le inseriscono i privati (vedremo poi se anche questi privati dovranno essere degli utenti iscritti al sito oppure no… mi dirai più avanti)

Premesso che lo scenario è quello sopra riportato, puoi procedere così:

  1. crea nella tabella Imprese una colonna numerica e chiamala “crediti consumati”
  2. crea nella tabella Richieste due colonne:
  • una colonna Template, che chiamerai “utente corrente” grazie alla quale in tutte le righe della tabella Richieste verrà spalmata automaticamente la mail dell’utente attuale della tua applicazione

  • una colonna Relation, che chiamerai “Relazione utente” che fungerà per scrivere (o meglio: aggiornare) verso la tabella Imprese un valore

A questo punto hai una relazione singola grazie alla quale puoi scrivere qualcosa dalla tabella richieste alla tabella Imprese.

Si tratta ora di creare un’azione nuova sulla tua Collection di richieste che faccia in successione due cose:

  1. Visualizzare il dettaglio della richiesta se il credito consumato non è andato oltre una certa soglia
  2. Aggiornare il valore “crediti consumati” nella tabella Imprese

Sai realizzare questa azione?
Fammi sapere.
Ciao

2 Likes

@Roldy grazie!!!
sono riuscito a impostare le tabelle e anche l’azione funziona tutto :smiley:

1 Like

Ottimo!

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.