Modify MDT wizard to automate computer naming - html

Situation:
I am imaging new systems using MDT Lite-Touch. I am trying to
customize the wizard to automate the naming of new systems so that
they include a prefix "AG-", a department code which is selected from
a drop-down box in the wizard page (eg. "COMM"), and finally the
serial number of the computer being imaged, so that my result in this
case would be "AG-COMM-1234567"
Progress:
I first created the HTML page which I will include below and added a script to the page to concatenate the pieces into a variable called
OSDComputername which, for testing, I could output in a msgbox and get
to display correctly.
The problem with this is I don't know how to trigger the script then assign it to the OSDComputername variable that is used throughout
the rest of the Light-Touch process.
I changed the script to a function and added it to DeployWiz_Initization.vbs then used the Initialization field in WDS to
call it. I'll include the function below.
The problem with this is I would get "Undefined Variable" for OSDComputername and I am not sure it is pulling the data from the HTML
correctly.
I tried adding the scripting into the customsettings.ini file after the "OSDComputername="
This resulted in the wizard just outputting my code in text as the computer name.
I am now trying adding variables to "Properties=" (eg.DepartmentName) in the customsettings.ini, pulling thier value
from the HTML Form and setting that value to the variable in my
function in DeployWiz_Initization.vbs and calling them after
"OSDComputername=" in the fashion "OSDComputername="AG-" &
%DepartmentName%" in customsettings.ini
I am rebuilding right now and will see how this goes
Any help would be appreciated.
The HTML page:
<HTML>
<H1>Configure the computer name.</H1>
<span style="width: 95%;">
<p>Please answer the following questions. Your answers will be used to formulate the computer's name and description.</p>
<FORM NAME="TestForm">
<p>Departmental Prefix: <!-- <label class=ErrMsg id=DepartmentalPrefix_Err>* Required (MISSING)</label> -->
<SELECT NAME="DepartmentalPrefix_Edit" class=WideEdit>
<option value="AADC">AADC</option>
<option value="AEM">AEM</option>
<option value="AIP">AIP</option>
<option value="COM">COM</option>
<option value="DO">DO</option>
<option value="DSOC">DSOC</option>
<option value="EDU">EDU</option>
<option value="EPE">EPE</option>
<option value="ITN">ITN</option>
<option value="LA">LA</option>
<option value="OAP">OAP</option>
<option value="SML">SML</option>
</SELECT>
</p>
<p><span class="Larger">Client's Net<u class=larger>I</u>D:</span>
<INPUT NAME="ClientNetID" TYPE="TEXT" ID="ClientNetID" SIZE="15"></p>
<p>Building: <!-- <label class=ErrMsg id=Building_Err>* Required (MISSING)</label> -->
<SELECT NAME="Building_Edit" class=WideEdit>
<option value="Academic Surge Facility A">Academic Surge Facility A</option>
<option value="Academic Surge Facility B">Academic Surge Facility B</option>
<option value="Caldwell">Caldwell</option>
<option value="Kennedy">Kennedy</option>
<option value="Roberts">Roberts</option>
<option value="Warren">Warren</option>
</SELECT>
</p>
<p>
<span class="Larger">Room <u class=larger>N</u>umber:</span>
<input type=text id="RoomNumber" name=RoomNumber size=15 />
</p>
</FORM>
</span>
</HTML>
The Function:
Function SetComputerName
OSDComputerName = "AG-" & oEnvironment.Item("DepartmentalPrefix_Edit")
ComputerDescription = oEnvironment.Item("DepartmentalPrefix_Edit") & ", " & oEnvironment.Item("ClientNetID") & ", " & oEnvironment.Item("RoomNumber") & " " & oEnvironment.Item("Building_Edit")
End Function

