Service Portal widget Server script help needed

gjz
Mega Sage

In the Service Portal widget Catalog Checkout (sc-checkout), there is a line to determine who the request_for person is using the system property glide.sc.request_for.query.

 

I needed to modify the request_for query to change the list of users depending on some specific criteria and changed it to

 

gjz_7-1739475819365.png

 

The script include figures out the list of users depending on gs.UserID() and what permissions they might have.  This code is working fine, the appropriate list of users is available to the user in the portal.

 

Now I have a request to include inactive users if it is an Offboard order guide.  This is where I'm stuck.

 

I know the widget has access to the order guide's sys_id because I've seen it in the Service Portal Log Entry table, but I don't seem to be able to use the data to determine if my custom query needs to include active or inactive users.

 

I've determined the order guide sys id is available in localInput.itemDetails.sys_id because I can see the value in the Service Portal Log Entry, but when I try to use it to change my query, it doesn't work. 

 

This screen shot is only showing the action for "from_attachment", but it the localInput.itemDetails.sys_id I want is used in several places in the server script.

 

gjz_0-1739474597283.png

 

 

gjz_1-1739474724057.png

 

gjz_8-1739476018846.png

 

gjz_6-1739475509916.png

 

 

While I'm really good at code, I'm a newbie at understanding service portal widgets and am hoping someone else with more experience with widgets can help me understand why the code doesn't work.

3 REPLIES 3

GopikaP
Mega Sage

Hi @gjz , I attempted to replicate your request to the best of my ability and noticed that 'localInput.item.sys_id' is returning an 'undefined' value(in the if - condition part). However, I tried a different approach using '$sp.getParameter('sys_id')'. Please refer to the screenshot for details. Also, I have attached what I have configured in the script include. If this isn't what you were expecting, please provide clarification.

Hi Gopika,

I haven't tried your solution but it wouldn't surprise me if it worked. I found I was able to get the sysid of the catalog item or order guide by using options.cart.name instead of localInput.itemDetails.sys_id.  I created a variable, then used the variable to determine the list of users.

 

var fromCartId = options.cart.name

Hi @gjz , Oh, I see, That’s great , glad it worked.