0
votes

I'm new with JavaScript and Google App Maker and I have a doubt with a little Workflow to Approve Expense.

I have two models:

  1. Requests (Details of Request input by Widget)
| RequestedBy | TypeOfExpense | WhoApprove | WhoResponsableToExecute | Approved | Executed |
  1. TypeOfExpense (Inputed by Admin via Widget)
| Type | ApproverOfExpense | RensableToExecute |

Scenario: A user creates a request choosing type of expense >> According Type >> Approver are notified - After approved >> RespnsableToExeute are notified - Affter Execution >> User is notified.

What feature I can use to associate (or trigger) in Request with ApproverOfExpense (from TypeOfExpense) and RensableToExecute (from TypeOfExpense) when an user input the Requisition of expense.

I'm think using onCreate events in Data Source but the app can are very slow.

1
Have you take a look at Document Approval template? - developers.google.com/appmaker/templates/document-approval - Pavel Shkleinik
Thanks by reply @PavelShkleinik ! Yes I see this template But in our Worlflow the requestor don't know who is approver and executer (Is the my doubt). The approver and executer are defined by TypeOfExpense - Antonio Saraiva Junior
Just to clarify my doubt .. I need create a type of trigger to associate two or moore fields between two Database according on load a field by user - Antonio Saraiva Junior

1 Answers

0
votes

I think onCreate is the right approach. It shouldn't make things noticeably slower as all it has to do is look up a single association, which is pretty fast. So basically what it sounds like you need to do is:

In the onCreate for request:

var email = record.TypeOfExpense.ApproverOfExpense;
// Email the approver.

And then maybe in OnSave for the request:

if (oldRecord.Approved === false && record.Approved === true) {
  var email = record.TypeOfExpense.RensableToExecute;
  // Email person who needs to execute
}