Highlighted
Respected Contributor.. Respected Contributor..
Respected Contributor..
629 views

Troubleshooting/view print statement output from script called by SRC Approval Definitions

Jump to solution

I'm trying to set up an Approval Defintion in Service Request Catalog that will call a javascript function in the script library, using the value of one of the User Selections as a parameter.  I'm running into two problems:

1.  The approval is never set, even if I hard code a value in the javascript funciton

2.  I don't know how/where to see the output from print statements in the javascript function.

The function call in the approval definition (xcelSRCGenericTypeOne is a User Selection field name):

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

The javascript function:

function PrivAccessCheck(unixGroupName)

{

var PrivAccess="no";

unixGroupName="ug-esb-dev-xdev"

print("unixGroupName= "+unixGroupName);

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

print("unixGroupPreFix = "+unixGroupPreFix);

if ( unixGroupPreFix == "ug-" )

{

PrivAccess="yes"

}

return PrivAccess;

}

0 Likes
1 Solution

Accepted Solutions
Highlighted
Respected Contributor.. Respected Contributor..
Respected Contributor..

Re: Troubleshooting/view print statement output from script called by SRC Approval Definitions

Jump to solution

I just realized the script is returning no when it should return yes.  Sorry - should have checked before I posted.

View solution in original post

0 Likes
5 Replies
Highlighted
Acclaimed Contributor.
Acclaimed Contributor.

Re: Troubleshooting/view print statement output from script called by SRC Approval Definitions

Jump to solution

Those kind of print messages will only be seen in the Messages windows of the User that triggers that code.

You probably want to write your print statements to the sm.log, so in Javascript, it'll be something like:

system.vars.$L_void = system.functions.rtecall("log", system.vars.$L_rc, "unixGroupName= "+unixGroupName);

0 Likes
Highlighted
Knowledge Partner
Knowledge Partner

Re: Troubleshooting/view print statement output from script called by SRC Approval Definitions

Jump to solution
Set all static in the approval definition and see if it works. If it works, change back to your code and show us a print of your definition.
Regards,
Breno Abreu

If you feel this was helpful please click the KUDOS! thumb below!
Highlighted
Respected Contributor.. Respected Contributor..
Respected Contributor..

Re: Troubleshooting/view print statement output from script called by SRC Approval Definitions

Jump to solution

Thanks for your response.  I've made some updates and received output in the sm.log file.  From the output, it looks like the script is working, but the approval condition isn't firing.

Output:

08/28/18 14:04:55 ug-esb-dev-xdev
08/28/18 14:04:55 ug
08/28/18 14:04:55 no

New Script:

function PrivAccessCheck(unixGroupName)

{

var PrivAccess="no";

unixGroupName="ug-esb-dev-xdev"

print("unixGroupName= "+unixGroupName);

smLogPrint(unixGroupName);

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

print("unixGroupPreFix = "+unixGroupPreFix);

smLogPrint(unixGroupPreFix);

if ( unixGroupPreFix == "ug-" )

{

PrivAccess="yes";

}

print("PrivAccess = "+PrivAccess);

smLogPrint(PrivAccess);

return PrivAccess;

}

function smLogPrint(val)

{

print(val);

writeFile("../logs/sm.log","a","\n"+system.functions.str(system.functions.tod())+"\t"+val); 

}

0 Likes
Highlighted
Respected Contributor.. Respected Contributor..
Respected Contributor..

Re: Troubleshooting/view print statement output from script called by SRC Approval Definitions

Jump to solution

I just realized the script is returning no when it should return yes.  Sorry - should have checked before I posted.

View solution in original post

0 Likes
Highlighted
Respected Contributor.. Respected Contributor..
Respected Contributor..

Re: Troubleshooting/view print statement output from script called by SRC Approval Definitions

Jump to solution

OK, now it works!  I had the substr values wrong (again, I think).

function PrivAccessCheck(unixGroupName)

 {

var PrivAccess="no";

unixGroupName="ug-esb-dev-xdev"

 smLogPrint(unixGroupName);

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

smLogPrint(unixGroupPreFix);

if ( unixGroupPreFix == "ug-" )

{

PrivAccess="yes";

}

smLogPrint(PrivAccess);

return PrivAccess;

}

function smLogPrint(val)

{

print(val);

writeFile("../logs/sm.log","a","\n"+system.functions.str(system.functions.tod())+"\t"+val);

}

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.