Вы находитесь на странице: 1из 9

formRanger

FormRangerisnowavailableasaFORMSAddon!
Checkitout
.Clickhereto
install
.
TheformRangerscriptallowsuserstocreatemultiplechoice,dropdownlist,orcheckboxquestionsinaGoogleFormwhose
optionsarepopulatedfromarangeofvalueswithintheGoogleSpreadsheettowhichtheformisattached.Inadditionto
enablingfasterformcreation,thisscriptallowsforformstobeupdatedquickly,andenablesdynamicformquestionoptions
thatchangebasedonhowpreviouslysubmittedformswerefilledout.

ExampleCaseI:Populateformdropdownwithstudentnamesfroman
uptodatestudentroster
Inthisfirstpartofourtutorialwewillshowhowasimple,formbasedstudentbehaviorloggingsystemcanpullstudent
namesfromanuptodatestudentroster.Whentherosterchanges,asnewstudentsleaveorjointheschool,asimple
refreshofformRangerwillautomaticallyupdatethestudentnameoptionsintheform.

ExampleCaseII:Dynamicallyalterformresponseoptionsbasedonprevious
formsubmissions
InthissecondpartofourformRangertutorial,wewillshowaninterestinguseofformRangerthatallowsformresponse
optionstochangebasedonhowpeopleansweredquestionsinpreviousforms.Wewillbuildaformthatallowsteachersto
registerforaparticularPDsession.Onceapredeterminedmaximumnumberofparticipantshavebeenreachedona
particularPD,formRangerwillupdatetheformtoremovethatoption,sothatfutureuserswillnolongerbeabletoselectit.
Youcanviewthedocumentscreatedforthistutorialhere:
formRangerTutorialDocs

ExampleCaseI
Step1:Createanewspreadsheetandattachaform
Step2:Addanewsheetwithstudentcontactinformation
Step3:InstallandSetupformRanger
ExampleCaseII
Step1:CreateaWorkshopSignupFormattachedtoaspreadsheet
Step2:Createanewsheettocalculateavailableworkshopspace
Step3:AttachformRanger&SetTrigger
GiveUsFeedback!


ExampleCaseI
Step1:Createanewspreadsheetandattachaform
Forthistutorialwewillbecreatingasimplebehaviorloggingsystem(Ifyouveseenour
formMule/autoCratcopydown
tutorial
,thiswilllookfamiliar).First,createanewspreadsheetandinsertaform.Inthisexamplewehavethefollowing
fields:

WhilecreatingourformsettheStudentNamequestiontypetoChoosefromalist,butleavetheoptionsblankfornow.
WewillbeusingformRangertopopulatetheStudentNamequestionoptions.

Step2:Addanewsheetwithstudentcontactinformation
Wewillnextaddastudentrosterwiththefollowingcontactinformationforeachstudent:

Step3:InstallandSetupformRanger
NextwearegoingtoinstallformRangerfromtheGoogleAppsScriptGallery.Ifyouhaveneverinstalledascriptbefore,
see
thisminitutorial
.
AfterinstallingandauthorizingtheformRangerscript,youwillseeanewformRangerdropdownmenu.Clickitandselect
Runinitialconfiguration:

Thescriptwilldosomethingsinthebackground.Afteritfinished,clicktheformRangermenuagainandselectAssignform
item(s)tocolumn(s):

ThiswillpulluptheformRangeruserinterface.Anyformfieldthatiseitheradropdown,checkbox,ormultiplechoiceisable
tobelinkedtoarangeinaspreadsheetviaformRanger.YoudothisbyclickingthecheckboxintheformRangeruser
interfacenexttothecorrespondingfield.YouthentellformRangerwhichsheetcontainstherelevantrange,andwhich

columninthatsheetcontainstherelevantdata.
Youcanhaveasmanyformfieldslinkedtospreadsheetrangesasyoulike.Andtheformscanliveinmultiplesheetsinyour
spreadsheet.Inourexamplewewilljustlinkingasingleformfieldstudentname.ClickSavesettingswhenyouare
finished.

Aftersavingyoursettings,ifyougointoourliveformyouwillseethattheStudentNamefieldhasbeenupdatedtoinclude
thestudentsfromourStudentRostersheet.

Now,ifweaddorremovestudentstoourroster,wecanquicklyupdatetheformtoreflectthosechanges.Inourexample
wehaveaddedanewstudent,Doug,toourroster.Afteraddingthenewname,wegobackintotheformRangermenuand
clickRefreshformtoupdatetheform:


Backinourliveform,youllnownoticethatourStudentNamefieldhasbeenupdatedtoincludeDoug.

ExampleCaseII
Step1:CreateaWorkshopSignupFormattachedtoaspreadsheet
Forthistutorialwearegoingtocreateasimpleworkshopregistrationform.Theformwillonlyaskfortwothings:theusers

nameandtheworkshoptheywanttoattend.

WewillpopulatetheworkshopdropdownlistusingformRanger,likeinexamplecaseIabove.However,unlikeinexample
caseI,wearegoingtodosomefancyformulafootworktopopulatethelistwithonlythoseworkshopsthatstillhave
availablespace.

