Google Sheets not automatically creating hyperlinks when multiple files are uploaded on Google forms - forms

Background:
I have a Google Form that asks clients to upload files. The form is attached to a Google Sheet where I want the files to be accessible to processing staff. A problem occurs when multiple files are uploaded. The Google sheet seems to not be able to create hyperlinks for the all the individual files.
There is a question about this already that has been resolved here:
https://stackoverflow.com/questions/70799922/google-app-script-to-convert-a-comma-seperated-list-of-urls-to-hyperlinks-in-she?answertab=modifieddesc#tab-top
The answer poses a custom function using Google App Script:
function onFormSubmit(e) {
// Get a Range reference to the cell containing the urls, possibly by using the event object passed in the form submit trigger:
var cell = e.range.getCell(1, urlColumn); // where urlColumn is the index of the column that contains the urls in question
var text = cell.getValue();
var richTextValueBuilder= SpreadsheetApp.newRichTextValue()
richTextValueBuilder.setText(text);
var urls = text.split(', ')
urls.forEach(function(url){
var startIndex = text.indexOf(url)
var endIndex = startIndex + url.length;
richTextValueBuilder.setLinkUrl(startIndex,endIndex,url)
})
cell.setRichTextValue(richTextValueBuilder.build())
}
My question is on how to use this as I have not had success.
First, when I run this script in the editor, I receive this:
TypeError: Cannot read property 'range' of undefined onFormSubmit # Code.gs:3
I'm pretty unfamiliar with java and have a working knowledge of python and am sure alot is missed in the details of how this script works.
As I understand it this error occurs if the script is run in the app script test function due to the formula being activated on an event which I believe is the submission of the form from the client.
I'm assuming that the custom function is to be set in a blank column that references the original results of the Google form links and converts them into the rich text links.
I've tested the script on the sheet on a blank column referencing the link information in the form results column and submitted a new form with the same result:
Link addresses appear as text and do not pull the documents.
Can anyone give me some clarity?

Related

How to trigger Azure function with flutter

I created an azure function in c # and set up an HTTP trigger. I'm interested in how to call this function from the flutter application. I don't need to transfer any special data because everything is already in the link I use to call the function.I’ve created a simplified view of the function to demonstrate what I want.
https://functionapp220220124204147.azurewebsites.net/api/Quercus?status=Off
When it calls this function all it needs to do is change the value of the variable from on to off
I know this is not the correct way to make a function and I should not have such variables, but this is just a simplified version
Here is a workaround given by Vikash Kumar in the Medium article regarding How to call Azure Functions API through Flutter App Code:
Created Wordle Website which has a list of legit words and allows you to input a word only from that list where we validate if an input word is a legit English word.
First, he created the Azure Cosmos DB > container in it > added a few dates, word pairs like:
Created the Azure Functions which has input binding with the Cosmos DB and gets a list of stored words on every request.
This functionality is broken into 3 segments:
Validate the input word (not null, same length, convert to uppercase both)
Check if both words are the same
Status of each letter in the input word.
The deployed function app API will be in this format: https://wordle-api.azurewebsites.net/api/CheckWord?word=
Also created the flutter in the composition of the word_field component which creates an input widget that accepts a 5 letter word in 5 boxes (1 each) which is similar to the OTP field.
And the home component builds a scaffold and puts together a page to accept 6 attempts for words.
The _checkWord handler calls the wordle-api, gets the color code, and updates the components accordingly.
Calling the Function API in the above handler and writing the code about response status and the user-defined message to the response.
var uri = Uri.https('wordle-api.azurewebsites.net', '/api/CheckWord', params);
For Complete Code, Please refer this article.

Can you get access to a pages front matter (or other data) in a eleventy (11ty) plugin

