{"id":9849,"date":"2015-09-15T10:00:00","date_gmt":"2015-09-15T17:00:00","guid":{"rendered":"https:\/\/www.sapien.com\/blog\/?p=9849"},"modified":"2015-09-15T10:45:42","modified_gmt":"2015-09-15T17:45:42","slug":"primalscript-adds-custom-primalsense-part-1-basic-lists-and-static-data","status":"publish","type":"post","link":"https:\/\/dev.sapien.com\/blog\/2015\/09\/15\/primalscript-adds-custom-primalsense-part-1-basic-lists-and-static-data\/","title":{"rendered":"PrimalScript adds Custom PrimalSense (Part 1: Basic lists and static data)"},"content":{"rendered":"<p>With the latest service build (7.1.67) of PrimalScript 2015 we introduced a new feature; custom PrimalSense. While many items in a script can be determined dynamically based on context and offered as a selection in a list, there are equally as many items that are tied to your specific environment or your business logic. There is simply no way we can foresee these items and offer them as you need them.<\/p>\n<p>What we can do however, is to enable you to customize PrimalSense and create your own lists, based on your needs and your environment.<\/p>\n<p>Invoking these custom lists is really easy. Type the name of the list and press Ctrl + L, as in List and it will show up. Lists are stored in this folder: C:\\ProgramData\\SAPIEN\\PrimalScript 2015\\Lists. The file name designates the name of a list. To make this feature as flexible as possible, we have designed this with three different types of lists.<\/p>\n<h2>List Types<\/h2>\n<p><strong>1. Static list.<\/strong><\/p>\n<p><a href=\"https:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2015\/09\/image10.png\" target=\"_blank\"><img loading=\"lazy\" decoding=\"async\" title=\"image\" style=\"border-left-width: 0px; border-right-width: 0px; border-bottom-width: 0px; display: inline; border-top-width: 0px\" border=\"0\" alt=\"image\" src=\"https:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2015\/09\/image_thumb10.png\" width=\"376\" height=\"198\"><\/a><\/p>\n<p>The data for this list is stored in a CSV file or an XML file. For just a simple, single selection list only the data file is required.<\/p>\n<p><strong>2. Cached list.<\/strong><\/p>\n<p><a href=\"https:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2015\/09\/image11.png\" target=\"_blank\"><img loading=\"lazy\" decoding=\"async\" title=\"image\" style=\"border-left-width: 0px; border-right-width: 0px; border-bottom-width: 0px; display: inline; border-top-width: 0px\" border=\"0\" alt=\"image\" src=\"https:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2015\/09\/image_thumb11.png\" width=\"495\" height=\"244\"><\/a><\/p>\n<p>A configuration file (.ini) contains a command to generate the data file for this list (CSV or XML). The command is only executed ONCE per PrimalScript session and the data file is kept around. If you exit PrimalScript and start it again, the command will be executed again. This is very helpful for data that is dynamic, but does not change very often, e.g. available PowerShell modules.<\/p>\n<p><strong>3. Dynamic list.<\/strong><\/p>\n<p><a href=\"https:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2015\/09\/image12.png\" target=\"_blank\"><img loading=\"lazy\" decoding=\"async\" title=\"image\" style=\"border-left-width: 0px; border-right-width: 0px; border-bottom-width: 0px; display: inline; border-top-width: 0px\" border=\"0\" alt=\"image\" src=\"https:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2015\/09\/image_thumb12.png\" width=\"456\" height=\"250\"><\/a><\/p>\n<p>A dynamic list executes the command you specified each time you invoke that list. The data format once again is either CSV or XML. A good example for this type of list is the \u201cfile\u201d example we provided. It lists the folder content of the directory the current file resides in. Since files get created, deleted or renamed all the time, this list has to always use current data.<\/p>\n<h2><strong>Data Format<\/strong><\/h2>\n<p>Ok, so how does the data part work? You can use a CSV file if your data is single line items.<\/p>\n<p><a href=\"https:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2015\/09\/image13.png\" target=\"_blank\"><img loading=\"lazy\" decoding=\"async\" title=\"image\" style=\"border-left-width: 0px; border-right-width: 0px; border-bottom-width: 0px; display: inline; border-top-width: 0px\" border=\"0\" alt=\"image\" src=\"https:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2015\/09\/image_thumb13.png\" width=\"330\" height=\"206\"><\/a><\/p>\n<p>If you have only simple strings, then you do not even need to use commas. Just list your items one per line.<br \/>Sometimes you need to provide a little more information or translate some weird strings into something human readable. GUIDs used for DSC resources are a good example. I cannot remember that many numbers nor can I really distinguish them when I see them. So we show a translation that makes sense but insert the GUID when selected<\/p>\n<p><a href=\"https:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2015\/09\/image14.png\" target=\"_blank\"><img loading=\"lazy\" decoding=\"async\" title=\"image\" style=\"border-left-width: 0px; border-right-width: 0px; border-bottom-width: 0px; display: inline; border-top-width: 0px\" border=\"0\" alt=\"image\" src=\"https:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2015\/09\/image_thumb14.png\" width=\"346\" height=\"193\"><\/a><\/p>\n<p><a href=\"https:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2015\/09\/image15.png\" target=\"_blank\"><img loading=\"lazy\" decoding=\"async\" title=\"image\" style=\"border-left-width: 0px; border-right-width: 0px; border-bottom-width: 0px; display: inline; border-top-width: 0px\" border=\"0\" alt=\"image\" src=\"https:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2015\/09\/image_thumb15.png\" width=\"381\" height=\"73\"><\/a><\/p>\n<p>The data file for this is also just a simple CSV file.<\/p>\n<p><a href=\"https:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2015\/09\/image16.png\" target=\"_blank\"><img loading=\"lazy\" decoding=\"async\" title=\"image\" style=\"border-left-width: 0px; border-right-width: 0px; border-bottom-width: 0px; display: inline; border-top-width: 0px\" border=\"0\" alt=\"image\" src=\"https:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2015\/09\/image_thumb16.png\" width=\"501\" height=\"192\"><\/a><\/p>\n<p>The first column contains the human readable string, the second column is an image index (we get to that later) and the third column is the data we want inserted when selected. You can use this translation for a lot of things to simplify selections, file names to full path names, weird SQL table names to more understandable terms e.g. \u201cCustomer Table\u201d to \u201cSQLQCust64527872NMA7657\u201d. If you have seen some SQL databases you know what I mean.<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>An XML file can be used if the text you want to be inserted has more than one line. The functions.xml file is an example for this.<br \/><a href=\"https:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2015\/09\/image17.png\" target=\"_blank\"><img loading=\"lazy\" decoding=\"async\" title=\"image\" style=\"border-left-width: 0px; border-right-width: 0px; border-bottom-width: 0px; display: inline; border-top-width: 0px\" border=\"0\" alt=\"image\" src=\"https:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2015\/09\/image_thumb17.png\" width=\"378\" height=\"139\"><\/a><\/p>\n<p>Selecting an item inserts the corresponding code into your script.<\/p>\n<p><a href=\"https:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2015\/09\/image18.png\" target=\"_blank\"><img loading=\"lazy\" decoding=\"async\" title=\"image\" style=\"border-left-width: 0px; border-right-width: 0px; border-bottom-width: 0px; display: inline; border-top-width: 0px\" border=\"0\" alt=\"image\" src=\"https:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2015\/09\/image_thumb18.png\" width=\"553\" height=\"292\"><\/a><\/p>\n<p>The XML format is very simple.<\/p>\n<p><a href=\"https:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2015\/09\/image19.png\" target=\"_blank\"><img loading=\"lazy\" decoding=\"async\" title=\"image\" style=\"border-left-width: 0px; border-right-width: 0px; border-bottom-width: 0px; display: inline; border-top-width: 0px\" border=\"0\" alt=\"image\" src=\"https:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2015\/09\/image_thumb19.png\" width=\"401\" height=\"147\"><\/a><\/p>\n<p>The root node is called &lt;List&gt;, each individual item is in an &lt;item&gt; tag. The \u201cName\u201d attribute defines the string displayed in the list and the \u201cimage\u201d attribute defines an index into the list\u2019s images. The text to be inserted is contained within a CDATA section. Please note that you <strong>must<\/strong> use a CDATA section, regular text would be ignored.<\/p>\n<p>So now you know how to create simple static lists to insert simple strings or even multi-line text. Next time I will show you how to make these lists multi-select and how to associate a collection of images with your list.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>With the latest service build (7.1.67) of PrimalScript 2015 we introduced a new feature; custom PrimalSense. While many items in a script can be determined dynamically based on context and offered as a selection in a list, there are equally as many items that are tied to your specific environment or your business logic. There [&hellip;]<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[582,410,624,21],"tags":[68,1028,1027,37,168,197],"class_list":["post-9849","post","type-post","status-publish","format-standard","hentry","category-feature-peek","category-primalscript-software-news","category-service-build","category-software-news","tag-csv","tag-customize","tag-intellisense","tag-primalscript","tag-primalsense","tag-xml"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts\/9849","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/comments?post=9849"}],"version-history":[{"count":6,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts\/9849\/revisions"}],"predecessor-version":[{"id":9889,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts\/9849\/revisions\/9889"}],"wp:attachment":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/media?parent=9849"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/categories?post=9849"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/tags?post=9849"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}