Issue Resolved!
The HTML page:
<H1>Configure the computer name.</H1>
<p>Please answer the following questions. Your answers will be used to formulate the computer's name and description.</p>
<FORM NAME="SetComputerNameForm">
<p>
<LABEL class="Larger"><u class="Larger">D</u>epartmental Prefix:</LABEL><br />
<SELECT NAME="DepartmentalPrefix_Edit" ID="DepartmentalPrefix_Edit" language=vbscript onpropertychange=ValidateSetComputerName AccessKey=D>
<option value="FOO">FOO</option>
<option value="DOE">DOE</option>
<option value="AFK">AFK</option>
<option value="BBL">BBL</option>
<option value="RTFM">RTFM</option>
</SELECT>
</p>
<p>
<LABEL class="Larger"><u class="Larger">C</u>lient's ID:</LABEL>
<br />
<INPUT NAME="ClientID" ID="ClientID" TYPE="text" ID="ClientID" SIZE="15" language=vbscript onpropertychange=ValidateSetComputerName AccessKey=C />
<label class=ErrMsg for=ClientID>* Required (MISSING)</label>
</p>
<p>
<LABEL class="Larger"><u class="Larger">B</u>uilding:</LABEL><br />
<SELECT NAME="Building_Edit" ID="Building_Edit" language=vbscript onpropertychange=ValidateSetComputerName AccessKey=B>
<option value="ASA">ASA</option>
<option value="ASB">ASB</option>
<option value="ASC">ASC</option>
</SELECT>
</p>
<p>
<LABEL class="Larger"><u class="Larger">R</u>oom Number:</span></LABEL>
<br />
<INPUT NAME="RoomNumber" ID="RoomNumber" TYPE="text" ID="RoomNumber" size="15" language=vbscript onpropertychange=ValidateSetComputerName AccessKey=R>
<label class=ErrMsg for=RoomNumber>* Required (MISSING)</label>
</p>
</FORM>
The Function:
Function ValidateSetComputerName
ParseAllWarningLabels
If Len(Document.SetComputerNameForm.ClientNetID.Value) < 1 OR Len(Document.SetComputerNameForm.RoomNumber.Value) < 1 THEN
ButtonNext.disabled = true
Else
Dim Department
Dim SerialNumber
Dim CID
Dim RoomNumber
Dim BuildingName
Dim Make
Dim Model
Department = Document.SetComputerNameForm.DepartmentalPrefix_Edit.Value
SerialNumber = oEnvironment.Item("SerialNumber")
CID = Document.SetComputerNameForm.ClientID.Value
RoomNumber = Document.SetComputerNameForm.RoomNumber.Value
BuildingName = Document.SetComputerNameForm.Building_Edit.Value
Make = oEnvironment.Item("Make")
Model = oEnvironment.Item("Model")
oEnvironment.Item("OSDComputerName") = "AG-" & Department & "-" & Right(SerialNumber,7)
oEnvironment.Item("ComputerDescription") = Department & ", " & CID & ", " & RoomNumber & " " & BuildingName & ", " & Make & " " & Model
ButtonNext.disabled = false
End If
End Function
The real change is in the Function how I needed to retrieve the values from my custom HTML screens. You will see in the working Function that I had to set each value using the format: Document.FormName.FieldName.Value
I could then use the built-in Environmental Items to collect the Make, Model, and Serial Number. Once I had all of the pieces, all of the user selections and built-in values, it was simply a matter of concatenating the strings in the order I wanted and assigning the value to the Environmental Items "OSDComputerName" and "ComputerDescription".
I also made use of ButtonNext.disabled to make all of the fields required before the user was able to continue to the next screen.

Related

How to extract URL of created html form using google app script

