How do you insert text into Google Sheets using Class Ui? [duplicate] - user-interface

I'm new to the world of google sheets. I was able to program very simple routines in Excel. Sorry if I couldn't find the answer anywhere on this site.
My question is simple, has 2 parts:
I would like to prompt a question box on opening the google sheet, asking a numeric value, after answering this, storing the numeric value to a specific cell, e.g. B3.
I would like to have a button on multiple pages of the sheet, prompting the same question box to edit the value.
Background:
I'm a medical doctor, I've created a sheet with many medications for small children in emergency situations. I would like a ask the user the age (and maybe later the weight, it's now calculated) of the child, so the age and weight are correct on all pages and the user is not in a hurry to find the right cell. If the user would like to edit the age, he uses the button, available on all sheets.

First, with the following function you can ask the user for the age and set it to a specific cell in a specific sheet:
function promptUserAge()
{
// Prompt for the value
var age = SpreadsheetApp.getUi().prompt("Please enter the age.").getResponseText();
// Get the sheet that you want store the value in and set the value in the cell B3
SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Patient Information").getRange("B3").setValue( age );
}
Now, since you used the phrase
so the age and weight are correct on all pages
I am not sure if you are going to set the value in multiple sheets, and are you going to do that with Sheets functions or app script. That is why I am going to include the method to set the value in all sheets, in specific cell:
function promptUserAge()
{
// Prompt for the value
var age = SpreadsheetApp.getUi().prompt("Please enter the age.").getResponseText();
//Get all pages in spreadsheet and iterate through
var sheets = SpreadsheetApp.getActiveSpreadsheet().getSheets();
for(var i = 0; i < sheets.length; i++ )
{
//Set the value in the cell B3 of the page
sheets[i].getRange("B3").setValue( age );
}
}
To get the prompt to pop-up when user opens the Spreadsheet you use call it in the onOpen function:
function onOpen(e)
{
promptUserAge();
}
And now, the part where you add the button to edit the value.
You could add a custom menu that would appear in the Spreadsheet's toolbar with a custom menu like this :
function createMenu()
{
SpreadsheetApp.getUi().createMenu("Fill information")
.addItem("Age", "promptUserAge")
.addToUi();
}
This is a good way if your users know what to look for, meaning that you have told them the custom menu exists. From my experience, some people have trouble finding the menu even if you tell them it is there, so since your background suggests you want to create an easy and fast way I would use the second method:
You could insert an image to the Spreadsheet by navigating from it's toolbar: Insert -> Image. Insert an Image that says 'Push here to edit information' in a very clear way and right click the image. You get the borders to edit the image size and in it's upper-right corner appears three dots. You click the dots and then "Assign script...". To the prompt, insert the function name without the parenthesis. In this example you would insert:
promptUserAge
Now the image works as a button to call the function.
I hope this helped.

Related

Is there a way to hide the formula in a Google sheet cell?

I want to block certain users/groups from viewing formulas in certain cells in Google sheet, but they'll have permission to edit other cells values. All they will be able to see is the result.
explanation: it's an advanced calculator. let's say that I want to give the user the ability to put values in cells A1 and B1, and in C1 the formula is =A1+B1.
I want to hide the formula in C1, so the user will only the the result.
There's a few ways to do it depending on how/who is working on the sheet. If people aren't familiar with sheets you can actually hide the formula in a row at the top by using array formulas so in the header:
={" header title" ; arrayformula(a2:a+b2:b)}
The formula would be hidden in the cell that shows the header, all the cells below would just be the calculation. If you hide the row that has the arrayformula and protect it no one will be able to see it. The only thing is you have to also protect the column otherwise if someone hardcodes a value in the column the formula will stop working.
The second option (easier but can run into more issues is the have a 'mirror' copy of the sheet they are interacting with in the same file as a hidden sheet. Basically a duplicate of the tab with all the cells a direct reference of the first tab. So:
Sheet1 = tab they interact with
Sheet2 = 'mirror' tab with every cell being ='Sheet1'!a1, but for the corresponding cell value.
As they edit Sheet the values entered in Sheet1 will show up in Sheet2, then the calculations can happen on that sheet, and then Sheet1, can just be a direct reference to that column in Sheet2. So the calculations in Sheet1 will only appear ='Sheet2'!C2. If you protect Sheet2 and hide it no one will be able to see the formulas. Sheet1 could even reference Sheet2 with an index formula like: index(column sheet2,,) which would return the entire column from sheet2.

Toggle validation hide(+) when other in open(-) SSRS

I am developing a "Dashboard Report" in SSRS Visual Studio 2010. I Am trying to put 8 charts graphs at the same location. Each chart must open from each textbox I assigned a toggle. Each chart has the visibility as Hidden and display by textbox name.
Now I am trying to make a validation which determine that only one chart must show at the time. Because when I try to see an individual chart always I have to close which was open before.
I have created a parameter to assign an InitialToggleState Expression, but I haven't succeed.
I will appreciated any good suggestion step by step. Thanks
Have you considered using a Hidden parameter to control which chart is open? By defining one you can use the textboxes to control an identifier for which chart you wish to display.
Method
First define a Hidden Pameter by creating a new parameter and setting the visibility to ‘Hidden’. I have created one called OpenChart
Create your charts (you have probably already done this by the looks of things. Set each charts visibility to be equivalent to
=iif(Parameters!OpenChart.Value = 1, false, true)
Changing the value ‘1’ to a unique number for each chart
Create your control buttons, possibly using text boxes. Create as many buttons as there are charts to disaply (you’ve probably done this already too). For each button Set the action to be a reloading of this report, using the same existing parameters, but with the OpenCahrt Parameter set to the chart identifier set in 2. Above
The report now looks like this (for 3 buttons)
Result
When the report is run and the ‘One’ textbox is clicked the output looks like this
And for 'Two' like this
And so on...
You don’t have to put the charts side by side of course, they can be layered on top of each other. I only laid them out like this for clarity.
Hopefully this will help save you from trying to validate all the charts are closed before the next one is open, because only one can be open at a time.
Please let me know if you need further clarification

Tableau, Action on Non-Map messes up Double Map

First workbook on Public Tableau allows user to hover or select datapoints on two separate maps, and other panels react accordingly (refer to tab Business Ratings)
Two maps are filtered separately, i.e. businesses in Brooklyn are selected in Brooklyn map, businesses in Ludhiana are selected in Ludhiana map, and it worked really well .... so far
Second workbook on Public Tableau adds action to Grade panel. If user hovers over a business, only that business should display on one of the maps.
But the problem, it displays on BOTH maps, which is what I don't want. And when I check the Location(Location) filter, it selects ALL locations, instead of the ones I specified. It's as if adding action to Grade totally wiped out my efforts.
How do I fix this?
I believe I solved my problem.
Before, Grand_Avg was defined as
{ EXCLUDE [Location (Location)] : AVG([Number_Rating]) }
So when I created action to select [Location (Location)], it somehow removed the filters I originally placed on [Location (Location)] for both separate maps.
But now, I defined Grand_Avg as
{ EXCLUDE [Location] : AVG([Number_Rating]) }
And now, I can create action to Hover and Select the Location in Grade panel and it works better. Here is updated workbook.

How to update a Google Forms dropdown list based off an existing spreadsheet?

So I've been looking for a way to do this and found many interesting answers about Google App Scripts, but none seem to get at what I am trying to do. I am looking to have a Google Sheet (Spreadsheet) with a column of choices. Then I have multiple forms which has a question that uses a drop down menu of those same choices. However, this list of choices gets updated semi often, so we currently find ourselves manually updating 6+ forms with the new information based off of the sheet. I'd like to know if there is a way to take the information from a spreadsheet and have it automatically update the drop down list.
I haven't really done any Google Script stuff, but I can hold my own in scripting generally. I just need help finding the right direction.
You can try getting a range of values from the sheet and loop through a column until last row as below code.
var values = SpreadsheetApp.getActiveSheet().getDataRange().getValues()
for(n=0;n<values.length;++n){
var cell = values[n][x] ; // x is the index of the column starting from 0, replace x with some value
}
Once you get the values into cell variable, you can simple add them to the form drop down list.
// Open a form by ID and add a new list item.
var form = FormApp.openById('1234567890abcdefghijklmnopqrstuvwxyz');
var item = form.addListItem();
item.setTitle('Do you prefer cats or dogs?')
.setChoices([
item.createChoice('Cats'),
item.createChoice('Dogs')
]);
You can refer to this documentation.
Hope that helps!
You should be able to use a formRanger AddOn which would allow you to update a spreadsheet.
This would then automatically update all the drop down dependent on the data you have added to the spreadsheet.

Coded UI Test : Finding and clicking dynamic hyperlinks in a grid

I recorded a click on a link inside of a tablecell in a grid, then modified the code after moving it to the UIMap file. There are many links in the grid, but they can only be used once then they go away. The links are a person's last name as the InnerText property. I am passing a persons last name in via the sLastName variable. I am finding that this works in places but not all the time and would appreciate any feedback.
Public Sub ReviewPhysOrdClick(ByVal sLastName)
Dim uILastNameHyperlink As HtmlHyperlink = Me.UIPaperlessAdministratWindow1.UIPaperlessAdministratDocument9.UINamelast1449Hyperlink
'all stuff to help it find a link in the grid to click
uILastNameHyperlink.SearchConfigurations.Add("Id") 'add id property as a search item
uILastNameHyperlink.SearchProperties.Add("Id", "ctl20__UserGrid", PropertyExpressionOperator.Contains) 'search parameter
uILastNameHyperlink.SearchProperties.Add("InnerText", sLastName, PropertyExpressionOperator.Contains) 'search parameter
uILastNameHyperlink.Find() 'prompts a search for the control before any action is taken
Mouse.Click(uILastNameHyperlink) 'click the link
End Sub
This code can be used where ever the id of the menu item which you want to click keeps on changing on change of environments or menu lists.You can directly edit the designer map of the
codedui test and comment the other search properties which where captured while recording the test.Put this three lines of code instead of captured lines.It works well.

Resources