Highlighted
Respected Contributor.. Respected Contributor..
Respected Contributor..
525 views

How to pass Service Request Catalog User Selection value in an Approval Definition function call

Jump to solution

I'm trying to pass the value of a user selection to an Approval Definition that uses a function call.  I've verified that the function works by hard-coding the parameter value in the script, but it passes the name of the user selection rather than the value when I try to pass it in as a parameter.

The function call in the Approval Defintion condition:

jscall("xcelSRCUNIXGroupUtils.PrivAccessCheck", "xcelSRCGenericTypeOne in $File")="yes"

returns

08/29/18 09:25:31 xcelSRCGenericTypeOne in $File
08/29/18 09:25:31 xce
08/29/18 09:25:31 no

I receive an error if I don't put the parameter in quotes.

Below is the function

function PrivAccessCheck(unixGroupName)
{
var PrivAccess="no";
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
1 Solution

Accepted Solutions
Highlighted
Acclaimed Contributor.
Acclaimed Contributor.

Re: How to pass Service Request Catalog User Selection value in an Approval Definition function call

Jump to solution

I have one approval definition which calls JS lib.

jscall("GetManager.IsApprovalNeeded", nullsub(contact.name in $L.file, requested.for in $L.file))=true

But I'd like to point out that both fields are actual fields in incidents table. I can't refer straight away to a single user option. Why?

User selections are not actual fields in SD ticket. User selections are bundled into XML format to the field called svc.options. At a first sight, this is quite confusing, but product designers have reasonably thought that it gives the maximum flexibility but minimizes the need to create dozens of DB fields for catalog purposes. 

Check a SD ticket (type: service catalog) and use RAD debugger to print out:

d svc.options in $L.file

The output should be XML code. You can't refer to a certain XML item in a similar way than to a single "real" field in a DB such as incident.id or title. You need some JS code to go though the XML tree and pick the correct values.

What I recommend is that you pass the $L.file to your JS code, print it to the log in a code and check what data it has eaten by then. If svc.options is already populated, you can clearly spot the XML code from the log output.

After then, it's time to think how to carve out the XML tag and its content, but this forum contains many fresh topics about it.

EDIT: If you have a version 9.40 or later, there's also a table called userOption, that actually renders all the user selections items as a proper DB items. OOB version of SM does not offer forms to browse it, so use DB tool to check its contents and you get a grasp what fields you need in your query.

---
Moving on, this account is no longer active. Best regards, Kelalek
- So Long, and Thanks for All the Fish

View solution in original post

0 Likes
3 Replies
Highlighted
Acclaimed Contributor.
Acclaimed Contributor.

Re: How to pass Service Request Catalog User Selection value in an Approval Definition function call

Jump to solution

I have one approval definition which calls JS lib.

jscall("GetManager.IsApprovalNeeded", nullsub(contact.name in $L.file, requested.for in $L.file))=true

But I'd like to point out that both fields are actual fields in incidents table. I can't refer straight away to a single user option. Why?

User selections are not actual fields in SD ticket. User selections are bundled into XML format to the field called svc.options. At a first sight, this is quite confusing, but product designers have reasonably thought that it gives the maximum flexibility but minimizes the need to create dozens of DB fields for catalog purposes. 

Check a SD ticket (type: service catalog) and use RAD debugger to print out:

d svc.options in $L.file

The output should be XML code. You can't refer to a certain XML item in a similar way than to a single "real" field in a DB such as incident.id or title. You need some JS code to go though the XML tree and pick the correct values.

What I recommend is that you pass the $L.file to your JS code, print it to the log in a code and check what data it has eaten by then. If svc.options is already populated, you can clearly spot the XML code from the log output.

After then, it's time to think how to carve out the XML tag and its content, but this forum contains many fresh topics about it.

EDIT: If you have a version 9.40 or later, there's also a table called userOption, that actually renders all the user selections items as a proper DB items. OOB version of SM does not offer forms to browse it, so use DB tool to check its contents and you get a grasp what fields you need in your query.

---
Moving on, this account is no longer active. Best regards, Kelalek
- So Long, and Thanks for All the Fish

View solution in original post

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

Re: How to pass Service Request Catalog User Selection value in an Approval Definition function call

Jump to solution

Thanks for the excellent explanation.  I have it working now.

0 Likes
Highlighted
Frequent Contributor.. Frequent Contributor..
Frequent Contributor..

Re: How to pass Service Request Catalog User Selection value in an Approval Definition function call

Jump to solution
Please send me exact steps to solve this issue
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.