I'm using google app script to build something like a form that helps me with automation.
here's the code for building my form
<div class="w3-container w3-section">
<div class="form-container">
<div class="spacing">
<input class="input-like" placeholder="Enter video link" id="vid" type="text"/>
</div>
<div class="spacing">
<select class="input-like" id="vcategory">
<option value='' disabled selected hidden>Select video category</option>
<option value='Film & Animation'>Film & Animation</option>
<option value='Autos & Vehicles'>Autos & Vehicles</option>
<option value='Pets & Animals'>Pets & Animals</option>
<option value='Sports'>Sports</option>
<option value='Travel & Events'>Travel & Events</option>
<option value='Gaming'>Gaming</option>
<option value='People & Blogs'>People & Blogs</option>
<option value='Comedy'>Comedy</option>
<option value='Entertainment'>Entertainment</option>
<option value='News & Politics'>News & Politics</option>
<option value='How to & Style'>How to & Style</option>
<option value='Education'>Education</option>
<option value='Science & Technology'>Science & Technology</option>
<option value='Nonprofits & Activism'>Nonprofits & Activism</option>
</select>
</div>
</div>
<div class="button-wrapper">
<button class="w3-blue" onclick="addRow()">Add</button>
</div>
<div class="button-wrapper">
<div class="alert alert-success" id="ok" style="display:none">
<h3>Thanks</h3>
<p>This is a new one</p>
</div>
<div class="alert alert-danger" id="warn" style="display:none">
<h3>Duplicate!</h3>
<p>The video ID or Name is already on the list</p>
</div>
<div class="alert alert-warning" id="missing" style="display:none">
<h3>Input missing!</h3>
<p>Viedo link or Category is missing</p>
</div>
</div>
</div>
At this point everything works fine and I can see my Form when I deploy.
I get the forms values through a function that send these values to doGet() function and I add them to the spreadsheet cells.
What I want to do, is when I do run this script .. it sends me to a new tab containing the created form, as this form is not created as a submenu in the spreadsheet, it's completely in another page/tab .. I want to get this page/tab url as I need to access it's parameters in the future.
I tried to use google.script.url as in the documentation but it sent me empty object,
I tried to use window.location.href, it sent me a weird URL that I couldn't recognize and it's not the one for the created tab.
Any help would be appreciated :)
ScriptApp.getService().getUrl()

How to modify this HTML form to include a constant?

Here's an example of a search in our SirsiDynix Enterprise catalog using the CloudSourceOA option te=750777545
https://nyit.ent.sirsi.net/client/en_US/default/search/results?qu=html&te=750777545&rt=false%7C%7C%7C%3ECSOA%3Ctitle%7C%7C%7CTitle
I want to pass the variables from a form in libguides to the enterprise. I have a working example for searching "Everything" and a broken example for the CloudSourceOA
My Form sends the search types like title and the term that the user enters in the input field to the qu=, however, I don't know how to append the te=750777545. This value will always be set as I want the widget to always search cloudsource rather than everything.
Here's a link to my libguide for troubleshooting. I was unable to add the code successfully here.
https://libguides.nyit.edu/c.php?g=1216772&p=8899584&preview=77a637b8476d8bbe2575a12fd18e3b61
It's unclear what te or the 750777545 value is, but if you need to hardcode that to your form you can do so with a hidden input set to that value. Fair warning, without knowing what this form field is, this may not be the best approach so you'll want to consult any documentation if this is specific to an internal NYIT application.
<form action="https://nyit.ent.sirsi.net/client/en_US/default/search/results?" id="searchForm" method="&te=""get"" name="searchForm">
<h5>Search the NYIT Catalogue</h5>
<div class="searchline">
<input name="ln" type="hidden" value="en_US"><br>
<select class="dropDown" id="restrictionDropDown" name="rt">
<option value="">
All Fields
</option>
<option value="false|||TITLE|||Title">
Title
</option>
<option value="false|||AUTHOR|||AUTHOR">
Author
</option>
<option value="false|||SUBJECT|||SUBJECT">
Subject
</option>
<option value="false|||ISBN|||ISBN">
ISBN
</option>
<option value="false|||ISSN|||ISSN">
ISSN
</option>
<option value="false|||DOI|||DOI">
DOI
</option>
<option value="false|||JOURNAL|||Journal Title">
Journal Title
</option>
</select>
<input type="hidden" id="te" name="te" value="750777545">
<p><input accesskey="s" id="qu" maxlength="256" name="qu" style="width:250px;" title="Search For:" type="text" value=""><input class="button" id="searchButton" title="Search" type="submit" value="Search"></p>
</div>
</form>

Struggling with using drop-down input menus to calculate & print results

