|
Post by ethanq on Dec 14, 2017 18:23:31 GMT
Is there any way to make an array variable? I need to split a comma delimited string into an array.
Not seeing anything in the documentation and my attempts to use the vbscript Split function don't seem to be working.
Is the only way to pass the data to an external vbscript and then have the vbscript return the data I need from the array?
Is that even possible?
If so, that seems like a really inefficient way to do it.
|
|
|
Post by Jason on Dec 20, 2017 2:11:31 GMT
If you are using a Choice Input (aka a drop down list), then you can use the ChiceList sub-element to populate the choices from a comma-separated list of items.
Otherwise, you can use the ExternalCall Action type to call out to an external command.
Both options are documented in the documentation in the download.
|
|
|
Post by ethanq on Dec 20, 2017 15:22:15 GMT
The Choicelist sub-element is not going to work for what we need to do.
We have about 50 sites we need to be able to auto-generate the computer name and OU they need to go in.
Currently we are using an HTA with a decent amount of custom javascript functions to pull everything together.
We have a drop down list that has all the sites in it. The value for each drop down is a comma-separated list.
After the site is selected, it pulls that line of data into an array and then it pulls out the needed values from the array to auto set the region, time zone, computer name, and build the OU the computer is put into.
I am seeing no way to actually do this in UI++ as the documentation specifically states that you cannot return data from an external script and I also see no way to make an array variable in UI++. I was able to get it to run without error, but it doesn't seem to populate the array if it is even making one in the first place. Either that or it is not able to reference the array elements.
If it is possible to make and reference an array in UI++ a code snippet would be extremely helpful.
|
|
|
Post by Jason on Jan 2, 2018 16:16:37 GMT
Without knowing all of the details, I can't suggest an explicit alternative to what you are doing; however, I'd say that storing all of the data in multiple arrays is overly complex to maintain and there are potentially better alternatives.
> "you cannot return data from an external script"
This is a misleading statement. You can't return data directly, but there's no reason that the external script set a task sequence variable then can then easily be used by UI++. Doing this could easily address your scenario with very little work.
|
|
guy
New Member
Posts: 4
|
Post by guy on Jan 2, 2018 16:27:32 GMT
Hi Jason, I'm working with Ethanq on this as well.
What we are doing is as follows, we currently have an array for example: <option value="EU,London,Lon,GMT"> London</option> <option value="NA,NewYork,FRE,EST"> New York</option> <option value="CA,Ottawa,OTT,EST"> Ottawa</option>
Using this we pull in the computer location, Region and Timezone we then build out the name OU it automatically for example: strOU = "OU=" + strChassisTypeOU + ",OU=Computers,OU=" + strSiteCodeOU + ",OU=" + strRegion +",DC=Example,DC=COM";
It just means the local person only need to select the site they are building and we pre-select everything else.
Hopefully this makes sense?
|
|
|
Post by Jason on Jan 2, 2018 16:42:58 GMT
OK. That does actually look like a decent way to store the data but today there simply isn't a way to access items in a CSV string. For now, my suggestion is to do something like the following. It's not necessarily better and a bit (a lot really) more verbose for sure, but it's more descriptive, [debateably] less error-prone, and will get the same end result.
<Action Type=UserInput ...>
...
<ChoiceInput Variable="TheLocation" ...>
...
<option value="London">London</option>
...
</ChoiceInput>
...
</Action>
<Action Type="Switch" OnValue="%TheLocation%" DontEval="False" > <Case RegEx="London"> <Variable Name="Region">EU</Variable> <Variable Name="LocationCode">Lon</Variable> <Variable Name="TimeZone">GMT</Variable> </Case>
</Action>
|
|
|
Post by ethanq on Jan 4, 2018 16:02:58 GMT
Ok, so I have the drop down set up and the switch statement set up.
Problems: 1. For the drop down, if the Action Type is "UserInput", it just skips past and doesn't let me choose. I have to set the type to "Input" for it to work. Guessing that was just a typo as I don't see any reference to "UserInput" type in the documentation.
2. In the case statement, it is automatically assigning whatever the first case is no matter what the ChoiceInput variable is set to. I have done a dump of the variables and it is showing the value I selected in the dropdown, but the switch statement is acting like I chose the top choice in the dropdown.
I have tried manually creating and setting the variables to "" before the case statement and it makes no difference.
It also doesn't matter what the Default case is supposed to set the values to. Thought maybe if it wasn't there and for some reason it wasn't actually reading the variable from the dropdown it would for some reason set it to the first case.
|
|
|
Post by Jason on Jan 4, 2018 21:07:48 GMT
1. Yes, typo, should be Input.
2. Can you post the relevant log file snippet, please.
|
|
|
Post by ethanq on Jan 4, 2018 21:24:42 GMT
Here is what looks like the relevant log snippet - looks like the case statement is matching to "*" ?? <![LOG[ * Adding <ChoiceInput> Input: Please choose a final location for this computer]LOG]!><time="15:18:48.000+300" date="01-04-2018" component="UI++" context="" type="1" thread="8440" file="UserInputAction.cpp:198"> <![LOG[ + Set the task sequence variable 'MyLocation' to the value 'Barnsley']LOG]!><time="15:18:51.000+300" date="01-04-2018" component="UI++" context="" type="1" thread="8440" file="TSVar.cpp:202"> <![LOG[ > OK button pushed ... moving to next action.]LOG]!><time="15:18:51.000+300" date="01-04-2018" component="UI++" context="" type="1" thread="8440" file="UI++.cpp:310"> <![LOG[Found <TSVar> Action: Region]LOG]!><time="15:18:51.000+300" date="01-04-2018" component="UI++" context="" type="1" thread="8440" file="UI++.cpp:282"> <![LOG[ Initiating <TSVar> Action: Region]LOG]!><time="15:18:51.000+300" date="01-04-2018" component="UI++" context="" type="1" thread="8440" file="UI++.cpp:287"> <![LOG[ + Set the task sequence variable 'Region' to the value '""']LOG]!><time="15:18:51.000+300" date="01-04-2018" component="UI++" context="" type="1" thread="8440" file="TSVar.cpp:202"> <![LOG[Found <TSVar> Action: SiteCode]LOG]!><time="15:18:51.000+300" date="01-04-2018" component="UI++" context="" type="1" thread="8440" file="UI++.cpp:282"> <![LOG[ Initiating <TSVar> Action: SiteCode]LOG]!><time="15:18:51.000+300" date="01-04-2018" component="UI++" context="" type="1" thread="8440" file="UI++.cpp:287"> <![LOG[ + Set the task sequence variable 'SiteCode' to the value '""']LOG]!><time="15:18:51.000+300" date="01-04-2018" component="UI++" context="" type="1" thread="8440" file="TSVar.cpp:202"> <![LOG[Found <TSVar> Action: TimeZone]LOG]!><time="15:18:51.000+300" date="01-04-2018" component="UI++" context="" type="1" thread="8440" file="UI++.cpp:282"> <![LOG[ Initiating <TSVar> Action: TimeZone]LOG]!><time="15:18:51.000+300" date="01-04-2018" component="UI++" context="" type="1" thread="8440" file="UI++.cpp:287"> <![LOG[ + Set the task sequence variable 'TimeZone' to the value '""']LOG]!><time="15:18:51.000+300" date="01-04-2018" component="UI++" context="" type="1" thread="8440" file="TSVar.cpp:202"> <![LOG[Found <Switch> Action: ]LOG]!><time="15:18:51.000+300" date="01-04-2018" component="UI++" context="" type="1" thread="8440" file="UI++.cpp:282"> <![LOG[ Initiating <Switch> Action: ]LOG]!><time="15:18:51.000+300" date="01-04-2018" component="UI++" context="" type="1" thread="8440" file="UI++.cpp:287"> <![LOG[ * Switching on value of 'Barnsley'.]LOG]!><time="15:18:51.000+300" date="01-04-2018" component="UI++" context="" type="1" thread="8440" file="Action.cpp:1198"> <![LOG[ * Found Case with regular expression: .*.]LOG]!><time="15:18:51.000+300" date="01-04-2018" component="UI++" context="" type="1" thread="8440" file="Action.cpp:1210"> <![LOG[ + Regular expression matched.]LOG]!><time="15:18:51.000+300" date="01-04-2018" component="UI++" context="" type="1" thread="8440" file="Action.cpp:1221"> <![LOG[ + Set the task sequence variable 'Region' to the value 'NA']LOG]!><time="15:18:51.000+300" date="01-04-2018" component="UI++" context="" type="1" thread="8440" file="TSVar.cpp:202"> <![LOG[ + Set the task sequence variable 'SiteCode' to the value 'ANA']LOG]!><time="15:18:51.000+300" date="01-04-2018" component="UI++" context="" type="1" thread="8440" file="TSVar.cpp:202"> <![LOG[ + Set the task sequence variable 'TimeZone' to the value 'PST']LOG]!><time="15:18:51.000+300" date="01-04-2018" component="UI++" context="" type="1" thread="8440" file="TSVar.cpp:202">
|
|
|
Post by ethanq on Jan 9, 2018 21:19:41 GMT
|
|
|
Post by Jason on Jan 16, 2018 16:57:12 GMT
XML is case-sensitive. This catches everyone at least once.
|
|
|
Post by Jason on Jan 17, 2018 16:03:18 GMT
OK, a follow-up here as I just tried something in VBScript that should work no problem for what you need -- something I never thought would work.
a = "Apple,Orange,Grapes"
WScript.echo Split(a, ",")(1)
This properly echoes the string "Orange" thus allowing you to retrieve individual values of a comma-separated string as if it was an array.
|
|
|
Post by gbmacman on Jan 30, 2019 18:37:14 GMT
This is just what i needed, tested in vbscript, but not working from the xml.
<ChoiceInput Variable="Language_Code" Question="Please select your NATIVE language:" DropDownSize="10" Required="True" Default="en,en-us,1033,409,1252"> <Action Type="TSVar" Name="LanguageString">WScript.Echo Split("%Language_Code%",",")(1)</Action>
Log:
+ Set the task sequence variable 'Language_Code' to the value 'en,en-us,1033,409,1252' UI++ 1/30/2019 1:28:18 PM 4748 (0x128C) > OK button pushed ... moving to next action. UI++ 1/30/2019 1:28:19 PM 4748 (0x128C) Found <TSVar> Action: LanguageString UI++ 1/30/2019 1:28:19 PM 4748 (0x128C) Initiating <TSVar> Action: LanguageString UI++ 1/30/2019 1:28:19 PM 4748 (0x128C) + Set the task sequence variable 'LanguageString' to the value 'WScript.Echo Split("en,en-us,1033,409,1252",",")(1)' UI++ 1/30/2019 1:28:19 PM 4748 (0x128C)
+ Saving variable 'LanguageString' with value "WScript.Echo Split("en,en-us,1033,409,1252",",")(1)'. UI++ 1/30/2019 1:28:20 PM 4748 (0x128C)
|
|
|
Post by gbmacman on Feb 1, 2019 12:37:20 GMT
Its working now. Found a hint in another post.
<Action Type="TSVar" Name="LanguageString">Split("%Language_Code%",",")(1)</Action>
+ Set the task sequence variable 'LanguageString' to the value 'en-us'
|
|
|
Post by Jason on Feb 3, 2019 3:40:11 GMT
👍👍
|
|