Thanks to Joe, I was able to put the following script together that adds a custom menu option to trigger autocrat by using a fake form submission.
My next step is to automatically trigger the script when a row is added by Jotform.
function triggerFormSubmission() {
var formId = '[ENTER YOUR FORM ID HERE]'; // Replace with your actual form ID from the Edit Form screen.
var form = FormApp.openById(formId);
// Create a fake form response to trigger the form submission event
var fakeResponse = form.createResponse();
var items = form.getItems();
items.forEach(function(item) {
if (item.getType() === FormApp.ItemType.TEXT) {
fakeResponse.withItemResponse(item.asTextItem().createResponse('Script run'));
}
});
// Submit the fake form response to trigger the form submission trigger
fakeResponse.submit();
}function myFunction() {
}
// add custom menu to update form
// the onOpen function opens automatically. You do not need a separate trigger.
function onOpen() {
var ui = SpreadsheetApp.getUi();
ui.createMenu('Autocrat')
// .addItem('Clear Autocrat status, submit a fake form, and run Autocrat', 'clrCell')
// .addSeparator()
.addItem('Process Applications', 'triggerFormSubmission')
.addToUi();
}