I'm creating (would like to create) an eleventy (11ty) plugin that can automatically generate Open Graph images based on a pages data. So in the template:
---
generate_og_image: true
image_text: "text which will be baked into the image"
og_image_filename: some_file_name.jpg
---
#some markdown
...
I can process each file in my .eleventy.js file via plugin using:
module.exports = function (eleventyConfig) {
eleventyConfig.addLinter("og-image-generator", function(content, inputPath, outputPath) {
title = HOW_TO_ACCESS_TEMPLATE_FRONT_MATTER
createImage(title)
});
}
But only have access to the content, inputPath and outputPath of the template.
How can I access the front matter data associated with the Template? Or is there a better way to go about this?
Answering my own question. As #moritzlost mentioned it is not possible directly. I found this workaround.
eleventyComputed allows you to dynamically assign values to keys. It also allows you to call a custom shortcode.
You can pass whatever properties you like from the template into the shortcode. In this case ogImageName the image name, ogImageTemplate a template or background image and text which is the text to be written on that background.
You can even pass in other keys from your front matter and process them as you go.
---
layout: _main.njk
title: "Some title here"
eleventyComputed:
ogImageName: "{% ogCreateImage { ogImageName: title | slug, ogImageTemplate: 'page-blank.png', text: title } %}"
---
Then in .eleventy.js or a plugin:
eleventyConfig.addShortcode("ogCreateImage", function(props) {
const imageName = props.ogImageName
const imageTemplate = props.ogImageTemplate
const imageText = props.text
console.log('-----------------ogCreateImage-----------------');
console.log(`filename: ${imageName}`);
console.log(`using template: ${imageTemplate}`);
console.log(`with the text : ${imageText}`);
// call the image creation code — return filename with extension
const imageNameWithExtension = createOGImage(imageName, imageTemplate, imageText)
return imageNameWithExtension
});
Returning the final filename which you can use in your template.
I've also come across this problem. I don't think what you're trying to do is possible at the moment. There are not many ways for a plugin to hook into the build step directly:
Transforms
Linters
Events
I think events would be the best solution. However, events also don't receive enough information to process a template in a structured way. I've opened an issue regarding this on Github. For your use-case, you'd need to get structured page data in this hook as well. Or eleventy would need to provide a build hook for each page. I suggest opening a new feature-request issue or adding a comment with your use-case to my issue above so those hooks can be implemented.
Other solutions
Another solution that requires a bit more setup for the users of your plugin would be to add your functionality as a filter instead of an automatic script that's applied to every template. This means that the users of your plugin would need to add their own template which passes the relevant data to your filter. Of course this also gives more fine-control to the user, which may be beneficial.
I use a similar approach for my site processwire.dev:
A special template loops over all posts and generates an HTML file which is used as a template for the generated preview images. This template is processed by eleventy. (source)
After the build step: I start a local server in the directory with the generated HTML files, open them using puppeteer and programmatically take a screenshot which is saved alongside the HTML templates. The HTML templates are then deleted.
This is integrated into the build step with a custom script that is executed after the eleventy build.
I've published the script used to take screenshots with Puppeteer as an NPM package (generate-preview-images), though it's very much still in alpha. But you can check the source code on Github to see how it works, maybe it helps with your plugin.

Update Binding Items Upload Collection

I'm trying to use a UploadCollection in my SAPUI5 App, to upload files and display them to the user. My page has two UploadCollections. One to upload and display PDF-Documents and one for JPG-Image files. The upload via a Odata V2 Service works perfectly well, but I ran into a difficulty displaying the uploaded files in the correct UploadCollection.
After the successful Upload of all files in both UploadCollections I'm triggering a refresh on the binding Items of both Upload Collections. Sadly this refresh is ignoring the filters which are applied to the items of each UploadCollection. This leads to the unfortunate situation, that the pdf and image files are displayed in both UploadCollections and not only in the correct Image- or PDF-UploadCollection. I would love to know why this is the case.
I've already tried to filter the binding items again, but then the request magically remembers that there has been a filter applied to the UploadCollection items from the beginning and therefore is executed with the same filter applied two times which leads to an error.
The only solution I found this far is to completely reload the page to reapply the correct filter to each Upload Collection. It would be fantastic if someone could help me with issue and possibly supply any solutions.
UploadColelction items Binding:
UC1: items="{path:'ImageSet', filters:[{path: 'Filetype', operator: 'EQ' , value1: 'IBR'}]}"
UC2: items="{path:'ImageSet', filters:[{path: 'Filetype', operator: 'EQ' , value1: 'DBR'}]}"

