1

I want to call Apps Script function from Golang.

I can send the Parameter from Golang but cannot make it work in runMyFunction. If I add return myParameter; - I can see the parameter I am passing but using it inside SQL to BigQuery is not working. I am getting undefined

var sql = ' SELECT column1, column2 ' +
  ' FROM  dataset.mytable WHERE SUBSTR ( column1) = "'
+ myParameter + '" ;'

My Apps Script Function:

function runMyFunction(myParameter) {
...
return myParameter;
}

In Golang, calling runMyFunction

type Message struct {
    myParameter string
}
m := Message{"1234"}
a := make([]interface{}, 1)
a[0] = m
req := script.ExecutionRequest{Function: "runMyFunction",
    Parameters: a,
    DevMode:    true}

// Make the API request.
resp, err := srv.Scripts.Run(scriptID, &req).Do()

1 Answer 1

1

Actually this is the right solution:

a := []interface{}{"1234"}
req := script.ExecutionRequest{Function: "runMyFunction",
Parameters: a,
DevMode:    true}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.