[HTML, JS, CSS]
.
I'm trying to make code for a dining calculator that takes an inputted value, inputted tip amount (from a drop-down menu), and an inputted amount of customers (also from a drop-down menu), then calculates ([startPrice * tipAmount] + [startPrice/peopleEating]) and prints the results.
The problem is that I don't know how to calculate and print results using the inputted values of those drop-down menus. Can anyone give me a simple explanation?
Thanks.
You simply need to use the .value of the dropdown. I have attached a runnable code snippet below:
function processForm() {
var startPrice = document.getElementById("startPrice").value;
var tipAmount = document.getElementById("tipAmount").value;
var peopleEating = document.getElementById("peopleEating").value;
console.log("Start price is " + startPrice);
console.log("Tip Amount is " + tipAmount);
console.log("People Eating is " + peopleEating);
console.log((startPrice * Number(tipAmount)) + (startPrice/Number(peopleEating)) + " Is the calculated number");
}
<!DOCTYPE html>
<html>
<body>
<label for="startPrice">Start Price</label>
<input type="number" name="startPrice" id="startPrice"><br><br>
<label for="tipAmount">Tip Amount</label>
<select id="tipAmount" name="tipAmount">
<option value="10">10</option>
<option value="20">20</option>
<option value="30">30</option>
</select><br><br>
<label for="peopleEating">People Eating</label>
<select id="peopleEating" name="peopleEating">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
</select>
<button onclick="processForm()">Calculate</button>
</body>
</html>
PS: I have used the Number() function in the dropdown values, because by default they are stored as strings, and converting them into numbers is important.

Pull data from HTML dropdown

I'm looking for a way to extract data from the available options from a website dropdown box, specifically the second optgroup "All fund companies".
extract of HTML code I'm scraping
</div><div class="large-5 medium-5 columns spacer-bottom padding-left-none"><div class="select_wrap"><select id="search-company" name="companyid" class="default">
<option value="">Search by company</option>
<optgroup label="Popular companies">
<option value="4">Hargreaves Lansdown</option>
<option value="1908">Lindsell Train</option>
<option value="55">Jupiter</option>
<option value="191">Legal & General</option>
</optgroup>
<optgroup label="All fund companies">
<option value="218">Aberdeen</option>
<option value="1080">Aberforth Unit Trust Managers</option>
<option value="141">Allianz Global Investors</option>
<option value="3472">Alquity Investment Management Limited</option>
<option value="1324">Amati Global Investors Ltd</option>
VBA:
Set htmlObj = html.getElementById("search-company")
For Each Child In htmlObj.getElementByClassName("optgroup")(1).Children
sqlId = Child.Value
sqlCompany = Child.innerText
Debug.Print (sqlId & " - " & sqlCompany)
Next
Thanks Jeeped...
This is the code that managed to solve the problem... not sure if it's the most efficient way of doing it, but it works :)
Set htmlObj = html.getElementById("search-company")
For Each Child In htmlObj.Children
If Child.Label = "All fund companies" Then Set htmlObj2 = Child
Next
For Each Child In htmlObj2.Children
sqlId = Child.Value
sqlCompany = Child.innerText
Debug.Print (sqlId & " - " & sqlCompany)
Next

asp classic and select tag with multiple attribute

I am using select tag of html and having multiple attribute. and now I am fetching of selected option from the select tag using asp classic. but getting 500 internal server error.
<%
response.write(request("evtCategory").Count)
response.write(request("evtCategory"))
%>
<form id="frmSearch" method="post" >
<select name="evtCategory" multiple>
<option value="0">--Select Category--</option>
<option value="1">First</option>
<option value="2">Second</option>
<option value="3">Third</option>
<option value="4">Fourth</option>
<option value="5">Fifth</option>
</select>
<input type="submit" value="Search" />
</form>
I don't think Count exists in Classic ASP, that looks like ASP.NET code.
Multiple selected values will be returned as a comma separated string.
You can use Split to get the selected values as an array.
Dim values, i
values = Split(Request.Form("evtCategory"), ",")
For i = 0 To UBound(values)
Response.Write("Value " & i & " = " & values(i) & "<br />")
Next