Refresh or Clear GUI (Apps Script Gadget Embedded in Google Site)

I have a small form that my colleagues and I often fill out that can be seen here, with source code (view-only) here. The spreadsheet that this form posts to can be seen (view-only) here.
Basically, the apps script is solely for preventing my coworkers from having to scroll through thousands of rows of a spreadsheet (this is also used for our film collection) to check in/out inventory. It will also, soon, post detailed history of the checkout in an audit spreadsheet.
I have attempted, with no success, to clear the values of the text fields after the data has been posted to the spreadsheet. What I essentially want to do is restart the GUI so that the fields are once again blank.
I have tried accessing the text fields by id but the return type is a Generic widget, which I of course can't do anything with. And since control is passed to the handler functions, the text fields can't be accessed, or at least I can't figure out how (and I looked through the documentation and online solutions for hours last night).
So the question: how can I erase/clear the values of the text fields in the GUI after values have been posted to the spreadsheet? (return from handler function to access text fields again, or restart the GUI?
I can accomplish restarting the script runs on a spreadsheet, but I have not been able to do this when it is embedded in a Google site.
The getElementById('xxxxx').setText('') approach was the right way to do it. but the way you tried to test it doesn't work... the new value would only be available in the next handler call.
/*
This function only has the desired effect if it is called within the handler
function (not within a nested function in the handler function).
*/
function restartGUI() {
var gui = UiApp.getActiveApplication();
gui.getElementById('equipmentIDField1').setText('');
gui.getElementById('equipmentIDField2').setText('');
gui.getElementById('equipmentIDField3').setText('');
gui.getElementById('studentLastNameField').setText('');
gui.getElementById('labasstLastNameField').setText('');
return gui;
}

appending a form parameter to url in code igniter

I have tried my best to search for an existing question with smiliar issue but was not able to find one. Here's my situation
I have a controller named search which accepts a parameter "search term", when this controller is called directly from URL like www.xyz.com/search/red+car it returns results and the URL in browser address bar is www.xyz.com/search/red+car but when the user submits the search from a from in webpage with same term, the results are coming fine but the URL does not reflect the search term.
If I do a redirect the form POST data is lost, although resubmitting the POSt is not a solution in my case either. I need a way to change the URL so that it shows the search term.
Thanks in advance for your help, please be gentle as this is my first question.
#Vlakarados - I am trying to use same controller to provide search results from post data and controller parameter. Both work fine but when using search form on webpage the search parameter is not reflected in URL.
#Rakesh Shetty - The actual method is very long, but here is the compressed format
build query as per post data and passed parameter.
populate view with results
render the view
Thanks everyone for suggesting various solution.
I used jquery to change the form action parameter, now when ever the dropdown selection is changed the value is appended to the action parameter. I also took out the dropdown from being part of post data.
There are 2 dropdowns one for area and other for zip code. This new approach works with bot dropdowns and my exsting code of controller works without any major change.
I used the following javascript code to create new action parameter when ever user changes the area. Same goes for ZIP code.
$("#cityname").change(function(){
var action = $(this).val();
alert(action);
$("#searchform").attr("action", "search/" + action);
});
I think I was not able to clearly explain my situation otherwise you people would have suggested this long ago.
The better way to do it is in your controller:
function search($search_query) {
// .. use your query as you normally would - display products, posts, messages
$data = array('search_query' => $search_query);
$this->load->view('search', $data);
}
// use this method as the form action
function search_proxy() {
$search_query = $this->input->post('search');
// if needed urlencode or other search query manipulation
redirect('controller/search/'.$search_query);
}
This way you will have no problems and will only work with data in your url.
Edit: The second option is yo use JavaScript - when user submit's the form, change the form's action to include the searched query in form action