...
Code Block |
---|
param( [string]$Name, [rbsingleselect]$WorkerType, #possible values E or C [string]$EmployeeNumber, [string]$CompanyName, [rbyesno]$IsActive, [int]$Salary ) |
Control that will cause others to show/hide
...
Code Block |
---|
function inputVisibility(inputId,isVisible){ //set the visibility of a run dialog control if(document.querySelector("'#"'+inputId) !== null){ document.querySelector("'#"'+inputId).parentNode.parentNode.parentNode.hidden = !isVisible; //document.querySelector("'#"'+inputId).parentNode.parentNode.parentNode.previousSibling.hidden=!isVisible; if(document.querySelector('#'+inputId).type=='radio'){ document.querySelector('#lbl'+inputId.substring(2)).parentNode.hidden=!isVisible; }else{ document.querySelector('#lbl'+inputId).parentNode.hidden=!isVisible; } } } |
Dialog Controls - Initial State
...
Code Block |
---|
function inputVisibility(inputId,isVisible){ //set the visibility of a run dialog control if(document.querySelector("'#"'+inputId) !== null){ document.querySelector("'#"'+inputId).parentNode.parentNode.parentNode.hidden = !isVisible; //document.querySelector("'#"'+inputId).parentNode.parentNode.parentNode.previousSibling.hidden=!isVisible; if(document.querySelector('#'+inputId).type=='radio'){ document.querySelector('#lbl'+inputId.substring(2)).parentNode.hidden=!isVisible; }else{ document.querySelector('#lbl'+inputId).parentNode.hidden=!isVisible; } } } inputVisibility('EmployeeNumber',true); inputVisibility('CompanyName',false); inputVisibility('Salary',false); |
...
Code Block | ||
---|---|---|
| ||
function inputVisibility(inputId,isVisible){ //set the visibility of a run dialog control if(document.querySelector("'#"'+inputId) !== null){ document.querySelector("'#"'+inputId).parentNode.parentNode.parentNode.hidden = !isVisible; //document.querySelector("'#"'+inputId).parentNode.parentNode.parentNode.previousSibling.hidden=!isVisible; if(document.querySelector('#'+inputId).type=='radio'){ document.querySelector('#lbl'+inputId.substring(2)).parentNode.hidden=!isVisible; }else{ document.querySelector('#lbl'+inputId).parentNode.hidden=!isVisible; } } } //For simple criteria, a short hand way to do show/hide fields is to base it directly on the value of another field inputVisibility('EmployeeNumber',document.querySelector('#WorkerType').value == 'E'); inputVisibility('CompanyName',document.querySelector('#WorkerType').value != 'E'); /* //Long form approach for more complex criteria if(document.querySelector('#WorkerType').value == 'E'){ inputVisibility('EmployeeNumber',true); inputVisibility('CompanyName',false); }else{ inputVisibility('EmployeeNumber',false); inputVisibility('CompanyName',true); } */ |
...
Note |
---|
[RbYesNo] parameter/control types follow a slightly different control naming pattern. Each radio button has it’s own control id.
To show/hide an RbYesNo type control, you can simply reference one of the radio button ids and the inputVisibility function will handle hiding all. Eg. |
In this example another controlling control will be the IsActive control. If IsActive:Yes is checked then show the Salary control, otherwise hide it.
...
Code Block | ||
---|---|---|
| ||
function inputVisibility(inputId,isVisible){ //set the visibility of a run dialog control if(document.querySelector("'#"'+inputId) !== null){ document.querySelector("'#"'+inputId).parentNode.parentNode.parentNode.hidden = !isVisible; //document.querySelector("'#"'+inputId).parentNode.parentNode.parentNode.previousSibling.hidden=!isVisible; if(document.querySelector('#'+inputId).type=='radio'){ document.querySelector('#lbl'+inputId.substring(2)).parentNode.hidden=!isVisible; }else{ document.querySelector('#lbl'+inputId).parentNode.hidden=!isVisible; } } } //Note: For RbYesNo control types, each radio button is its own id. // The 'Yes' control id is preface with 'r1'; whereas the 'No' is prefaced with 'r2' inputVisibility('Salary',document.querySelector('#r1IsActive').checked); //'Yes' (the 'r1' prefaced id) is checked |
...
Info |
---|
It is left to the bot developer to have the appropriate logic inside the bot PowerShell to handle the various permutations of some parameters coming in as empty string values. |
Copy of Example Bot
The below can be copied and pasted into the Bot Studio left nav by right clicking on any folder node and selecting paste.
{"Folders":null,"Scripts":[{"ScriptParamValues":null,"ExecutedOn":"1900-01-01T00:00:00Z","LastScriptContentModifiedDate":"2023-11-02T02:56:29.9460724Z","RunStatus":0,"Modules":null,"Content":"","Parameters":null,"ScriptParams":"[{\"Key\":\"$Name\",\"Value\":{\"Name\":\"$Name\",\"Mandatory\":false,\"Position\":0,\"ParameterSetName\":\"__AllParameterSets\",\"ValueFromPipeline\":false,\"ValueFromPipelineByPropertyName\":false,\"ValueFromRemainingArguments\":false,\"HelpMessage\":null,\"DontShow\":false,\"Alias\":null,\"AllowNull\":false,\"AllowEmptyString\":false,\"AllowEmptyCollection\":false,\"ValidateCount\":null,\"ValidateLength\":null,\"ValidatePattern\":null,\"ValidateRange\":null,\"ValidateScript\":null,\"ValidateSet\":null,\"ValidateNotNull\":false,\"ValidateNotNullOrEmpty\":false,\"Type\":\"System.String\",\"TypeName\":\"string\",\"DefaultValue\":null,\"TypeNameForQueryString\":\"string\"}},{\"Key\":\"$WorkerType\",\"Value\":{\"Name\":\"$WorkerType\",\"Mandatory\":false,\"Position\":1,\"ParameterSetName\":\"__AllParameterSets\",\"ValueFromPipeline\":false,\"ValueFromPipelineByPropertyName\":false,\"ValueFromRemainingArguments\":false,\"HelpMessage\":null,\"DontShow\":false,\"Alias\":null,\"AllowNull\":false,\"AllowEmptyString\":false,\"AllowEmptyCollection\":false,\"ValidateCount\":null,\"ValidateLength\":null,\"ValidatePattern\":null,\"ValidateRange\":null,\"ValidateScript\":null,\"ValidateSet\":null,\"ValidateNotNull\":false,\"ValidateNotNullOrEmpty\":false,\"Type\":\"System.String\",\"TypeName\":\"rbsingleselect\",\"DefaultValue\":null,\"TypeNameForQueryString\":\"string\"}},{\"Key\":\"$EmployeeNumber\",\"Value\":{\"Name\":\"$EmployeeNumber\",\"Mandatory\":false,\"Position\":2,\"ParameterSetName\":\"__AllParameterSets\",\"ValueFromPipeline\":false,\"ValueFromPipelineByPropertyName\":false,\"ValueFromRemainingArguments\":false,\"HelpMessage\":null,\"DontShow\":false,\"Alias\":null,\"AllowNull\":false,\"AllowEmptyString\":false,\"AllowEmptyCollection\":false,\"ValidateCount\":null,\"ValidateLength\":null,\"ValidatePattern\":null,\"ValidateRange\":null,\"ValidateScript\":null,\"ValidateSet\":null,\"ValidateNotNull\":false,\"ValidateNotNullOrEmpty\":false,\"Type\":\"System.String\",\"TypeName\":\"string\",\"DefaultValue\":null,\"TypeNameForQueryString\":\"string\"}},{\"Key\":\"$CompanyName\",\"Value\":{\"Name\":\"$CompanyName\",\"Mandatory\":false,\"Position\":3,\"ParameterSetName\":\"__AllParameterSets\",\"ValueFromPipeline\":false,\"ValueFromPipelineByPropertyName\":false,\"ValueFromRemainingArguments\":false,\"HelpMessage\":null,\"DontShow\":false,\"Alias\":null,\"AllowNull\":false,\"AllowEmptyString\":false,\"AllowEmptyCollection\":false,\"ValidateCount\":null,\"ValidateLength\":null,\"ValidatePattern\":null,\"ValidateRange\":null,\"ValidateScript\":null,\"ValidateSet\":null,\"ValidateNotNull\":false,\"ValidateNotNullOrEmpty\":false,\"Type\":\"System.String\",\"TypeName\":\"string\",\"DefaultValue\":null,\"TypeNameForQueryString\":\"string\"}},{\"Key\":\"$IsActive\",\"Value\":{\"Name\":\"$IsActive\",\"Mandatory\":false,\"Position\":4,\"ParameterSetName\":\"__AllParameterSets\",\"ValueFromPipeline\":false,\"ValueFromPipelineByPropertyName\":false,\"ValueFromRemainingArguments\":false,\"HelpMessage\":null,\"DontShow\":false,\"Alias\":null,\"AllowNull\":false,\"AllowEmptyString\":false,\"AllowEmptyCollection\":false,\"ValidateCount\":null,\"ValidateLength\":null,\"ValidatePattern\":null,\"ValidateRange\":null,\"ValidateScript\":null,\"ValidateSet\":null,\"ValidateNotNull\":false,\"ValidateNotNullOrEmpty\":false,\"Type\":\"System.Management.Automation.SwitchParameter\",\"TypeName\":\"rbyesno\",\"DefaultValue\":false,\"TypeNameForQueryString\":\"switch\"}},{\"Key\":\"$Salary\",\"Value\":{\"Name\":\"$Salary\",\"Mandatory\":false,\"Position\":5,\"ParameterSetName\":\"__AllParameterSets\",\"ValueFromPipeline\":false,\"ValueFromPipelineByPropertyName\":false,\"ValueFromRemainingArguments\":false,\"HelpMessage\":null,\"DontShow\":false,\"Alias\":null,\"AllowNull\":false,\"AllowEmptyString\":false,\"AllowEmptyCollection\":false,\"ValidateCount\":null,\"ValidateLength\":null,\"ValidatePattern\":null,\"ValidateRange\":null,\"ValidateScript\":null,\"ValidateSet\":null,\"ValidateNotNull\":false,\"ValidateNotNullOrEmpty\":false,\"Type\":\"System.Int32\",\"TypeName\":\"int\",\"DefaultValue\":0,\"TypeNameForQueryString\":\"int\"}}]","ParameterPromptValues":null,"HasParams":true,"HideDescriptionPanel":false,"VersionNumber":0,"IsVersionDirty":true,"IsChangeMonitoringEnabled":false,"IsSelectiveConnectIdEnabled":false,"ScriptActions":"","CanViewSelfGeneratedRunInstances":false,"RunOnlyAsExplicitScript":false,"IsProvideFullReadiMessage":false,"AllowQuerying":false,"AllowScriptExecutionThroughPowershell":false,"AllowScriptDataAccessThroughRestApi":false,"AllowScriptExecutionThroughRestApi":false,"Alias":null,"IsExecutionRestEndpointDisabled":false,"CanViewScriptRunInstancesTimeline":false,"CanViewScriptLogViews":false,"CanViewScriptExecutionLog":true,"AllowAddDatatableRecordThroughUI":false,"AllowEditDatatableRecordThroughUI":false,"AllowDeleteDatatableRecordsThroughUI":false,"IsDeleteChangeLogs":false,"ScriptExecutionHolder":0,"ChangeLogGroups":null,"ChangeStatus":0,"ChangeCount":0,"IsChangeMonitoringPerformed":false,"ZipContent":"1AAAAB+LCAAAAAAABABdjr0KwkAQhPtA3mHBKxTuFSwkpLBJo2AhKfbCKod7P+xeAvf2phAhmenmg5nJKBiOAG0Dq55axMf3aAYMZH+ZOF0zJiWmqYzmkeRDcq+ZLBxyUvWOCRbkmRR6SALdrq0PmVMlGubgSOyOdilkjHU7WUljGs1VL1PxC53NC1n/3Mf1xw0ZpbbNqW22/gLeaboH1AAAAA==","ZipExecutedContent":null,"ZipParameterPromptValues":"CxAAAB+LCAAAAAAABADtV21v2zYQ/isXbYDsTrDQ7ltSD9i8DAi2GsVidBjWfKCks0WEJjWSsqsG+e89Ui+WYztWh2EfhsCBIx4f3h0f3T2kH4JCq3VhF/jJBpfBe4HMIJBtwzMEm9Mz02yNFjVsmCjRTIIoyDgTajVjheVK0rKfK8nWPIX3DmsIoEv5U2mtko1fMtmcyftKle/QGLZCMr7Nv/9h0VjfxjQg1BaT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"CertificateThumbprint":null,"CertificateName":null,"SignedBy":null,"SignDate":"1900-01-01T00:00:00Z","IsSendAlertOnNoData":false,"ScriptRefreshKey":"","RuleSets":"","ScriptDataType":0,"WorkerCost":"60","UntrackSavingsFlag":false,"ConservedTime":"0.5","WorkerCostCurrency":0,"ROIMetricsCategory":"Uncategorized","ROIMetricsTags":null,"Name":"Dynamic Params","ParentId":"422d1171-53f5-4065-9dc7-951256e52e34","IsScript":true,"CreatedOn":"2023-10-25T20:50:13.7871802Z","UpdatedOn":"2023-12-01T18:34:02.2701661Z","JobScheduleOption":0,"IsShared":false,"IsSharedSolutionNode":false,"SharedSolutionIdentifier":null,"ConnectId":null,"AvailableConnectIds":"","CredentialOption":1,"RetentionOption":3,"RetentionNumber":1,"RetentionUnit":4,"SequenceWithinParent":71,"PermissionOption":0,"JsonDepth":0,"MaxItemsToDequeue":0,"PermittedRunInstances":0,"IgnoreNoDataResults":false,"PartitionKey":"a6d1b007-d7a9-473c-bf54-6e2e8425f557","RowKey":"874eee81-5cef-4a05-a14a-f5d42df119ed","Timestamp":"2023-12-01T18:34:02.3173132+00:00","ETag":"W/\"datetime'2023-12-01T18%3A34%3A02.3173132Z'\""}],"Views":[],"SourceWorkspaceId":"a6d1b007-d7a9-473c-bf54-6e2e8425f557"}