Absent Member.. DBR Absent Member..
Absent Member..
403 views

Check to see if result of a flow is null and if so, set it to a value.

Jump to solution

Is there some method out of the box that would allow me to do the below?

 

Check to see if result of a flow is null and if so, set it to a value.

 

Thanks,

Don

 

Labels (1)
0 Likes
1 Solution

Accepted Solutions
Absent Member.. Steve_Drummond Absent Member..
Absent Member..

Re: Check to see if result of a flow is null and if so, set it to a value.

Jump to solution

Excellent, glad to hear you got it sorted. On the 'check null' operation in the library if you have a look at the scriptlet tab you can see it basically doing the same check (undefined, null and zero-length string).

 

I personally don't treat zero-length as null but OO does.

 

If that's helped do you mind marking it as the solution?

 

cheers

steve

0 Likes
4 Replies
Established Member.. Gontran
Established Member..

Re: Check to see if result of a flow is null and if so, set it to a value.

Jump to solution

Hello Don,

 

     The "String Equals" operation allows you to compare against empty values.

     Operation: /Library/Utility Operations/Math and Comparasion/String Equals

 

 

 

<pre>
Compares two strings, returning a true response if and only if they contain the same sequence of characters. A null string is considered to be equal to an empty string.

Inputs:
string1 - The first string.
string2 - The second string.
ignoreCase - If set to 'true', then the comparison ignores case considerations. The two strings are considered equal ignoring case if they are of the same length and corresponding characters in the two strings are equal ignoring case. If set to any value other than 'true', then the strings must match exactly to be considered equal.

responses:
true - If the two strings are equal
false - If the two strings are not equal

</pre>

 I hope this information help you to accomplish your task

0 Likes
Absent Member.. Steve_Drummond Absent Member..
Absent Member..

Re: Check to see if result of a flow is null and if so, set it to a value.

Jump to solution

Hi Don,

 

There are a couple of ways you can do this.

 

There is an operation in /lib/Utility Operations/Flow Variable Manipulation/Check Null that takes a variable name as input and has "is Null" "not Null" responses that can point to other operations.

 

Alternatively if you want to make sure it always has a value you can either instanstiate it before hand in the flow, or you can handle it all within the result; add a filter to the result and choose type "Scriptlet". Set the body of the scriptlet to be:

 

scriptletResult = (typeof scriptletInput == "undefined" || scriptletInput == null ? "" : scriptletInput);

 This will set the result to a zero-length string if the result is null or wasn't defined, otherwise it simply returns back what it got in. The above code is a conditional setting, it's equivalent in a If/Else is

 

if (typeof scriptletInput == "undefined" || scriptletInput == null)
{
  scriptletResult = "";
}
else
{
  scriptletResult = scriptletInput;
}

 If you are going to be using this approach a lot then you can create a new System Filter that developers can just drag into as a new Filter. You can do this in Studio by going to /Configuration/System Filters and Right Click -> Create New -> Scriptlet.

 

Hope this helps.

 

cheers

steve

0 Likes
Absent Member.. DBR Absent Member..
Absent Member..

Re: Check to see if result of a flow is null and if so, set it to a value.

Jump to solution

Steve,

 

Thanks for the help!

 

I had to modify a bit to work but you pointed me in the right direction.

 

if (typeof scriptletInput == "undefined" || scriptletInput == null || scriptletInput == "")
{
  scriptletResult = "All servers are OK.";
}
else
{
  scriptletResult = scriptletInput;
}

 

Thanks!

Don

 

0 Likes
Absent Member.. Steve_Drummond Absent Member..
Absent Member..

Re: Check to see if result of a flow is null and if so, set it to a value.

Jump to solution

Excellent, glad to hear you got it sorted. On the 'check null' operation in the library if you have a look at the scriptlet tab you can see it basically doing the same check (undefined, null and zero-length string).

 

I personally don't treat zero-length as null but OO does.

 

If that's helped do you mind marking it as the solution?

 

cheers

steve

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.