|
Post by Christopher Ireland on Jul 3, 2017 18:32:11 GMT
I have 50+ models I'm supporting and would like to verify XHWModel against a master CSV text file of model names and display to the user whether their model is supported or not. What would be the best way to accomplish something like this?
BTW, love love love using UI++. Great job Jason!
|
|
|
Post by codylc on Jul 3, 2017 18:56:27 GMT
The "FileRead" action type is the only action I've seen that comes close to this, but it wouldn't parse a CSV file and create an array for you.
We currently use a ton of OR statements in our conditions, like this...
<Action Type="TSVar" Name="IsSupportedDesktop" Condition='("%XHWModel%" = "HP EliteOne 800 G1 AiO") OR ("%XHWModel%" = "HP EliteDesk 800 G2 DM 35W") OR ("%XHWModel%" = "HP ELITEDESK 800 G2 DM 35W") OR ("%XHWModel%" = "HP EliteDesk 800 G1 DM")'>"True"</Action>
I agree though, it would be nice to suck in a CSV or even have a comma separated list of potential values.
|
|
|
Post by Jason on Jul 4, 2017 15:29:06 GMT
Hey, guys. Interesting idea. I've been trying to design a solution for action groups (much, much harder than I thought it would be because of being able to go back now) and have a "switch/case" action in the pipeline as well. I think the switch/case could work here although I could see a "one of" type action that reads from an external file working as well. I'm very hesitant to add additional external dependencies like files. Not sure if I should be for something like this or not.
For the case/switch, here's what I would imagine the XML would look like:
<Action Type="Switch" On="%XHWModel%" Variable="IsSupportedDesktop"> <Case Operator="Is" Match="HP EliteOne 800 G1 AiO" Value="True" /> <Case Operator="IsLike" Match="HP EliteOne 900*" Value="True" /> <Case Operator="IsNot" Match="HP ELITEDESK 800 G2 DM 35W" Value="True" /> <Case Operator="IsOneOf" Match="'HP EliteOne 800 G1 AiO','HP EliteDesk 800 G2 DM 35W','HP ELITEDESK 800 G2 DM 35W'" Value="True" /> ... <Default Value="False" /> </Action>
Would that work and accomplish your goals? Does having the values in the external CSV add value or simplicity? Not saying it does or doesn't, just looking for feedback.
If yes, would adding the following add even more value: <Case Operator="IsOneOf" FileMatch="ModelList.csv" />
|
|
|
Post by Christopher Ireland on Jul 5, 2017 0:32:07 GMT
Well, I've only been using UI++ for the last several days, so I wasn't sure what was the best way to go about listing the supported models.
I tried (and still have in place) an Info page with all the models, similar to what I have in the MDT UDI wizard in production. But I found that I couldn't make it Tall, so it's kinda scrunched.
Then I thought of the conditional Or statement like Cody mentioned, but I wasn't sure if it would be too long. Is there a max length?
And then I thought of attaching an external vbscript parser with an accompanying CSV (just for parsing ease), but didn't exactly know how to pipe the results back to UI++. The idea of the CSV makes adding models in the future easier, because just that file would be updated and it would be easier to add to it.
The case statement seems interesting as possibilities go, but it might end up being just as long or chock full as the Or statement, plus readability would go out the window. I usually use case statements with integers. But I do like the different varieties of Is, IsLike, IsNot, and IsOneOf. Nice.
i just wasn't sure if there was something I was missing, or a technique I hadn't thought of before. You never know about the convoluted mess you made until you see an easier way done by somebody else.
|
|
|
Post by Ronnie on Jul 5, 2017 6:54:25 GMT
I like the switch/case construct as it ties very well into the idea of UI++ XML structure. And if you combine that with having the config file on a web server, you can change the file without having to rebuild your boot image all the time.
Another way to solve the case with checking for supported models would be to use the external call construct to run a Powershell script that performs the check for a supported model, the script could set a TS variable that UI++ could verify, and maybe you could even make a preflight check to verify it.
One note on the switch/case construct, maybe it should have sub items to allow for setting more than one variable or perform other actions, but that would make it more complex to code.
<Action Type="Switch" On="%XHWModel%" Variable="IsSupportedDesktop"> <Case Operator="Is" Match="HP EliteOne 800 G1 AiO" > <Action Type="TSVar" Name="Supported">True</Action> </Case> ... <Default Value="False" /> </Action>
|
|
|
Post by codylc on Jul 5, 2017 17:28:06 GMT
Agreed that the case operator as Jason described would be great! The ability to pull in a CSV for values would be great as well, although I can't say I have enough models to justify using it currently.
|
|
|
Post by Christopher Ireland on Jul 23, 2017 2:24:52 GMT
Codylc, I took your idea for the model condition and modified it slightly to accommodate partial names:
Condition="(InStr("%XHWModel%","EliteBook 8560p") > 0) OR (InStr("%XHWModel%","ProBook 650 G2") > 0) OR (InStr("%XHWModel%","ProBook 6470b") > 0)" ...., etc.
Works like a charm. 50+ models doesn't take up too much room and it's easy to have several slightly different form factors represented with one comparison string, like USDT or SFF.
|
|
|
Post by Jason on Aug 29, 2017 22:29:33 GMT
I'll be posting a new version tomorrow (most likely) that will include the new Switch action which may/should simplify this scenario and give you some interesting flexibility as well. It's a bit different from what I prototyped above and has a lot more potential.
|
|
|
Post by scribdog on Jan 29, 2019 19:29:30 GMT
I have read and re-read this post trying desperately to figure out how to do a Preflight check for supported computer models. My failing I'm sure is my coding abilities. They are abysmal at best.
Is there any Preflight code that anybody can provide that could help?
|
|
|
Post by Jason on Feb 3, 2019 3:37:02 GMT
What models exactly are considered supported for you?
|
|
|
Post by del019589 on Feb 4, 2019 21:30:56 GMT
This is how we are handling our list of supported models. We just pipe ( | ) each model our entire string is almost 80 models laptops desktops etc..
<ActionGroup Name="Preflight"> <Action Type="DefaultValues" ValueTypes="Asset,Net" ShowProgress="True" /> <Action Type="Switch" OnValue="%XHWModel%" DontEval="False"> <Case CaseInsensitive="True" RegEx="(Virtual Machine|Optiplex 5040|Latitude 3189|Latitude 3330|Latitude 3340|Latitude 3350)"> <Variable Name="Supported">"True"</Variable> </Case> <Default> <Variable Name="Supported">"False"</Variable> </Default> </Action> <Action Type="Preflight" Title="Preflight checks" ShowOnFailureOnly="True" ShowBack="True" Timeout="15" TimeoutAction="Continue"> <Check Text= "Supported Hardware" ErrorDescription= "Your model is not listed as supported please contact x4120 for help" CheckCondition='"%Supported%" = "True"' /> </Action> </ActionGroup>
|
|