NOTICE: Branded Content
NOTICE: 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.
Service Manager / Service Center User Discussions
cancel

SRC Approval definition based on substr of user selection value

Highlighted
Respected Contributor.. Mark Siple Respected Contributor..
Respected Contributor..

SRC Approval definition based on substr of user selection value

I'm trying to get an approval definition to execute based on the results of the substr function applied to the value of a user selection field in SRC. So far, it either doesn't work or returns an error.

For example, the value entered for user selection "xcelSRCGenericTypeOne" is ug-esb-dev-xdev

I have an approval definition that calls a javascript function with the value of "xcelSRCGenericTypeOne" as the input parameter:

jscall("xcelSRCUNIXGroupUtils.PrivAccessCheck", "xcelSRCGenericTypeOne")="yes"

The javascript is as follows:

function PrivAccessCheck(unixGroupName)

{

var PrivAccess="no";

var unixGroupPreFix=unixGroupName.substring(1,3); 

if (unixGroupPreFix=="ug-")

PrivAccess="yes";

return PrivAccess;

}

This does not cause the approval definition to execute.

2 REPLIES
Outstanding Contributor.. AChandler Outstanding Contributor..
Outstanding Contributor..

Re: SRC Approval definition based on substr of user selection value

Two issues:

1: Your substring() should start with 0, not 1. The first character in a JS string is at the 0 position.

2: Assigning a value to, and returning, PrivAccess should be enclosed in braces following your if condition. You have to tell the code what to do, should that if be true.

Thus:

var unixGroupPreFix = unixGroupName.substring(0,3);

if ( unixGroupPreFix == "ug-" )
    {
     PrivAccess="yes";

     return PrivAccess;
    }
Respected Contributor.. Mark Siple Respected Contributor..
Respected Contributor..

Re: SRC Approval definition based on substr of user selection value

Thanks for answering my noob question.  I appreciate you taking the time.