Skip to content
DataMiner DoJo

More results...

Generic selectors
Exact matches only
Search in title
Search in content
Post Type Selectors
Search in posts
Search in pages
Search in posts
Search in pages
Log in
Menu
  • Blog
  • Questions
  • Learning
    • E-learning Courses
    • Open Classroom Training
    • Certification
      • DataMiner Fundamentals
      • DataMiner Configurator
      • DataMiner Automation
      • Scripts & Connectors Developer: HTTP Basics
      • Scripts & Connectors Developer: SNMP Basics
      • Visual Overview – Level 1
      • Verify a certificate
    • Tutorials
    • Video Library
    • Books We Like
    • >> Go to DataMiner Docs
  • Expert Center
    • Solutions & Use Cases
      • Solutions
      • Use Case Library
    • Markets & Industries
      • Media production
      • Government & defense
      • Content distribution
      • Service providers
      • Partners
      • OSS/BSS
    • DataMiner Insights
      • Security
      • Integration Studio
      • System Architecture
      • DataMiner Releases & Updates
      • DataMiner Apps
    • Agile
      • Agile Webspace
      • Everything Agile
        • The Agile Manifesto
        • Best Practices
        • Retro Recipes
      • Methodologies
        • The Scrum Framework
        • Kanban
        • Extreme Programming
      • Roles
        • The Product Owner
        • The Agile Coach
        • The Quality & UX Coach (QX)
    • DataMiner DevOps Professional Program
  • Downloads
  • More
    • Feature Suggestions
    • Climb the leaderboard!
    • Swag Shop
    • Contact
      • General Inquiries
      • DataMiner DevOps Support
      • Commercial Requests
    • Global Feedback Survey
  • PARTNERS
    • All Partners
    • Technology Partners
    • Strategic Partner Program
    • Deal Registration
  • >> Go to dataminer.services

Protocol automation script validation

Solved1.08K views24th February 2023automation scipt validation
8
Maria Cunha [SLC] [DevOps Advocate]379 24th February 2023 0 Comments

I want to add a parameter in a protocol that allows the user to configure a script that should be used later for some actions.

How should I go about validating the script name to make sure the input provided is a valid script and that would not cause issues when trying to execute it?

Maria Cunha [SLC] [DevOps Advocate] Selected answer as best 24th February 2023

1 Answer

  • Active
  • Voted
  • Newest
  • Oldest
10
João Severino [SLC] [DevOps Catalyst]12.94K Posted 24th February 2023 0 Comments

Hi Maria,

There are a few options you can implement depending on how simple or advanced you want your validation to be.
The simplest would be to have a string parameter and have your write parameter trigger a QAction for you to perform some validations.
To validate you could use a logic similar to the snippet below and that would already check if the input provided is a valid script.

private static bool IsValidScriptName(SLProtocol protocol, string scriptName)
{
if (String.IsNullOrWhiteSpace(scriptName))
{
return false;
}

var response = (GetScriptsResponseMessage)protocol.SLNet.SendSingleResponseMessage(new GetInfoMessage(InfoType.Scripts));
var scriptNames = response.Scripts;
return scriptNames.Contains(scriptName, StringComparer.OrdinalIgnoreCase);
}

You could then use something like protocol.ShowInformationMessage to present the user with a message stating the provided input is invalid, see docs for more info about the ShowInformationMessage method, paying particular attention to the remarks that say this pop-up window will only work from QActions that are directly triggered from a client with user interaction.

This should work for your use case but I do have to add a disclaimer here that these kinds of SLNet calls are internal calls and typically not recommended to use since there is no official support and may be subject to change in the future.

If you want to go for a more advanced approach you could use the same SLNet call as above to pre-populate a dynamic discreet with possible values and allow the user to select from those.
See dependencyId for the option that allows you to create a dynamic discreet by providing a semicolon-separated list of items.
Ideally, this would be coupled with a refresh button so the user can rescan the system for new scripts.

A third option would be to do something similar to the second option I mention but instead of fetching all scripts on the system, you could limit your search to just one or a couple of folders where the script may reside.
This would reduce the list size and improve usability so the user can find what he needs faster.

See snippet below

private static Dictionary<string, List<string>> GetScriptsGroupByFolder(SLProtocol protocol)
{
GetAutomationInfoMessage message = new GetAutomationInfoMessage(21, String.Empty);
var allScripts = (GetAutomationInfoResponseMessage)protocol.SLNet.SendSingleResponseMessage(message);

List<SA> list = new List<SA>();
if (allScripts != null)
{
list.AddRange(allScripts.psaRet.Psa);
}

Dictionary<string, List<string>> dictionary = new Dictionary<string, List<string>>();
foreach (SA item in list)
{
if (item == null || item.Sa == null || !item.Sa.Any() || item.Sa[0] == null)
{
continue;
}

string key = item.Sa[0];
List<string> list2 = new List<string>();
for (int i = 1; i < item.Sa.Length; i++)
{
string text = item.Sa[i];
if (!string.IsNullOrWhiteSpace(text))
{
list2.Add(text);
}
}

dictionary.Add(key, list2);
}

return dictionary;
}

Maria Cunha [SLC] [DevOps Advocate] Selected answer as best 24th February 2023
You are viewing 1 out of 1 answers, click here to view all answers.
Please login to be able to comment or post an answer.

My DevOps rank

DevOps Members get more insights on their profile page.

My user earnings

0 Dojo credits

Spend your credits in our swag shop.

0 Reputation points

Boost your reputation, climb the leaderboard.

Promo banner DataMiner DevOps Professiona Program
DataMiner Integration Studio (DIS)
Empower Katas

Recent questions

Alarm Dashboard PDF/CSV Export 1 Answer | 0 Votes
Is the Microsoft SharePoint Connector Still Usable 0 Answers | 0 Votes
Is the Microsoft SharePoint Connector Still Usable 0 Answers | 0 Votes

Question Tags

adl2099 (115) alarm (62) Alarm Console (82) alarms (100) alarm template (83) Automation (223) automation scipt (111) Automation script (167) backup (71) Cassandra (180) Connector (108) Correlation (68) Cube (150) Dashboard (194) Dashboards (188) database (83) DataMiner Cube (57) DIS (81) DMS (71) DOM (139) driver (65) DVE (55) Elastic (83) Elasticsearch (115) elements (80) Failover (104) GQI (159) HTTP (76) IDP (74) LCA (151) low code app (166) low code apps (93) lowcodeapps (75) MySQL (53) protocol (203) QAction (83) security (88) services (51) SNMP (86) SRM (337) table (54) trending (87) upgrade (62) Visio (539) Visual Overview (345)
Privacy Policy • Terms & Conditions • Contact

© 2025 Skyline Communications. All rights reserved.

DOJO Q&A widget

Can't find what you need?

? Explore the Q&A DataMiner Docs

[ Placeholder content for popup link ] WordPress Download Manager - Best Download Management Plugin