Step2:Createanewsheettocalculateavailableworkshopspace

Intheformattachedspreadsheet,InextcreatedanewsheetandnameditWorkshopCapacity.InthefirstcolumnIhave
thenameofeachworkshop,andinthesecondcolumnthetotalnumberofspacesavailable.

Nextwewanttocalculatehowmanypeoplehaveregisteredforeachworkshop.Todothis,wewillusethreefunctions
nestedwithintheother.
ThefirstistheFILTERfunction,whichwewillusetofilteralloftheformresponsesbytheworkshopwewanttocount.For
6

row2ofourspreadsheet,thisfunctionwilllooklikethis:
=filter('FormResponses'!C:C,'FormResponses'!C:C=
A2
)
Becausethefilterfunctionwillreturn#N/Aiftherearenotanymatchesinthesourcerange,wewanttowrapthefunctioninan
IFERRORfunction.Thiswillsuppresstheerrormessage.Nowourfunctionlookslikethis:
=iferror(filter('FormResponses'!C:C,'FormResponses'!C:C=
A2
))
Nowwewanttocounttheoutputofthisfunction.SowewillwrapthisfunctioninaCOUNTAfunction,sowehave:
=counta(iferror(filter('FormResponses'!C:C,'FormResponses'!C:C=
A2
)))
InEnglish,thisfunctionissaying:FiltertheFormResponsessheetfortheworkshopincellA2.Thencounthowmanyyoufind.But
dontcounttheerrormessageifyoudontfindanything.
WenowhavethezerosineachrowincolumnC,becausenoonehasregisteredyet:

Next,wewanttodeterminewhetherthereisstillopenspaceforeachworkshop.TodothiswewillusetheIFfunction.TheIF
functionsays:If[someexpression]istrue,outputthis,otherwiseoutputthis.WewanttocomparetheCurrentRegistrationcolumnto
theTotalCapacitycolumn,andIFtheCurrentRegistrationislessthantheTotalCapacity,returntheWorkshopName.Otherwise,
returnnothing.
Ourfunctionlookslikethis:
=if(
C2
<
B2
,
A2
,"")
WecancopythisfunctiondowneachofourrowsincolumnD.

Next,incolumnE,wewanttouseourFILTERfunctionagain,thistimetocreateafilteredlistofonlytheOpenWorkshops(ifwe
didntdothis,laterwhenweinstallformRangerwewouldgetblankoptionsinourdropdownmenu).Todothis,weusethefollowing
function:
=filter(D2:D4,D2:D4<>)
InEnglish,wearesaying:FiltercellsD2toD4forworkshopnamewhereverworkshopnameisnotblank
(Note:Editedon5/12toincludethislaststep)
FINALLY,wearegoingtowrapourfunctionincolumnEinaniferrorfunction.Ifwedontdothis,youwillgetan#N/Aerrorwhen
allofyoursessionshavefilledup.The#N/Aissayingthatittriedtofilteryourdataforthecriteriayouspecified,butitdidntfindany
matches.Wrappingthefunctioninaniferrorwillinsteadreturnanemptycell.
=iferror(filter(D2:D4,D2:D4<>))


NOTE:Thesearedefinitelysomemoreadvancedfunctions.Takesometimeand
makeacopyofthespreadsheet
createdforthis
tutorial.Playwiththefunctionstoseehowtheywork.

Step3:AttachformRanger&SetTrigger
NowwewillgototheScriptGalleryandinstallformRanger.Wewanttolinkquestion2tocolumnEinourWorkshopCapacity
sheet.

See
Step3inCaseIabove
fordirectionsoninstallingandsettingupformRanger.
NextweneedtotellformRangertorefreshitselfaftereachformsubmission.Eventually,theworkshopswillbecomefulland
thenameswillberemovedfromtheformRangerListcolumninourWorkshopCapacitysheet.WeneedformRangerto
refreshthedropdowntoreflectthis.


Thatsit!Nowourworkshopwilladjusttoreflectavailablecapacity.NoticethatourworkshopUsingdigitallearningtoolsin
theclassroomhasreacheditscapacityandhasbeenremovedfromourformRangerListincolumnE.

NOTE
:formRangercannotrefreshformsthathavealreadybeenopeninsomeonesbrowser.Itispossiblethatifmultiple
peopleareusingyourformatthesametimeyoucangetintoasituationwhereyourlimitisreachedbutformsarealready
openinotherbrowsers,sowhenthoseformsaresubmittedyourlimitisexceeded.So,sayyouhave1slotleft,andtwo
peopleopenyourformatthesametime.Thereisnotawaytopreventthembothfromsigningupforthesameslot.

GiveUsFeedback!
Ifyoufoundanythinginthistutorialtobeunclear,incomplete,outofdateorotherwiseconfusing,pleaseletusknow!You
caninsertcommentsdirectlyintothisdocumentbyhighlightingtherelevanttextthatyouwanttoaddress,clickingonthe
insertmenuandclickingoncomment.