Scripts, scripts, scripts!

well, the idea is the following:

1- from glide through a webview the client makes the payment with his credit card
2- The payment gateway receives the transaction and notifies through a webhook
3- GAS receives the webhook and writes the details on the spreadsheet
4-finalize the purchase process in glide

that’s the general idea of what i’m trying to do, but i’m in an alley with the script

Just based on the error message you have, it appears that it is failing at step 2.
Sorry, I can’t really offer much more than that.

1 Like

I understand your point, and I appreciate your time … verify that the payment gateway will send the confirmation using integromat, and with that service if I found the configuration, but I need it in GAS

@Darren_Murphy @Manan_Mehta

I copied this script but wasn’t able to make it run. I bet it’s due to my poor understanding on the whole thing and the trigger setting.

Any tutorial or how can I get it started?

@Darren_Murphy hi!
Возникли проблемы с созданием столбцов, определяемых пользователем, для временного хранения входного значения.
Как это сделать?

https://docs.glideapps.com/all/reference/data-editor/user-specific-columns

Thanks. Yes, i read it. It is not clear exactly in the part “for temporary storage of the input value”.

Going back to my example, the template column is a concatenation of 3 columns: Name, Age & Sex

  • I would have 3 corresponding User Specific Columns: usc-name, usc-age, and usc-sex
  • In my form layout, I would have 3 input components. Each of those would use one of those user specific columns as the target
  • I would then have a second template column that concatenates the 3 user specific columns
  • And these two template columns are used to create a relation column, which in turn will indicate whether or not a duplicate has been created

Does that explanation help?

Yes, thanks)
So I understood you correctly the first time

According to the script, I am having difficulty to execute the notification.

    function Twilio() {
     
  var ss = SpreadsheetApp.getActive().getSheetByName("Notifications");
  var values = ss.getRange("A2:H").getValues();

  for (var i in values) {
     var row=i;
     var r = +row + 2;
     if (values[i][5] != '' && values[i][7] == '' ) {
       var number = values[i][5]
       var message = values[i][6]
       
       function sendSms(to, body) {
  var messages_url = "Your Twilio URL";

  var payload = {
    "To": to,
    "Body" : body,
    "From" : "Twilio phone number"
  };

  var options = {
    "method" : "post",
    "payload" : payload
  };

  options.headers = { 
    "Authorization" : "Basic " + Utilities.base64Encode("Your API Code")
  };

  UrlFetchApp.fetch(messages_url, options);
}
       try {
      response_data = sendSms(number, message);
      status = "sent";
    } catch(err) {
      Logger.log(err);
      status = "error";
    }
    ss.getRange(r, 8).setValue(status);
       
      
         
     }  
    if (values[i][5] == '' && values[i][7] == '' ) {
         Utilities.sleep(1000);
      var mail = values[i][2]
       var message = values[i][6]
       var row = +i + 2
       ss.getRange(row, 8).setValue("Email Sent");
         MailApp.sendEmail(mail, "Your Subject line", message, {name:"name of sender"})
        
       SpreadsheetApp.flush();
       }
  }
}

Can someone assist? @Darren_Murphy T,T

Stucked at triggering.

What happens when you try to execute the script?
Do you see an error message?
Sharing that might help us to help you…

PS. When posting code, please enclose with 4 back ticks (````) before and after (I fixed that for you)

Thanks Darren.

2:00:03 PM

2:18:49 PM

Error

Exception: Failed to send email: no recipient

Twilio

@ Code.gs:51

This is the error shown.

Okay, so that error is pretty obvious.

In the code you posted, you have the following function definintion:

But you don’t show how that function is called.
Find the line in your code that calls that function, and check the value of to at that point.

I think this code is a knock out. Check it out.

  1. Send a email based on status change.
  2. Send email to multiple columns.
  3. Send a offline email based on timestamp, After 5 hours in this case. (currently when it goes offline.)

Very very useful code.

Here is a sample spreadsheet you can test and see how it would work
Please change the status in order to see the results.
Please note in the sample sheet. you wont have the email function. Instead click on the link down

Please make a copy of this sheet. And enjoy the magic.

4 Likes

@gvalero

1 Like

Where do you put the scripts for working?

In the GSheet script editor…

Is that what you were asking?

You put them there and work on Glide?

I’m not sure I understand your question.
Scripts are generally used to extend the capabilities of Glide, or fill in the gaps to do things that Glide cannot do.

For example, there is no current way to execute time-based actions with Glide, so scripts can be used for this. There are many other examples where scripts might be used.

1 Like

oh perfect. Thanks!